Posts

Showing posts from May, 2012

Algorithm to get group index of item in chunked array -

so have arbitrary array of items: array = [0,1,2,3,4]; and when it's been chunked looks like: array.chunk(2) => [[0,1],[2,3],[4]]; array.chunk(3) => [[0,1,2],[3,4]]; what i'd algorithm index of group index in, based on group size. for instance, running algorithm on each element in array yield: array.chunkindex( chunksize = 2, index = n ) 0 => 0 1 => 0 2 => 1 3 => 1 4 => 2 array.chunkindex( chunksize = 3, index = n ) 0 => 0 1 => 0 2 => 0 3 => 1 4 => 1 so running algorithm on index chunksize = 1 yield original index. how go doing this? clear, don't want chunk array, determine group in, without looping , without built-in functions, if possible. also in psuedo-code: chunkindex = index / chunksize it's simple integer division means case have careful of languages return float/decimal/real. cases, need floor function find integer part of result. may wish handle negative values also.

Single-precision floating-point format Range -

sign = 1 bit, biased exponent = 8 bits, mantissa = 23 bits what positive , negative possible range? teacher told me following range: -0.5*2^-128 -(1-2^-24)*2^127 (for negative floating point numbers) 0.5*2^-128 (1-2^-24)*2^127 (for positive floating point numbers) but don't find range correct because not able understand how store 0.5 * 2 -128 format. please explain. firstly, floating-point number format symmetric positive , negative numbers. @ positive case. the maximum positive number has maximum mantissa 1.11111111111111111111111 2 , maximum non-infinite exponent 127. 1.11111111111111111111111 2 × 2 127 = (2 − 2 −23 ) × 2 127 ≈ 3.402 × 10 38 ≈ 2 128 . the minimum positive number has non-zero mantissa 0.00000000000000000000001 2 , minimum exponent −126 subnormal/denormalized numbers. 0.00000000000000000000001 2 × 2 −126 = 2 −23 × 2 −126 = 2 −149 ≈ 1.401 × 10 −45 . further reading: https://en.wikipedia.org/wiki/single-precision_floating-poi...

java - Codechef "Primality Test" Wrong answer -

problem: alice , bob meeting after long time. usual love play math games. times alice takes call , decides game. game simple, alice says out integer , bob has whether number prime or not. bob usual knows logic since alice doesn't give bob time think, bob decides write computer program. bob accomplish task writing computer program calculate whether number prime or not . input the first line of input contains t testcases, t lines follow each of t line contains integer n has tested primality output for each test case output in separate line, "yes" if number prime else "no" my solution: `import java.io.*; import java.math.*; import java.util.*; class ex6 { public static void main(string args[])throws ioexception { try { bufferedreader input=new bufferedreader(new inputstreamreader(system.in)); int t=0; t=integer.parseint(input.readline()); int n=0; int c=0; while(c!=(t)) { int j=0; n...

email - PHP mail() headers -

i have following headers want pass mail() function: $headers = "mime-version: 1.0\r\n"; $headers .= "x-mailer: php/" . phpversion()."\r\n"; $headers .= "from:".$sender_email."\r\n"; $headers .= "subject:".$subject."\r\n"; $headers .= "reply-to: ".$sender_email."" . "\r\n"; $headers .= "content-type: multipart/mixed; boundary=".md5('boundary1')."\r\n\r\n"; $headers .= "--".md5('boundary1')."\r\n"; $headers .= "content-type: multipart/alternative; boundary=".md5('boundary2')."\r\n\r\n"; $headers .= "--".md5('boundary2')."\r\n"; $headers .= "content-type: text/plain; charset=iso-8859-1\r\n\r\n"; $headers .= $message."\r\n\r\n"; $headers .= "--".md5('boundary2')."--\r\n"; $headers .= "--".md5('boundary1')....

if statement - PHP: If not selecting correctly -

i building list based off of csv file. here 2 common lines in csv file: 10,11,12,13,14,15,16 12,13,14,15,16,0,0 the file read line-by-line , stored list. here code: while(($current_line = fgets($find_products, 4096)) !== false) { list($weight1, $weight2, $weight3, $weight4, $weight5, $weight6, $weight7) = explode(",", $current_line); } i @ value of each item in list, , print if value not 0. here code: if($weight1 != '0') { print '<option>'.$weight1.' lb.</option>'; } if($weight2 != '0') { print '<option>'.$weight2.' lb.</option>'; } if($weight3 != '0') { print '<option>'.$weight3.' lb.</option>'; } if($weight4 != '0') { print '<option>'.$weight4.' lb.</option>'; } if($weight5 != '0') { print '<option>'.$weight5.' lb.</option>'; } if($weight6 != '0...

angularjs - "x is not defined" when call a javascript function -

i have code this: <ion-content> <ion-list> <ion-item > 订单号 餐桌 顾客姓名 顾客电话号码 配送地址 订单备注 下单时间 </ion-item> <ion-item ng-repeat="x in orders|orderby:'order_id'"> {{ x.order_id + ', ' + x.table_id+', '+x.name+', '+x.phone+', '+x.address+', '+x.remark+', '+changtimetostring(x.ctime)}} <button onclick="window.vieworderdetails(x.detail)">order detail</button> </ion-item> </ion-list> </ion-content> in app.js: app.controller('customerscontroller', ['$scope', '$http', function($scope,$http) { $http.get("http://18ff2f50.tunnel.mobi/yii2-basic/tests/customers_json.json") .success(function (response) { console.log("debug",response); $scope.orders = response; }); window.vieworderdetails = function vieworderd...

c - BCM2708 (RPi) Rasbpian FIQ not triggered -

i have written linux loadable kernel module attempts attach fiq service gpio edge transistions. pin in question on gpio0 (irq 49) attempt configure fiq follows: #ifndef gpio_base #define gpio_base 0x7e200000 #endif #define gpio_len 0x60 #define gpio_gpeds0 0x10 #define gpio_gpeds1 0x11 #define gpio_gpren0 0x13 #define gpio_gpren1 0x14 #define gpio_gpfen0 0x16 #define gpio_gpfen1 0x17 #define air_base 0x7e00b200 #define air_len 0x28 #define air_ip2 2 // irq pending source 63:32 #define air_fiq 3 // fiq config register #define air_fiq_an 0x80l // fiq enable field mask #define air_fiq_src 0x7fl // fiq source field mask #define air_en2 5 // irq enable irq source 63:32 #define air_de2 8 // irq disable irq source 63:32 #define air_gpio0_irq 49 struct { uint32_t wr_p; } fiq_data_s; extern unsigned char pulse_logger_fiq_handler, pulse_logger_fiq_handler_end; static struct fiq_handler...

mysql - C# - SQL Database - Sending query to update records however too many update requests cause some to get missed -

i've searched high , lo, apologies if have missed something. when run source, no errors arise , looks if working should, when inspect database, records have been updated/added , others have been missed. the rate of updates varies between 1 per second upwards of 25 per second (some headroom/just incase, typically around 15). in section, query database pull existing values, make adjustments on values, save database. below snippet updates sql database, there 43 columns being updated (some may remain same value, being re-added). is there way can ensure update requests pass through , succeed in updating? try { mysqlcommand cmd2 = connection.createcommand(); connection.open(); cmd2.commandtype = commandtype.text; cmd2.commandtext = "update user_information set examplevalue = @examplevalue username = @username"; cmd2.parameters.addwithvalue("@username", username); cmd2.parameters.addwithvalue("@examplevalue", exampleva...

Eclipse will not recognize my Scala main -

what i've tried: ensuring scala perspective set, disabled, set again ensuring right click on object extends app i never 'run scala application...' @ point defining explicit 'main' in object after removing 'extends app' what 'run configurations..." when right-click on object main(). no matter there, e.g. enter name of object extends app or has explicit main, main() never found , classloader stack trace dumps indicating there no main. while no scala compile errors, no matter try, never 'run as...scala application'. code: object fatfinger extends app { import com.mongodb.casbah.imports._ import common._ import mongofactory._ */ object insert { def main(args: array[string]) { val apple = stock("aapl", 600) val google = stock("goog", 650) val netflix = stock("nflx", 60) savestock(apple) savestock(google) savestock(netflix) } def savestock(...

ios - UITableViewCell display under other view -

Image
i cannot convince uitableviewcell display under view per attached image. happens when embed uitableview uiviewcontroller . vouchertableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"vouchertableviewcell" forindexpath:indexpath]; if (cell == nil) { cell = [[vouchertableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:@"vouchertableviewcell"]; } image 1 before scrolling up. image 2 problem. just try in viewdidload code self.edgesforextendedlayout = uirectedgenone; self.tableview.contentinset = uiedgeinsetsmake(0, 0, yourtopiew.height, 0);

python - Tornado: Are there Request Filters? -

i looking @ tornado app , wondering how perform use case. need intercept every request before dispatching url handler , possibly return redirect. there way using tornado? i wondering if tornado has concept of servlet filter. looks maybe input modifier decode_argument does this? seems bit of hack filter request using method, haven't found else in documentation. you have al least 3 options: use requesthandler.prepare() kamushin said . as said in this tornado issue comment : you can hook middleware, actually. httpserver request handlers callable objects (function, methods, or objects implement __call__ ). can write own handler passes on requests application (example) my_app = tornado.web.application(...) def middleware(request): # whatever transformation want here my_app(request) if __name__ == '__main__': http_server = tornado.httpserver.httpserver(middleware) # ... but notice that: since tornado request handling ca...

c - detect incomplete 32 bit binary data -

i have binary file need read 32 bit patterns- in event if eof reached such less 32 bits - need error out saying unexpected eof else break. tried lot unable incomplete bytes detecting part working. can provide pointer how achieve ? did thought of exploring 1 byte @ time byte[0] , evaluating if eof didnt work. (;;) { bytes_read = fread(buffer, 4, 1, infile); if (bytes_read == 1) { // perform task } else { // detect if incomplete sequence or eof , output appropriately } } p.s : editing fread per comment - your code tells fread read 1 record, containing 4 bytes, file. if record incomplete, return 0 (0 records read, error). if record missing (at end of file), return 0 (0 records read, normal situation). must adjust code distinguish these cases, having fread return 4 (bytes) instead. if it's impossible read 4 bytes @ end of file, want fread output less 4. have behavior, should tell fread read in units of 1 ...

Is it possible in iOS 8 to use swipe to go back on TableviewController in Swift? -

so i'm using navigation controller segue view controller a(vca) multiple other controllers: view controller b(vcb), tableview controller a(tca) , , tableview controller b(tcb). when segue vca vcb , can swipe left right , return vca . problem run same feature does/t work when go vca tca or vca tcb. can click on button , takes vca, wanted gesture feature. possible achieve want, or option create 2 view controllers , insert tableview in each?

html - How to get my text on correct position next to custom checkbox? -

#admin_status label { width: 80px; display: inline-block; margin-right:15px; } #admin_status label input[type="checkbox"] { display:none; } #admin_status label input[type="checkbox"] + .label-text:before { content: url("../images/04_checkbox_radiobutton.png"); font-family: 'roboto', sans-serif; speak: none; font-style: noraml; font-size: normal; font-variant: normal; font-transform: normal; line-height: 1; -webkit-font-smoothing: antialiased; width: 1em; display: inline-block; margin-right: 5px; } #admin_status label input[type="checkbox"]:checked + .label-text:before { content: url("../images/04_checkbox_radiobutton_checked.png"); } #admin_status .checkbox-inline { width:100px; padding-left:0px; } #admin_status .checkbox-inline span { margin-left:20px; font-size: 1em; } <div id="admin_status"> <la...

tkinter - How to give an "argument" to my function in Python? -

i using python 2.7 , tkinter. trying make button change own text when clicked. code seems correct, keep encountering error: exception in tkinter callback traceback (most recent call last): file "/usr/lib/python2.7/lib-tk/tkinter.py", line 1413, in __call__ return self.func(*args) typeerror: dostuff takes 1 argument (0 given) here code: def dostuff(event): button01.configure(command=dostuff2) button01.configure(text="click me again!") button01 = button(root, text="click me", command=dostuff) button01.grid(row=8, column=6) where screwing , how pass needed argument dostuff() ? you defined function taking event . for? have bound keyboard key? keyboard key, when pressed, pass event whatever function it's bound to. however, button widget not. if function connected button , remove event function definition. if have bound function both button , keyboard key (or mouse action, or else generates event), give default argume...

Ansible playbook vars not working in templates -

i have problem getting variables work in templates. variables work in playbook in templates, rendered 'as is' without getting replaced values. here simple test-playbook.yml trying. --- - name: test playbook vars hosts: webservers vars: hello_var: hello world hello_file_path: /tmp/hello_file.txt tasks: - name: copy hello world file copy: src=templates/hello_world.txt.j2 dest={{ hello_file_path }} in templates/hello_world.txt.j2 , have following contents hi {{ hello_var }} after running playbook, have on host @ /tmp/hello_world.txt same content in template hi {{ hello_var }} the variable hello_file_path used in playbook works variable hello_var used in template not working. inside task using copy module copies file without template processing. in order use template need use template module . - name: copy hello world file template: src=templates/hello_world.txt.j2 dest={{ hello_file_path }}

java - Searching a grid of points, visting each point once only -

Image
i have grid of (d) dimensions, dimensions partitioned using delta = 0.25 an example of grid figure (d here 2, , each dimension normalized 0-1): each intersection represents 1 point, example, point in middle represented as: double[] a={0.5, 0.5}; my question is: want search grid, starting input point , neighbors. continue doing that. 1 condition: each point visited once. to clarify more, consider example: starting point is: double[] a={0.5, 0.5}; so, checked first, neighbours generated , inserted queue (the queue ordered based on function f). here point dark circle . neighbors green circles: {0.25, 0.25} {0.25, 0.5} {0.25, 0.75} .. .. .. {0.75, 0.75} now, algorithm loops until queue becomes empty. in loop, top point removed (pop()), checked, neighbors added queue. for example, in first loop, blue circle happened top point in queue. removed queue, checked, neighbors (red circles) generated , added queue. the problem here is, code generates neighbors poi...

sql server - Copy Data from multiple table to one table without duplicate -

i want insert data source (1&2) tables destination table without duplicates table: source songs artists album s baby john rocknroll moon mike moonlight firefly chad garden table: source2 songs artists albums happy jane fresh baby john rocknroll bday zelda link table: destination id song artist album catalog# track# <--- columns 1 baby john rocknroll here code: insert destination (song, artist, album) select distinct so.songs, so.artists, so.albums, source left join destination ds on ds.song= so.songs , ds.artist= so.artists , ds.album= so.albums ds.song null , ds.song null , ds.songis null however after trying code on both table still duplicate i tried union have m...

How to convert C++ header file to delphi -

i'm converting c++ header delphi pas file. first, converted c++ header using headconv 4.0 dr.bob module. failed compiling. can converting? ****** c++ header ****** #if !defined(____kkk_module__) #define ____kkk_module__ #ifdef kkk_module_exports #define kkk_module_api extern "c" __declspec(dllexport) #else #define kkk_module_api extern "c" __declspec(dllimport) #endif kkk_module_api int _stdcall kkk_creat(); ...... above code converted delphi code leads error below; ****** delphi code ****** {$ifdef kkk_module_exports} const kkk_module_api = extern 'c' __declspec(dllexport); **//error** {$else} const kkk_module_api = extern 'c' __declspec(dllimport); **//error** {$endif} var kkk_creat: function: kkk_module_api int cdecl {$ifdef win32} stdcall {$endif}; ......... cause of error 'extern' not reserved syntex of delphi. don't know how replace delphi code , need help. that not c#, c++. th...

xml - content mathml to infix notation using ctop.xsl not getting as desired format -

i trying make math notation or infix expression content mathml, i making of ctop.xsl this: /***ctop.xsl**/ refer it can parsed expression follows: <html> <head> <script> function loadxmldoc(filename) { if (window.activexobject) { xhttp = new activexobject("msxml2.xmlhttp"); } else { xhttp = new xmlhttprequest(); } xhttp.open("get", filename, false); try {xhttp.responsetype = "msxml-document"} catch(err) {} // helping ie11 xhttp.send(""); return xhttp.responsexml; } function displayresult() { xml = loadxmldoc("contentmathml.xml"); xsl = loadxmldoc("ctop.xsl"); // code ie if (window.activexobject || xhttp.responsetype == "msxml-document") { ex = xml.transformnode(xsl); document.getelementbyid("example").innerhtml = ex; } // code chrome, firefox, opera, etc. else if (document.implementation && document.implementation.createdocument) { xsltproce...

ios - Auto layout doesn't work on iPhone 6 device but works on emulator -

Image
i have app uses auto layout constraints added in xcode designer , using "add missing constraints" option editor menu , problem screens looks on iphone 6 ios 8.3 emulator doesn't work on actual iphone 6 device ios 8 well. m not adding code below examples what missing auto layout ? **** additional details *** there principle need know.. every view add storyboard must have enough constraints confirm it's: width height x position y position you should review constrains added. first textfield(your full name). seems it's y position constrains wrong.

javascript - Custom formatting for a time using Moment.js -

i'm having difficulty formatting time using moment.js . decided try out angular-moment , faced limitations, , after looking @ documentation moment.js , seems lot better create custom directive uses moment . here lies problem, have experience , knowledge of basic directives, i'm not sure how move forward creating directive uses moment format date/time. so, here rules want adhere to: less 1 minute ago: print a few seconds ago more 1 minute ago && less 1 hour ago: print x minutes ago more 1 hour ago: print h:mm a yesterday (this should compare 2 days see if today or yesterday): print yesterday more yesterday: print mmm dd so i'm unsure start really, , welcome! moment.js way go! recommend use angular filter instead of directive. here how might implement 1 moment.js fromnow function : var fromnow = function () { return function (value, format) { return moment(value).fromnow(); }; }; angular.module('myap...

sql - edit php doesn't work it doesn't update data -

my php doesn't update data. here code: <html> <body> <meta charset="utf-8"> <title>სატელეფონო ცნობარი</title> <?php include('connection.php'); if(isset($_get['id'])) { $id=$_get['id']; if(isset($_post['submit'])) { $tarigi=$_post['addedon']; $teleponi2=$_post['tel2']; $teleponi3=$_post['tel3']; $departamenti2=$_post['department2']; $departamenti3=$_post['department3']; $web=$_post ['url']; $email=$_post['email']; $address=$_post['address']; $comment=$_post['comment']; $query3=mysql_query("update phonebook set addedon='$tarigi', tel2='$teleponi2',tel3='$teleponi3', department2='$departamenti2' , department3='$departamenti3' url='$web...

java - Inject Singleton Session Bean into a Stateless Session Bean -

is allowed (and practice) hold shared informations in our application using singleton session bean inside stateless session bean? the ssb injected slsb. @stateless public class myslsb { @inject myssb myssb; - @singleton @lock(read) public class myssb implements serializable { private static final long serialversionuid = 1l; it more allowed. using singleton injections in stateless or statefull ejbs allow call business methods on ssb in slsb. 1 of trivial advantages using ssb concurrent capabilities. in example of method calls toward ssb locked on read , means threads accessing ssb methods on read mode unless thread holding lock on write.

How to append data one by one in existing file in android? -

how append data 1 one in existing file? using following code.. append data row order in file..how solve this? private string savetext() { file sdcard = environment.getexternalstoragedirectory(); file dir = new file (sdcard.getabsolutepath()+file.separator+"gps"); dir.mkdirs(); string fname = "gps.txt"; file file = new file (dir, fname); fileoutputstream fos; try { fos = new fileoutputstream(file,true); outputstreamwriter out=new outputstreamwriter(fos); out.write(value1); out.close(); fos.close(); toast.maketext(getapplicationcontext(), "saved lat,long", toast.length_short).show(); } catch (exception e) { e.printstacktrace(); } return dir.getabsolutepath(); } try code try{ outputstreamwriter writer = new outputstreamwriter(new fileoutputstream(file,true), "utf-8"); bufferedwriter fbw = new bufferedwriter(...

Solr range query in text field -

i have multi valued field. content looks way multi_field:"type:type1; year:2008" i want able make range requests based on year substring. cannot understand if can perform kind of range queries. want have this. q=multi_field:"type:type1;*" , multi_field:"*years:[2005 2010]*" is possible? know looks horrible. there way can it? no, not possible (at least without hell-a-lot of coding). easiest way should fix indexing code split field 2 separate fields. if need keep original multi_field available (e.g. used in processing search results), create 2 new fields (e.g. multi_field_part1 , multi_field_part2 ), search on new fields ( q=multi_field_part1:type1 , multi_field_part2:[2005 2010] ), use old 1 in results.

memory management - Deallocate sprites properly -

what proper steps deallocate played sprite? remove object stage call stop() method on sprite set sprite variable null is ok if remove stage , don't stop it? the sprite instance receives tick display list, don't need stop prior removing it. ensure available garbage collection, remove display list , ensure null references may have created it.

node.js - Fetching fields which have values as array in mongodb -

my collection looks this {a:"foo", b:[10,20,30]} {a:"boo", b:[15,25,35]} {a:"abc", b:[10,40,50]} {a:"xyz", b:[10,60,70]} now, want retrieve entire array under a:"foo". how do this? db.collection.find({"a":"foo"}) will return object matching criteria , can access "b" element of results

git - Why am I unable to create/checkout this branch? -

i trying create local git branch, not working. here commands using: tablet:edit11$ git checkout -b edit_11 switched new branch 'edit_11' tablet:edit11$ git checkout edit_11 error: pathspec 'edit_11' did not match file(s) known git. tablet:edit11$ git branch tablet:edit11$ what's going on? you created , "switched to" branch called edit_11 when ran git checkout -b edit_11 however, (incl. empty git branch output) indicates have initialised repository , have yet made make initial commit. if there no commit, branches have nothing useful point @ , there nothing check out. therefore, when run git checkout edit_11 you following error, error: pathspec 'edit_11' did not match file(s) known git. even though branch edit_11 exists. the problem can reproduced follows: $ mkdir testgit $ cd testgit $ git init initialized empty git repository in /xxxx/testgit/.git/ $ git checkout -b edit_11 switched new branch 'edit_11...

sql - How to find table names which have a same value in other tables based aone column -

i have database many tables , table has common column. how can retrieve table have same value in column? ex:- have 25 table, tables have column name ccode want know tables have same value column? the following statement create union select brings data need in 1 result set. best set query output text , don't forget set query option max text highest (8192). take result of select new sql window , execute it: alltableswithmycolumn ( select distinct table_name information_schema.columns column_name='ccode' ) select stuff( ( select 'union select ''' + table_name + ''' tablename, ccode ' + table_name + char(13) + char(10) alltableswithmycolumn xml path(''),type ).value('.','varchar(max)'),1,6,'') if need further help, tell me...

java - custom-sql when I only imported the service (Liferay) -

hey guys liferay question, i using service builder communicate database. thing using same tables 2 of portlets, imported jar created in 1 of portlets other one,, need create custom sql on both of them.. how create finderimpl class? don't have persistence folder on other portlet because service.jar imported.. doing right? should this? thanks if second project not contain custom entity create dummy entity of service builder service builder create service structure i.e dummy localserviceimpl, serviceimpl you. to create dummy entity, don't mention column in entity element of service.xml <service-builder package-path="com.custom"> <author>yourname</author> <namespace>mycustom</namespace> <entity name="mydummyentity" local-service="true" remote-service="true" > </entity> <service-builder> so create com.custom.service..... packages. now create com.custom.s...

jquery - Inserting data using dynamic textbox -

i got problem inserting data mysql. error message: notice: undefined index: total0, here's php code if(isset($_post['submit'])){ $numquery = $_post['transaction']; $itemtotz = ""; ($xquery = 0; $xquery < $numquery; $xquery++) { $valpo_number = $_post['inpo_number']; $valpo_date = $_post['inpo_date']; $valitem = $xquery+1; $valquantity = $_post['quantity'.$xquery.'']; $valunit_price = $_post['unitprice'.$xquery.'']; $valtotal = $_post['total'.$xquery.'']; $valaprove_by = $_post['inaprove_by']; $valprepared_by = $_post['inprepared_by']; $valgrandtotal = $_post['grandtotal']; if ($xquery == 0){ $itemtotz .= $valitem; $valquantitytotz = $valquantity; $valunit_pricetotz = $valunit_price; $valtotaltotz = $valtotal;} else { $itemtotz .= "|".$valitem; ...

mongodb - Aggregate with count of sub documents matching the condition and grouping -

i've collections of documents below: { "_id" : objectid("55d4410544c96d6f6578f893"), "executionproject" : "project1", "suitelist" : [ { "suitestatus" : "pass" } ], "runendtime" : isodate("2015-08-19t08:40:47.049z"), "runstarttime" : isodate("2015-08-19t08:40:37.621z"), "runstatus" : "pass", "__v" : 1 } { "_id" : objectid("55d44eb4c0422e7b8bffe76b"), "executionproject" : "project1", "suitelist" : [ { "suitestatus" : "pass" } ], "runendtime" : isodate("2015-08-19t09:39:13.528z"), "runstarttime" : isodate("2015-08-19t09:39:00.406z"), "runstatus" : "pass", "__v" : 1 } { "_id...

CSS: How to get position and size relative to screen width? -

i have problem relative positioning, in following html code: <ion-view class="menu-content" view-title="postkarte"> <ion-content> <div class="postcard"> </div> </ion-content> </ion-view> and current css: .postcard { display: block; position: relative; margin-left: auto; margin-right: auto; background-position: center center; background-image: url("../img/frames/postcard_00.png"); background-size: contain; background-repeat: no-repeat; width: 354px; height: 250px; } as can see defined width , height absolute (354 , 250px). tried set width 90% made div small. guess 5 x 5 px. want @ 90% of width of device. since im developing app mobile devices need check in css if orientation landscape or protrait because if portrait need width 90% of devices screen width , if landscape need height 90% of devices height. how can that? you can ...

content management system - Django 1.8 + CMS error: django.db.utils.ProgrammingError: relation "cms_cmsplugin" does not exist -

i got same error 3 times already, before didn't find solution in google nor here, , guess i'm not 1 got it. from fresh installation, install @ same time django-cms plugin many of plugins. after running python manage.py makemigrations python manage.py migrate i error: django.db.utils.programmingerror: relation "cms_cmsplugin" not exist well, remove cms plugins except 'cms' itself, run python manage.py migrate add again plugins , alter, again, python manage.py migrate it seems django tries create tables plugins before 'cms' app's one as see it's not big deal if know it. usually people install them 1 one, if pip requirements.txt or similar, face this.

swift - Cannot assign a value of type '[UIImage?]' to a value of type '[AnyObject]?' -

this code please help, i'm following tutorial can't figure out whats wrong. please help. i'm trying create slideshow in swift var logoimages: [uiimage] = [] logoimages.append(uiimage(named: "logo.png")!) imageview.animationimages = [ uiimage(named: "jade2.jpg"), uiimage(named: "jade1.jpg"), uiimage(named: "jade14.png") ] imageview.animationduration = 5 imageview.startanimating() i thankful help. your images optional in animationimages add ! after every images , work fine. and code be: imageview.animationimages = [uiimage(named: "jade2.jpg")!, uiimage(named: "jade1.jpg")!, uiimage(named: "jade14.png")! ]

Remove duplicates from a Spark JavaPairDStream / JavaDStream -

i'm building spark streaming application receives data via sockettextstream. problem is, sended data has duplicates. remove them on spark-side (without pre-filtering on sender side). can use javapairrdd's distinct function via dstream's foreach (i can't find way how that)??? need "filtered" java(pair)dstream later actions... thank you! the .transform() method can used arbitrary operations on each time slice of rdds. assuming data strings: somedstream.transform(new function<javardd<string>, javardd<string>>() { @override public javardd<string> call(javardd<string> rows) throws exception { return rows.distinct(); } });

reflection - Convert reflect.value to reflect.method -

i have fallowing: func newmethoddescriptor(typ interface{}) *methoddescriptor { reflectedmethod := reflect.valueof(typ) methodtype := reflectedmethod.type paramcount := methodtype.numin() - 1 ... but when try: newmethoddescriptor(func(){}) i compile time error: methodtype.numin undefined (type func() reflect.type has no field or method numin)

How can i make my html control organized by bootstrap -

Image
i try make html page beautifies .my codes below : <div class="row" ng-if="model.fieldtype == customtypes.select"> <div class="form-group"> <label class="control-label col-md-4">seçim</label> <div class="col-md-5"> <input type="text" class="form-control" ng-model="model.newcomboitemforselect" /> </div> <div class="col-md-5"> <button type="button" class="btn btn-success" ng-click="addtodropdownlist()">+</button> </div> <div class="col-md-5"> <select class="form...

node.js - Criteria permission with sails-permissions -

i have created permission assigned criteria results in 404 not found , suggesting there no permitted records. can see output of log criteria { group: 1 } , there 1 record group = 1 1 record should returned yet can see permitted.lenth equal 0 . familiar sails-permissions able advise on whether correct? log output silly: permissionpolicy: 1 permissions grant read on issue johnsmith info: responsepolicy silly: data [ { items: [ { owner: 1, group: 1, id: 1, title: 'an important issue', open: true, createdat: '2015-08-24t18:17:32.580z', updatedat: '2015-08-24t18:17:32.586z' }, { owner: 3, group: 2, id: 2, title: 'an issue belonging group', open: true, createdat: '2015-08-24t18:17:32.582z', updatedat: '2015-08-24t18:17:32.582z' } ], _pagination: { current: 1, limit: 30, items: 2, pages: 1 } } ]...

node.js - Counting nested arrays with mongoose -

i'm using mongodb through mongoose in node.js application. in db have general format: books: bookschema = { variousdata, //books contain pages pages: [{type: pageschema}] } pages: pageschema = { variousdata, //pages contain frames frames: [frameschema] } frames: frameschema = { variousdata } i want write count query count total number of frames in pages in books. so if have content in db: book1 = { data:data, pages: [ {data:data, frames: [frame1,frame2,frame3] }, {data:data, frames: [frame1,frame2,frame3] }, {data:data, frames: [frame1,frame2,frame3] } ] } and book2 = { data:data, pages: [ {data:data, frames: [frame1,frame2] }, {data:data, frames: [frame1,frame2] }, {data:data, frames: [frame1,...

MAVEN : Run Multiple Maven Project using Maven Test -

i have 3 maven projects. project1, project2 & project3. project3 depends on project1 & project2 , project2 depends on project1. for have added in project2 pom.xml file <modelversion>4.0.0</modelversion> <groupid>project2</groupid> <artifactid>project2</artifactid> <version>0.0.1-snapshot</version> <dependencies> <dependency> <groupid>project1</groupid> <artifactid>project1</artifactid> <version>0.0.1-snapshot</version> </dependency> </dependencies> my pom.xml project3 - <modelversion>4.0.0</modelversion> <groupid>project3</groupid> <artifactid>project3</artifactid> <version>0.0.1-snapshot</version> <dependencies> <dependency> <groupid>project1</groupid> <artifactid>project1</artifact...

c - Is this code undefined behaviour? -

i have variable i: int i; if(b){ i=1; } else{ i=-1; } is i undefined behavior because of int i; exists? or should int i=0 first? absolutely fine. you initialising i on program control paths, , not reading value until initialisation complete. i prefer using ternary operator in such instances. int = b ? 1 : -1; as that's less vulnerable accidental reference uninitialised i .

php - Sort array based on the numbers and a certain piece of text that occurs within a string -

i have array got directory pdf files in using scandir $array = array(7) { [0]=> string(17) "q150824-spost.pdf" [1]=> string(17) "s150826-spost.pdf" [2]=> string(16) "s150826-spro.pdf" [3]=> string(17) "t150827-spost.pdf" [4]=> string(16) "t150827-spro.pdf" [5]=> string(17) "v150825-spost.pdf" [6]=> string(16) "v150825-spro.pdf" } i need sort array numbers in file name (eg. 150824 date) can using following: usort($array, function($a, $b) { return filter_var($a, filter_sanitize_number_int) - filter_var($b, filter_sanitize_number_int); }); the above gives me array sorted numbers (which want): $array = array(7) { [0]=> string(17) "q150824-spost.pdf" [1]=> string(17) "v150825-spost.pdf" [2]=> string(16) "v150825-spro.pdf" [3]=> string(16) "s150826-spro.pdf" [4]=> string(...

java - ajax POST + spring controller parameter passing error -

i have strange problem passing int param in post request spring mvc controller. the thing parameter passed through post, didn't parsed controller. here code: spring controller: @controller @requestmapping("user") public class usercontroller { @requestmapping(value = "/register", method = requestmethod.post) @responsebody public jsonresponse adduser(@requestbody user user){ system.out.println(user.getcondoid()); system.out.println(user.getpassword()); system.out.println(user.getusername()); *** stuff *** } user model: public class user { private string username; private string password; private int condo_id; private list<string> roles; public list<string> getroles() { return roles; } public void setroles(list<string> roles) { this.roles = roles; } public string getusername() { return username; } public void setusername...

sql server - SQL FOR XML Path, returning multiple child elements -

i require data returned table in following format. <root> <property name="test1">text1</property> <property name="test2">text2</property> <property name="test3">text3</property> <property name="test4">text4</property> </root> i've tried code other post sql server xml path add attributes , values , can work single line not multiple. eg. select 'test1' [@name], 'text1' xml path('property'), root('root') works giving <root> <property name="test1">text1</property> </root> but select 'test1' [@name], 'text1' ,'test2' [@name], 'text2' ,'test3' [@name], 'text3' ,'test4' [@name], 'text4' xml path('property'), root('root') fails with attribute-centric column '@name' must not co...

ios - didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios8 -

i know question asked , have solution it,i tried solution available ,but nothing working me. code working on side when submit app store reject (till got 3 rejections app store). i try the code following link:- why didregisterforremotenotificationswithdevicetoken not called get device token in ios 8 https://developer.apple.com/library/ios/technotes/tn2265/_index.html i check provisional profile , certificates fine. anyone please help push notification registration process has been changed in ios 8, make sure have added this if ([[[uidevice currentdevice] systemversion] floatvalue] >= 8.0) { [[uiapplication sharedapplication] registerusernotificationsettings:[uiusernotificationsettings settingsfortypes:(uiusernotificationtypesound | uiusernotificationtypealert | uiusernotificationtypebadge) categories:nil]]; [[uiapplication sharedapplication] registerforremotenotifications]; }

java - Difference between Spark toLocalIterator and iterator methods -

while coding spark programs came across tolocaliterator() method. earlier using iterator() method. if has ever used method please throw lights. i came across while using foreach , foreachpartition methods in spark program. can pass foreach method result tolocaliterator method or vice verse. tolocaliterator() -> foreachpartition() iterator() -> foreach() first of all, iterator method rdd should not called. can read in [javadocs]( https://spark.apache.org/docs/1.0.2/api/java/org/apache/spark/rdd/rdd.html#iterator(org.apache.spark.partition , org.apache.spark.taskcontext)): this should ''not'' called users directly, available implementors of custom subclasses of rdd. as tolocaliterator , used collect data rdd scattered around cluster 1 node, 1 program running, , data in same node. similar collect method, instead of returning list return iterator . foreach used apply function each of elements of rdd, while foreachpartition apply fun...

java - getOutputStream() has already been called for this response error -

exception : org.apache.jasper.jasperexception: java.lang.illegalstateexception: getoutputstream() has been called response org.apache.jasper.servlet.jspservletwrapper.handlejspexception(jspservletwrapper.java:584) org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:466) org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:389) org.apache.jasper.servlet.jspservlet.service(jspservlet.java:333) javax.servlet.http.httpservlet.service(httpservlet.java:722) org.netbeans.modules.web.monitor.server.monitorfilter.dofilter(monitorfilter.java:393) root cause : java.lang.illegalstateexception: getoutputstream() has been called response org.apache.catalina.connector.response.getwriter(response.java:627) org.apache.catalina.connector.responsefacade.getwriter(responsefacade.java:215) javax.servlet.servletresponsewrapper.getwriter(servletresponsewrapper.java:105) org.apache.jasper.runtime.jspwriterimpl.initout(jspwriterimpl.java:125) org.apache.jasper.ru...