Posts

Showing posts from June, 2012

Lucene search result -

i have below data index in lucene 4.8 , code. finance expense admin expenses transaction expense salary expenses indexing: try { writer = createwriter(ramdirectory); for(string line : readfile(file_path)) { string[] split = line.split(","); document doc = new document(); doc.add(new textfield("id", split[0].trim(), field.store.yes)); doc.add(new textfield("name", split[1].trim(), field.store.yes)); writer.adddocument(doc); } writer.commit(); } { if(writer != null) { writer.close(); } } search indexsearcher searcher = new indexsearcher(directoryreader.open(ramdirectory)); queryparser nameqparser = new queryparser(version.lucene_48, "name", new standardanalyzer(version.lucene_48)); query query = nameqparser.parse("expense"); topdocs queryresults = searcher.search(query, 10); above c

javascript - onInit, onAfterRendering not being called when returning back to the page -

i have developed 2 views view1.xml , view2.xml in both implemented oninit() , onafterrendering() . implemented button use router.navto() method. when come view2 view1, view1's oninit/onafterrendering not called. same happens if press browser's button. please help! oninit , called once, that's how defined! furthermore, instead of relying on onafterrendering should listen matched events of routes, see navigation , routing tutorial of sdk! never know when view gets rerendered, make sure understand when makes sense it, i.e. modify dom after rerendering has happened or if need register third party libs somewhere in dom...

Definition of conversation in botframework -

i bit confused on definition of "conversationid". can explain conversation exactly? use case needs state group conversation, long bot group, want maintain state. i want know how differentiate group conversation vs conversation 1 user. the message types documentation explains messages begin , end conversation users , bots. page indicates messages channel specific, meaning channels send conversation message , others might not. so, once choose channels, you'll need experiment or read channel specific documentation see if send messages start , end conversation. prepare, bot framework emulator has drop-down list send button can test how code handles these messages.

Python for loop control variable accessed before declaration -

this question has answer here: python for-in loop preceded variable 4 answers i'm new python, , i'm trying understand following line: "".join(char char in input if not unicodedata.category(char).startswith('p')) source: https://stackoverflow.com/a/11066443/3818487 this code removes unicode punctuation input. don't understand why works. far can tell, iterates on characters in input ignoring punctuation characters. how can access char before declared in loop? come java background, confusing me. this comprehension more following, in regular code (using list store our non-punctuation characters). #input defined somewhere prior loop output = [] char in input: if not unicodedata.category(char).startswith('p'): output.append(char) ''.join(output) comprehensions iterate on loop portion first, va

python - Python3: What this "%" means in this code? -

this question has answer here: what significance of % in python [closed] 5 answers i'm study python 3, , % in code, see below: def main(): maxwidth = 100 # limita o numero de caracteres numa célula print_start() # chama função print_start count = 0 # cria uma variavel cont while true: try: line = input() if count == 0: color = "lightgreen" elif count % 2: color = "white" else: color = "lightyellow" print_line(line, color, maxwidth) count += 1 except eoferror: break print_end() # chama função print_end what elif count % 2: line means? this called modulo or modulus operator . it divides "left" value "right" value , returns remainder (the amount left on after division). it's commonl

c# - Operator To Return if one and ONLY One Argument is True -

i'm making if statement in c# return true if 1 of parameters true. i'll use || in example because that's closest thing can think of: int = 1; int b = 2; int c = 3; if(a == 1 || b == 2) { console.log("the first statement true") } if(a == 1 || b == 3) { console.log("the second statement true") } if(a == 0 || b == 0 || c == 3) { console.log("the third statement true") } if(a == 1 || b == 0 || c == 3) { console.log("the fourth statement true") } //output: //the second statement true //the third statement true again, think of || operator i'm looking for. such operator exist, or should define own boolean function? for 2 expressions, can use xor: if (a == 1 ^ b == 0) for more two, like: if (new[] { == 1, b == 0, c == 2 }.count(x => x) == 1) that counts "true" elements of array constructed expressions, , checks count 1. admittedly evaluate conditions first, , count of them if first 2 true (so

can python and php access same mysqldb? -

is possible access same mysql database using python , php.beacause developing video searching website based on semantics. purposely have use python , javaee. have make datbase store video data. should accessed through both python , javaee, can use php interfacing between javaee mysql database. problem python can access same database.? i new here , developing. appreciate kindness. think can best solution it's database. doesn't care language or application you're using access it. that's 1 of benefits of having standards mysql protocol, sql in general, or things tcp/ip: allow different systems seamlessly inter-operate.

php - echo variable and select it -

i'm trying echo variable search box placeholder , value search box search on google maps. the variable $address $address = $_session['mylocation']['address']; and in html i've form <input name="custom[map_location]" id="form_map_location" class="controls" type="text" placeholder="<?php echo $address ?>" value="<?php echo $address ?>"> the variable echos fine, choose value echoed , change location echod value i've click inside text form box , click away, detects location, need automatically without clicking inside form i've added chunk of code loads map http://pastebin.com/xmzixwiw are passing variable in input javascript function via on change event? if you may need create 2 listeners 1. "change event" capture new values put in input field 2. "document ready event" grab value passing via php , use when building map. n

excel - vba looking for a fast way to highlight every other row -

so far have , it's slow big data sets. 'for every row in current selection... counter = 1 rng.rows.count 'reccnt 'if row odd number (within selection)... if counter mod 2 = 1 rng.rows(counter).interior .pattern = xlsolid .patterncolorindex = xlautomatic .themecolor = xlthemecoloraccent6 .tintandshade = 0.799981688894314 .patterntintandshade = 0 end end if next give try. imagine speed things bit. runs me instantly. sub coloreven() set rng = rows("1:40000") rng.formatconditions.add type:=xlexpression, formula1:="=mod(row(),2)=0" rng.formatconditions(1).interior.pattern = xlsolid rng.formatconditions(1).interior.patterncolorindex = xlautomatic rng.formatconditions(1).interior.themecolor = xlthemecoloraccent6 rng.formatconditions(1).interior.tintandshade = 0.799981688894314 rng.formatconditions(1).interi

ios - HealthKit - Does Source Queries return an App when user Did Not Allowed access or turned all Categories Off? -

i check if our users have app installed. if do: i want know if have allowed access healthkit (if possible know allowed categories) so, what source query returns if app has been allowed or denied access? if app not installed? you cannot determine healthkit authorization status of other apps installed on user's phone. hksourcequery returns sources of apps have saved samples matching given predicate, regardless of authorization status or whether app installed.

css - How to target firefox or any other browser in SCSS? -

what trying do? glyphicon not behaving in firefox. misaligned. looks great in chrome , safari alignment. solve this, trying write rule apply if mozilla browser. is there way detect browser in scss using directives @if. following: @if $browser == mozilla { //apply css .pull-right.glyphicon.glyphicon-chevron-right { top: -13px; line-height: 0.5 !important; } do have simple way detect? asking because, tried using @moz-document url-prefix() isn't working in scss. i have seen question asked here there no correct solution problem. any or guidance appreciated. thank you.

swift - How can I figure out the day difference in the following example -

i calculating day difference between 2 dates, figured out the following code giving me difference 24 hours rather difference in date. have following code: func daysbetweendate(startdate: nsdate, enddate: nsdate) -> int { let calendar = nscalendar.currentcalendar() let components = calendar.components([.day], fromdate:startdate, todate: enddate, options: []) return components.day } so, following example result: lastlaunch:2016-06-10 01:39:07 +0000 toady: 2016-06-11 00:41:41 +0000 daydiff:0 i have expected day difference one, since last launch on 10th , today 11th. how can change code give me actual difference in date days? you can use calendar method date bysettinghour noon time startdate , enddate, make calendar calculations not time sensitive: xcode 8.2.1 • swift 3.0.2 extension date { var noon: date? { return calendar.autoupdatingcurrent.date(bysettinghour: 12, minute: 0, second: 0, of: self) } func daysbetween(_ date:

c++ - QT, socket.io and boost integration undefined references errors -

Image
i'm new boost , starter qt, i'm unaware how packaging system works in qt, boost , cpp well. i'm trying integrate socket.io using boost in qt following this tutorial. i'm trying without cmake because looked more understandable me. errors , warnings i'm receiving in picture: all i've done far this: -downloaded , unpacked boost -commands history: 254 ./bootstrap.sh 255 ./b2 --help 256 ./b2 257 ./bjam install --prefix="./" --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi 258 git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git -copied content of src folder in github repo project under folder name siosrc -updated pro file , content: template = app qt += qml quick widgets config += c++11 sources += main.cpp \ siosrc/sio_client.cpp \ siosrc/sio_socket.cpp \ siosrc/internal/sio_client_impl.cpp \ siosrc/intern

c++ - What's could class "Oscar" possibly be doing there? -

in line? std::unique_ptr<lucille<oscar>> mbuster; if it's either 1 of lucille or oscar have no problem understanding it's creating empty pointer either class types. there two. what's going on? this declares std::unique_ptr instance of template class lucille , oscar template parameter.

jquery - Disable time outside minTime and maxTime range -

Image
i tried link 2 jquery-ui timepicker. var time = new date(); $('#from').timepicker({ onclose: function(datetext, inst) { var startdatetextbox = $('#to'); if (startdatetextbox.val() != '') { var teststartdate = new date(startdatetextbox.val()); var testenddate = new date(datetext); if (teststartdate > testenddate) startdatetextbox.val(datetext); } else { startdatetextbox.val(datetext); } }, onselect: function(datetext){ var time = new date($(this).datetimepicker('gettime').gettime()); $('#to').timepicker('option', 'mintime',time); } }); $('#to').timepicker({ onclose: function(datetext, inst) { var startdatetextbox = $('#from'); if (startdatetextbox.val() != '') { var teststartdate = new date(startdatetextbox.val()); var t

jquery - Adding classes to subchildren with addClass -

i trying add class 'animated fadeindown" subchildren of h1, letters individually fade in top instead of doing @ once. reason cannot type these classes in hand because using lettering.js, breaks "lorem ips" constituents when doc loads. <h1 id = "letters"> <span class="char1">l</span> <span class="char2">o</span> <span class="char3">r</span> <span class="char4">e</span> <span class="char5">m</span> <span class="char6"> </span> <span class="char7">i</span> <span class="char8">p</span> <span class="char9">s</span> </h1> my jquery: $(document).ready(function() { $("#letters").children().addclass('animated fadeindown'); }); in fact, ideally, first 5 have class applied rather on of them. $(docume

RxJs: How to emit events at predefined times? -

i have pre-defined events set occur @ specific times. , have timer, this: const timer = rx.observable.interval(100).timeinterval() .map(x => x.interval) .scan((ms, total) => total + ms, 0) the timer emits close 100,200,300,400,500 (although in reality it's more 101,200,302,401,500...which totally fine) have stuff want @ times. example, let's want stuff @ following times: const stuff = rx.observable.from([1000, 2000, 2250, 3000, 5000]); what i'd combine "stuff" , "timer" in such way resulting stream emits value once per time defined in "stuff" @ time (or ever later). in case, t=1000 ms, 2000 ms, 2250 ms, 3000 ms , 5000 ms. note: 2250 guy should emit around time 2300 because of interval size. that's fine. can't come or more once. i have 1 solution, it's not good. re-starts "stuff" every single step (every single 100 ms in case) , filters , takes 1. prefer that, once event emitted "stuff"

java - Converting List<Object> to String returns empty results -

disclaimer : i'm using this post , reference list<object> list<string> , this post java list<string> of strings javascript array. i've list<seat> , want values of in comma separated string , tried in way import java.util.*; import java.lang.*; class rextester { public rextester(){ seat seat1 = new seat(); seat1.setseatnumber(1); seat seat2 = new seat(); seat2.setseatnumber(2); seat seat3 = new seat(); seat3.setseatnumber(3); list<seat> seatlist = new arraylist<seat>(); seatlist.add(seat1); seatlist.add(seat2); seatlist.add(seat3); utility util = new utility(); string stringseats = util.tojavascriptarray(seatlist); system.out.println("javascriptarray " + stringseats); } public static void main(string args[]) { new rextester(); } private class seat { private int

matlab - A table with 2 columns where one column increases sequentially while the other column displaying the same number till a limit is reached -

i have been trying write code users enters 2 numbers in order 2 columns. hard explain words trying achieve here example: if user inputs a = 1 , b = 1 , following table should created: ans = 1 1 if user inputs a = 2 , b = 2 : ans = 1 1 1 2 2 1 2 2 if user inputs a = 2 , b = 5 : ans = 1 1 1 2 1 3 1 4 1 5 2 1 2 2 2 3 2 4 2 5 for other values of a , b , matrix should constructed according above shown sequence. this can achieved straight-forward use of repelem , repmat : [repelem((1:a).',b),repmat((1:b).',a,1)] a more elegant way using meshgrid , reshape after: [a,b] = meshgrid(1:a,1:b); [a(:),b(:)] let's create anonymous function , test first approach: >> fun = @(a,b) [repelem((1:a).',b),repmat((1:b).',a,1)]; >> fun(1,1) ans = 1 1 >> fun(2,2) ans = 1 1 1 2 2 1 2 2 >> fun(2,5) ans = 1 1 1

amazon web services - How to point AWS Route 53 to wordpress.com blog? -

i have website serve out of aws. domain name www.my-website-blah.com. now, created wordpress blog: my-website-blah.wordpress.com. i want blog appear @ blog.my-website-blah.com. how do it? i believe it, have setup ns record in route53. however, i'm not sure fqdns point them to. can information? in domain name registry contains domain (eg example.com ), create cname record point blog.example.com xyz.wordpress.com . if domain name registered in route 53, create cname resource record set using amazon route 53 console . if domain name registered somewhere else (eg godaddy), create cname record there.

Create process by system with delphi -

how create process system nt authority account in delphi ? there api such createprocessasuser function. you need create service installed & starts @ run time itself. on service execute procedure call createprocessasuserw token of winlogon.exe process. notes if want new proccess runs in same caller session call wtsqueryusertoken wtsgetactiveconsolesessionid current active user token call createenvironmentblock token, , assinge received pointer on createprocessasuserw . set random name & displayname (such created time) service. if want run multiple system process same serevice. here use usysaccount.pas unit usysaccount; interface uses winsvc, svcmgr, winapi.windows, system.sysutils, tlhelp32, system.classes; type tssysaccount = class(tservice) procedure serviceexecute(sender: tservice); private lpapplicationname, lpcommandline, lpcurrentdirectory: pwidechar; public function getserv

php - Image not moving to proper folder zend framework2 -

i started working on zend framework image upload.the code not showing errors image not moving proper destination. public function uploadaction() { error_reporting(e_all); ini_set('display_errors', 1); $form = new uploadform(); $form->get('submit')->setvalue('add'); $request = $this->getrequest(); if ($request->ispost()) { $profile = new upload(); $form->setinputfilter($profile->getinputfilter()); $nonfile = $request->getpost()->toarray(); $file = $this->params()->fromfiles('fileupload'); $data = array_merge_recursive($request->getpost()->toarray(), $request->getfiles()->toarray()); //print_r($data);die; //set data post , file ... $form->setdata($data); if ($form->isvalid()) { $favicon = $data['fi

How to insert multiple jquery on created rows values into database using php and mysql? -

here html code : <tr> <td><input class="case" type="checkbox"/></td> <td><input type="text" data-type="productcode" name="itemno[]" id="itemno_1" class="form-control autocomplete_txt" autocomplete="off"></td> <td><input type="text" data-type="productname" name="itemname[]" id="itemname_1" class="form-control autocomplete_txt" autocomplete="off"></td> <td><input type="number" name="price[]" id="price_1" class="form-control changesno" autocomplete="off" onkeypress="return isnumeric(event);" ondrop="return false;" onpaste="return false;"></td> <td&g

java - itext, pdf size A4, and image scalling -

Image
my paper b4 - 17,60cm x 24,50cm its scanned have size in pixels -> 2048 x 2929 im creating pdf a4 size (2480px x 3508px) using itext.. im unable scale margins, , not without margins, need insert b4 image pdf a4 size, using left margin of 2,5cm , righ margin 2cm, how can make fit calculating sizes, since paper a4 has 2480x3508, b4 image has 2048x2929, if insert, cut? b4 bigger :| how?? considering size of a4, , b4 should fit inside a4 if this: doc = new document(pagesize.a4, 0, 0, 0, 0); os = new fileoutputstream(arquivonomecompleto); pdfwriter.getinstance(doc, os); doc.open(); image img = image.getinstance(arraypath[i]); // array store path image // img.scaletofit(2090, 1208); // tried lot of modifications, can set 500x500 or in have showed in pdf, how can calculate margins doc.add(img); doc.add(new paragraph("test: text under b4 image"); doc.newpage(); still cutting if convert 17cm ,

fine-uploader handle custom data in response JSON -

hopefully simple issues, have missed in rtfm. i have application integrating fine uploader, , have working in terms of uploading files server. issue need take action on client side each time user uploads file. in short have hidden input field comma separated list of files have been been uploaded. in json response server side implementation. of course including "success: true". in addition have entry called "file: /path/to/savedupload.file". so when upload performed successfully, need know how call own method json response passed in can take care of managing hidden input element. thanks in advance assistance! dustin

php - Is there any solution to log if somebody get my website's pages with file_get_contents? -

for example data website file_get_contents, on local computer, upload data db , after upload db server? sorry bad english... thank replay! your web server should log requests whether came via file_get_contents or other way. can check logs see if there distinctive these requests (like ip coming or user agent string). once information downloaded, out of control of server , not able log if data uploaded db or other server.

java - How I can split file in Android Case The File Is Large To Upload It(Sound File) -

how can split file in android case file large upload it(sound file) use zip4j how can split when mack zip or way split upload code when zip private static void compress(string inputfile, string compressedfile) { try { zipfile zipfile = new zipfile(compressedfile); file inputfileh = new file(inputfile); //initiate zip parameters define various properties zipparameters parameters = new zipparameters(); // set compression method deflate compression parameters.setcompressionmethod(zip4jconstants.comp_deflate); //deflate_level_fastest - lowest compression level higher speed of compression //deflate_level_fast - low compression level higher speed of compression //deflate_level_normal - optimal balance between compression level/speed //deflate_level_maximum - high compression level compromise of speed //deflate_level_ultra - highest compression level low speed p

mysql - Vaadin upload image and store it to database -

i using vaadin upload component , far have managed upload image directory, , display in panel component after successfull uploaded. want after this, insert in database aswell. have table called show has name, date , image. in show class have tried have image byte array or blob. column(name="image") private byte[] image; @lob @column(name="image") private blob image; in upload succeded method want convert file byte array, , far have tried this: file file = new file("c:\\users\\cristina_pc\\desktop\\" + event.getfilename()); byte[] bfile = new byte[(int) file.length()]; try { fileinputstream fileinputstream = new fileinputstream(file); fileinputstream.read(bfile); uip.uploadimage(bfile); fileinputstream.close(); } catch (exception e) { e.printstacktrace(); } i tried this: byte[] data = files.readallbytes(new file("c:\\users\\cristina_pc\\desktop\\" + event.getfilename()).topath()); uip.uploadimage(data); uip upl

algorithm - Efficient way of generating "item-item distance rank matrix" in MATLAB? -

i have 1000-by-3 matrix x containing 1000 datapoints in 3d space. can generate item-item mahalanobis distance matrix in matlab: x = random(1000, 3); distmat = pdist(x, 'mahalanobis'); distmat = squareform(distmat); where ( i , j )-th entry distance between point i , point j . now wish have similar matrix ( i , j )-th entry rank of point i among points based on distance point j . call "item-item distance rank matrix." my idea sort each row of distmat , construct desired matrix sorting indices, requires 1000 sorting operations. believe there's more efficient way.

sql - Using CROSS JOIN -

i learning how use cross joins , can't see doing wrong 1 attempting. what have pattern , numbers table. number table: numberid tinyint pattern table: patternid tinyint identity(1,1) patternresult varchar(5) i have inserted each row in number table 1 - 22. at moment getting no results displayed. i want display patterns between numbers 0 - 5 (i can't include '0' in number table later on using table requires number beginning @ '1' 'number' table e.g 0 - 0 0 - 1 0 - 2 0 - 3 0 - 4 0 - 5 1 - 0 1 - 1 1 - 2 1 - 3 1 - 4 1 - 5 etc what doing incorrectly cross join? insert dbo.pattern(patternresult) select cast(n.numberid varchar (5)) + ' - ' + cast(nn.numberid varchar (5)) patternresult dbo.number n cross join dbo.number nn first, query insert . insert statements not return result sets. so, question is, return? select * dbo.pattern next, pattern has space 5 characters, using 3 ' - ' . so, try making pat

javascript - Change selectedColor dynamically in jqvamp -

i using jqvamp plugin , change selectedcolor property dynamically (by clicking on button ) can't figure out how. var your_variable = ""; // solution 1 // click $('#your_button').click(function(){ your_variable= target_color; // run initialization again test(); }); function test(){ set = $('#map').vectormap({ //...code selectedcolor: your_variable //...code }); } // solution 2 $('#your_button').click(function(){ $('#map').vectormap("set", "selectedcolor", your_variable); }); hope works

c++ - converting Roman numerals into decimal -

hey guys think i'm close i'm not sure how continue. of questions related problem don't answer anything. error i'm getting right an (33): error c2064: term not evaluate function taking 1 arguments (41): error c2064: term not evaluate function taking 1 arguments header file: using namespace std; class romantype { public: void printroman(char romannum); int printdecimal(int& total); int convertroman(int& total); void setroman(char& roman); romantype(); romantype(char); private: char romannum[6]; int decimal; int total; }; implementation: #include "stdafx.h" #include <iostream> #include <iomanip> #include "romantype.h" using namespace std; romantype::romantype(char) { }; void romantype::printroman(char romannum) { cout << "here number in roman numeral form: " << romannum << endl; }; int romantype::printdecimal(int& total) { cout <

angularjs - can't seem to display the content of ng-message for 'required' -

i don't know why can't seem display content of ng-message 'required'. i'm new this, please excuse if i'm missing obvious!! if try display {{studentform.fname.$error}} says blank. btw first question on stackoverflow :) edit : use form tag instead of md-form. seems md-form not valid tag. additionally md-auto-hide="false" might me required under ng-messages tag. see : https://github.com/angular/material/issues/6767 <div layout="row"> <div layout="column"> <md-form ng-model="student" name="studentform" flex="90%"> <div layout="column" layout-padding> <md-input-container class="md-block" flex> <label for="firstname">firstname</label> <input type="text" ng-model="student.firstname" name="fname" placeholder="firstname" required><

security of REST api - token invalidation -

i have rest api serves multiple customers. today, each customer gets own api key sent in headers of each request. api key encrypted string contains data customer, permissions etc. key decrypts api keys same customers, , stored in server. if customer leaves us, want able invalidate token, without invalidating tokens of rest of clients. creates problem. can, example, store each customer's token in customers table, each request api require me run query against customers table, may slow things down. possible store tokens in json file, may faster, don't know. think best solution? btw, i'm not interested in oauth.

java - Not able to create mysql datasource in Jboss 7.1.1 -

i using jboss 7.1.1 final release. trying add mysql driver server via admin console. able when go create datasources, not find driver listed there. followed steps add driver server mentioned in link : http://www.appeon.com/support/documents/appeon_online_help/1.5/server_configuration_guide_for_j2ee/ch03s03s03.html#d0e4128 i followed step 3 of installing jdbc driver via web console had created 1 management user.to summarize did, i added driver file e:\devsoftwares\servers\jboss\jboss-as-7.1.1.final\modules\com\mysql\main\meta-inf\services\java.sql.driver , content following : com.mysql.jdbc.jdbc2.optional.mysqlxadatasource (fully qualified driver class name). create module.xml file inside e:\devsoftwares\servers\jboss\jboss-as-7.1.1.final\modules\com\mysql\main\ , content below : added mysql-connector-java-5.0.8-bin.jar file inside e:\devsoftwares\servers\jboss\jboss-as-7.1

php - Modify article on the fly in Joomla -

i can change title placing next line template: $doc->settitle('my new title'); but method modify article's 'fulltext' in same way? short answer: yes, content plugin . details if can use $doc->settitle() , assume somewhere before line there's line says: $doc = jfactory::getdocument(); but document refers whole page , you're setting html <title> tag. if want change article text, you're dealing result of specific component, i.e. com_content , part of whole document. there more 1 ways change it. change whole page content if want change whole page content in template, have do: $buffer = $doc->getbuffer(); // ... whatever modification buffer $doc->setbuffer($buffer) quite simple do, it's not idea put kind of logic in template (if ever want change template, you'll have copy / paste code). use system plugin change buffer the core of solution same before, put logic in system plugin , hooking on

multithreading - reproducible random sequences for multithreaded C pthreads simulator -

i'm working on wa-tor simulator in c strict requirements , i'm little confused on how reproducible behaviour between calls same arguments. wa-tor 2d array of cells can contain water only, fish or shark. what have (i'll try list what's interesting understand problem): a configuration file, user can specify integer seed, among other options a master process, parse configuration file , spawns (fork+execve) many worker subprocess requested user. further collect status workers displaying single big grid. workers communicate master through unix socket file. many multithreaded (pthreads) worker process. workers connect master socket , receive simulation parameters, included seed specified user (at moment seed differentiated between workers adding worker id it. worker id progressive number master reproducibly assigns worker , included on command line on execve, worker can identify upon connection master's socket , each time assigned same grid section). wo

ios - How to draw a proper polylines on google maps -

Image
i have drawn polyline point point b, reason , shows linear line not correct waypoints here's code let path = gmsmutablepath() path.addlatitude(3.1970044, longitude:101.7389365) path.addlatitude(3.2058354, longitude:101.729536) let polyline = gmspolyline(path: path) polyline.strokewidth = 5.0 polyline.geodesic = true polyline.map = mapview i expecting doing waypoints, shows straight polylines self.googlemapsview google maps view. example : self.getdirections("26.9211992,75.8185761", destination: "26.8472496,75.7691909", waypoints: ["26.8686811,75.7568383"], travelmode: nil, completionhandler: nil) example: google direction link https://maps.googleapis.com/maps/api/directions/json?origin=26.9211992,75.8185761&destination=26.8472496,75.7691909&waypoints=optimize:true|26.8686811,75.7568383 let baseurlgeocode = "https://maps.googleapis.com/maps/api/geocode/json?"

ruby on rails - How to connect two tables by using ActiveRecord? -

Image
this question has answer here: why can't show restaurant list? 3 answers (sorry issue duplicated. now, deleted issue.) i'm trying ror active records association. , trying connect 2 tables, restaurants , restaurant_translations. these split multi-language support. here's definition of 2 tables. create_table "restaurant_translations", id: false, force: :cascade |t| t.integer "id", limit: 4, default: 0, null: false t.integer "restaurant_id", limit: 4 t.string "restaurantname", limit: 255 t.string "address", limit: 255 t.string "tel", limit: 255 t.text "description", limit: 65535 t.string "lang", limit: 255, default: "", null: false t.datetime "created_at", nu

c++ - 'GLEWContext does not name a type' error on ubuntu -

i trying port glew_mx project windows ubuntu errors because of glewcontext being undefined. error: ‘glewcontext’ not name type i know dont need glewcontext on linux nevertheless have define glewcontext* glewgetcontext(); in order compile project. created global glewcontext , return in glewgetcontext. window.h code looks this: #pragma once #define glew_mx #define glew_static #include "gl/glew.h" #include "glfw/glfw3.h" #define glm_swizzle #include "glm/glm.hpp" #include "glm/ext.hpp" #ifdef _win32 #define context_prefix window #else #define context_prefix #endif namespace window { class window { public: window() {} ~window() {} //... #ifdef _win32 static void makecontextcurrent(window* window_handle); #endif static window* createwindow(int win_width, int win_height, const std::string& title, glfwmonitor* monitor, window* share); glfwwindow* window; #ifdef _win

sql - Trigger isn't inserting the correct row -

i have trigger made alter trigger fuzzylogic on oehdrhst_sql insert begin declare @ordno char(8) declare @rownum int declare @id int select @ordno = ord_no inserted select @rownum = a.id banktransactions convert(char(8),a.ownreference) = (select ord_no inserted) select @id = a.id banktransactions join inserted on i.ord_no = a.invoicenumber a.invoicenumber = @ordno begin insert triggertest values(@ordno,@rownum,@id) update banktransactions set matchid = @rownum,supplierinvoicenumber = @ordno id = @id end end when inside triggertest after insert row see ordno , rownum keep getting nulls on id i ran sql statement test see if query wouldn't return did. select a.id banktransactions join oehdrhst_sql b on a.invoicenumber = b.ord_no why won't variable print? select @ordno = ord_no inserted this logic fundamentally flawed. if insert more 1 row, value expect assigned variable? arbitrary. triggers fire per statement, not per row. you need upda

mysql - Array to list/or other array in php -

i need sql queries php. here php code: $sql = "select * datab (`datestamp` between '$date' , '$date') , (`timestamp` between '08:00:01' , '20:00:00')"; $result = $conn->query($sql); while($list = mysqli_fetch_array($result)) { //echo "$list[0]</br>"; echo "$list[1]</br>"; //this column mysql corresponding temperatures //echo "$list[2]</br>"; //this column mysql corresponding other entries (humidity) //echo "$list[3]</br>"; // echo "$list[4]</br>"; // echo "$list[5]</br>"; //echo "$list[6]</br>"; // echo "$list[7]</br>"; } so, need access each temperature array or list element , don't know how it. think solution add each $list[1] element array inside while. basicaly want access element temp[2] (or smth that) second element printed $list[1]. can me? create array temperature: $te

Android / Java - Overriding -

i have 2 classes "baseactivity" , "childactivity" i.e. childactivity inherts baseactivity. question: in following code snippet, whenever press left button - logs me "i child activity". need if want call super class functionality default. public class baseactivity extends activity implements onclicklistener { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); }; protected void configuretitlebar(string title) { imagebutton imgleftbutton = ((imagebutton) findviewbyid(r.id.actionbarleftbutton)); imgleftbutton.setonclicklistener(baseactivity.this); } @override public void onclick(view v) { if(v.getid() == r.id.actionbarleftbutton){ printcustomlog("i base"); } } } child activity: public class childactivity extends baseactivity implements onclicklistener{ @override protected void oncreate(bundle savedinstancestate) {

symfony - Doctrine partial queries return the complete object -

i'm trying optimize query need simple list entity affiliated several entities. created query, should give me id , name: public function findallorderbyname() { $qb = $this->createquerybuilder('a'); $query = $qb->select(array('partial a.{id,name}')) ->addorderby('a.name', 'asc') ->getquery(); return $query->getresult(); } return in controller this: public function getinstrumentsaction() { $instruments = $this->getdoctrine()->getrepository('acmeinstrumentbundle:instrument')->findallorderbyname(); return array('instruments' => $instruments); } rather give me 2 camps, gives me complete object, including fields of other related entities. why did not work? it worked designed. observing lazy loading of of related entities. start adding: echo $query->getsql() . "\n"; return $query->getresult(); you see like