Posts

Showing posts from February, 2012

MongoDB: Editing Element In Array -

i wanting edit element might exist in multiple arrays in collection. public class class { [bsonid] public guid id { get; set;} public string name {get; set;} public list<student> students {get; set;} } public class student { [bsonid] public guid id {get; set;} public string name {get; set;} public string grade {get; set;} } then class collection like { "_id" : nuuid("..."), "name" : "computer science", "students" : [ { "_id" : nuuid("..."), "name" : "chris" "grade" : "a" }, { "_id" : nuuid("..."), "name" : "bob" "grade" : "b" } } and student collection like { "_id" : nuuid("..."), "name" : "chris eastwood" "grade": &qu

Correct way to call a singleton object in C++ -

i've build singleton class based on hit posted here . i've extended getmessage() function, retrive internal dictionary message - dictionary needs loaded once on whole application, reason of singleton. my code: singleton.hpp class singleton { public: static singleton& getinstance(); std::string getmessage(std::string code); private: singleton() {}; singleton(singleton const&) = delete; void operator=(singleton const&) = delete; }; singleton.cpp singleton& singleton::getinstance() { static singleton instance; return instance; } std::string singleton::getmessage(std::string code) { /// return "code example."; } and main code: main.cpp int main() { singleton* my_singleton; my_singleton = singleton::getinstance(); **<-- error here** cout << my_singleton->getmessage("a"); << endl } main giving me error: cannot convert 'singleton'

javascript - Fill Second input with the First input information -

i don't how can this.. example: i have 2 inputs , when fill first input time , second input add +2 hours . example: first input = 10:00 second input automatically put: 12:00 i'd use date object , add 2 hours, has advantage of making 23:00 become 01:00 etc. without hassle. then it's matter of adding event handler, getting value, creating date object, adding 2 hours, getting hours back, , putting value in other input var first = document.getelementbyid('first'); var second = document.getelementbyid('second'); first.addeventlistener('input', function() { if (this.value.indexof(':') != -1 && this.value.length === 5) { var date = new date(); var val = this.value.split(':'); date.sethours( parseint(val[0], 10) + 2); var hours = date.gethours(); hours = hours > 9 ? hours : '0' + hours; second.value = hours + ':' + val[1];

Silverlight MediaElement requires many H.264 frames to render one image -

i working on silverlight application implements custom mediastreamsource feeding mediaelement elementary h.264 nal units. stream starts off key frame, noticed on average takes 20 frames render 1 image. have gop size set 8 on h.264 encoder. video coming security camera , being viewed in live stream application. the main issue induces decent amount of latency between when events happen in real life , when image rendered. small latency expected, turns out 3 seconds receiving first frame until first image rendered. shouldn't first key frame theoretically contain enough information decode image? testing have sample silverlight application loads captured h.264 stream file , internally buffers entire file, way once mediastreamsource opens, consumes ~20 frames , renders image virtually no latency. any microsoft / silverlight / h.264 experts care elaborate on why might possibly happening?

php - Advertisement System Tips -

i creating advertisement system shows highest bidder's ads more frequently. here example of table structure using, simplified... +----+----------+------------------------+----------------------+-----+ | id | name | image | destination | bid | +----+----------+------------------------+----------------------+-----+ | 1 | abc, co | htt.../blah | htt...djkd.com/ | 3 | +----+----------+------------------------+----------------------+-----+ | 2 | facebook | htt.../blah | htt...djkd.com/ | 200 | +----+----------+------------------------+----------------------+-----+ | 3 | google | htt.../blah | htt...djkd.com/ | 78 | +----+----------+------------------------+----------------------+-----+ now, right selecting values database , inserting them array , picking 1 out random similar following: $ads_array = []; $ads = ad::where("active", "=", 1)->orderby("price", &q

sql - How to create a variable length RowParser in Scala for Anorm? -

a typical parser in anorm looks bit this: val idseqparser: rowparser[idandsequence] = { long("id") ~ int("sequence") map { case id ~ sequence => idandsequence(id, sequence) } } assuming of course had case class so: case class idandsequence(id: long, sequence: int = 0) all handy-dandy when know front if want run ad-hoc queries (raw sql) write @ run time? (hint: on fly reporting engine) how 1 tackle problem? can create series of generic parsers or various numbers of fields (which see scala had resort when processing tuples on forms meaning can go 22 elements in form , unsure heck after that...) you can assume "everything string" purpose of reporting option[string] should cut it. can parser created on fly however? if doing like? is more elegant way address "problem"? edit (to clarify i'm after) as "ask" using aliases select f1 'a', f2 'b', f3 'c' some

java - Displaying search results from a hash table -

i can't figure out how display results search method. put strings in needs display results. here client class public class client { private string name; private string city; public client(string name, string city) { this.name = name; this.city = city; } public string tostring() { return name + " " + city; } public string getname() { return name; } public string getcity() { return city; } } here hashtable class public class hashtable { private int n; private client[] table; public hashtable(int n) { this.n = n; table = new client[n]; } public int hashfunction(string key) { int sum = 0; (int = 0; < key.length(); i++) { sum += (int) key.charat(i); } sum = sum%n; return sum; } public string search(string key) { int sum = 0; (int = 0; < key

android - Filtering in RecyclerView takes long -

i testing set of 5000 objects. use custom comparator(myownsort) sort values based on business logic. public filter getfilter() { if (_filter == null) { _filter = new filter() { @override protected filterresults performfiltering(charsequence constraint) { string chartext = constraint.tostring(); filterresults filterresults = new filterresults(); // clear data visibledata.clear(); (string title : data) { if (title.startswith(chartext)) { visibledata.add(title); } } myownsort.setsearchstring(chartext); collections.sort(visibledata, myownsort); } filterresults.count=visibledata.size(); filterresults.values=visibledata; return filterresults; } @override protected void publishresu

jsf - In PrimeFaces (4.0) confirm dialog, how do I ensure 'No' is in focus by default? -

Image
as can see image below, 'yes' button gets primary focus. can ensure 'no' in focus without swapping buttons around, perhaps attribute? as far know, way swap buttons in xhtml. can keep order of appearance in dialog float:left on yes button. <p:confirmdialog global="true" showeffect="fade" hideeffect="fade"> <p:commandbutton value="no" type="button" styleclass="ui-confirmdialog-no" icon="ui-icon-close" /> <p:commandbutton value="yes" type="button" style="float:left;" styleclass="ui-confirmdialog-yes" icon="ui-icon-check" /> </p:confirmdialog>

c# - Can not seed data with EF Code First -

i found problem, solution @ comments. i can create tables , diagram can not seed data table. 1.i installed ef nuget. 2.from pm console wrote enable-migrations –enableautomaticmigrations. model in all.model class library , and context methods in all.dal class library did not understand doing wrong can me? this context code: using all.model; namespace all.dal { public class alldb : dbcontext { public alldb() { database.connection.connectionstring = "server=seuphoria;database=alldb;uid=sa;pwd=123;"; } public dbset<category> categories { get; set; } public dbset<comment> comments { get; set; } public dbset<line> lines { get; set; } public dbset<user> users { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { database.setinitializer<alldb>(new dbstrategy()); modelbuilder.entity<category>().property(c => c.name).isrequir

oracle - SQL: Repeating data in JOIN -

Image
i'm doing homework class , can't figure out how answer question: "determine books generate less 55% profit , how many copies of these books have been sold. summarize findings management, , include copy of query used retrieve data database tables." i tried taking shot @ can't seem come out way want to. has data doesn't seem go together. below code: select isbn, b.title, b.cost, b.retail, o.quantity "# of times ordered", round(((retail-cost)/retail)*100,1)||'%' "percent profit", o.quantity "# of times ordered" books o join orderitems o using(isbn); it works in sense data need comes this: i have theory because table "order items" has multiple orders same isbn , different quantities it's selecting of them. there way combine them? if not me rid of redundant data caused join? thank you! i've had similar things in sql server / mysql. need group columns in see repeated data not c

java - HashSet doesnt allow duplicates but how to write logic for allowing duplicates -

consider following program: import java.util.*; class setdemo { public static void main(string[] args) { set s=new hashset(); s.add("ajay"); s.add(120); s.add("a"); s.add(120); system.out.println(s); } } it outputs [a,ajay,120] , want output contain 120 2 times. how can achieve that? you should use hashmap key, value pairs. or list. sets design contain unique elements.

php - Show names from comma seperated values -

i have query on article data contains mysql column called products. field contains values 2,20,12. numbers represent id's of rows of products associated article. i need work out how can display products under each article without creating duplicates of each result. $sql5="select * #__content catid=$iconcategoryid"; $db->setquery($sql5); $articles= $db->loadobjectlist(); foreach($articles $article){ $product_ideez = $article->products; $sql6="select * #__products_products id in($product_ideez)"; $db->setquery($sql6); $products= $db->loadobjectlist(); foreach ($products $product) { $productarray .= '<span class="badge">'.$product->name.'</span>'; } // html output here // getting duplication on output of product names echo '<h1>'.$article->title.'</h1>'; echo '<hr/

javascript - Difference of method calling between object and function -

here code , fiddle : var test = { value : "sss", func1 : function(){ console.log(this.value); } }; var test2 = function(){ return { value : "sss", func1 : function(){ console.log(this.value); } }; }(); test.func1(); test2.func1(); hey lads, what's difference between these 2 ways of method calling. have make test2 inmmediate invoke function execution make sure works. mean carry coals newcastle? 1 better or situation should use them? hey lads, what's difference between these 2 ways of method calling. there's no significant difference between 2 resulting objects have them. which 1 better or situation should use them? the second scheme offers option of having private variables in closure methods use this: var test2 = function(){ var cnt = 0; return { value : "sss", func1 : function(){ console.log(this.value);

vba - looping through an unknown range of rows in excel -

say have 5 columns , god knows how many row. cells in range populated except few cells in last column. need loop through rows (starting in a1) until last row, , each row has cell populated in last column, display message box saying "hello" i'm unsure how start loop. i've tried googling, dont understand. know how i'd check empty cells, , how diply message box, not how find end of range. additional variant side dim cl range activesheet each cl in .range(.[a1].currentregion.columns(5).address) if cl.value <> "" msgbox cl.address(0, 0) & " has value (" & cl.value & ")" end if next cl end

listview - How to set default fragment in android? -

i have tried several ways set default fragment 1st list item when app open's first time , last opened fragment when app not opened first time. both scenarios not working. please help. mdrawerlist.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int stupid, long id) { // getting values selected listitem name = ((textview) view.findviewbyid(r.id.name)) .gettext().tostring(); strpath = ((textview) view.findviewbyid(r.id.email)) .gettext().tostring(); string description = ((textview) view.findviewbyid(r.id.mobile)) .gettext().tostring(); source_id = integer.parseint(description); // starting single contact activity bundle data = new bundle(); data.putstring(tag_name,name); data.

scala - Spark RDD Lifecycle: whether RDD will be reclaimed out of scope -

in method, create new rdd, , cache it, whether spark unpersist rdd automatically after rdd out of scope? i thinking so, what's happens? no, won't unpersisted automatically. why ? because maybe looks rdd not needed anymore, spark model not materialize rdd until needed transformation, it's hard tell "i won't need rdd" anymore. you, can tricky, because of following situation : javardd<t> rddunion = sc.parallelize(new arraylist<t>()); // create empty merging (int = 0; < 10; i++) { javardd<t2> rdd = sc.textfile(inputfilenames[i]); rdd.cache(); // since used twice, cache. rdd.map(...).filter(...).saveastextfile(outputfilenames[i]); // transform , save, rdd materializes rddunion = rddunion.union(rdd.map(...).filter(...)); // transform t , merge union rdd.unpersist(); // seems not needed. (but needed actually) // here, rddunion materializes, , needs 10 rdds unpersisted. so, rebuilding 10 rdds occur. rddunion.saveas

excel vba - Copy-paste based on date -

ultra newb here excel vba. sheets data comes userform user enters info includes use date goes column c. have activex button on sheet1, run search of dates in column c previous today's date , in 7 days time cut , pasted sheet 3. i apologize in advance if not specific enough. appreciate , input on this! your question bit broad meaningfully answered. please see how create minimal, complete, , verifiable example but describing there lot of resources can use: userforms getting started vba in excel macros, worksheets, loop, arrays ... (a bit of everything) if stuck or there's more specific can answer come , we'll answer it.

android - onSetItemClickListener not working -

hey saw many solutions none pertain me... using actionbaractivity toolbar , cannot mdrawerlist.setonitemclicklistener(new adapterview.onitemclicklistener() { this code: mtoolbar = (toolbar) findviewbyid(r.id.toolbar); mdrawerlist = (listview)findviewbyid(r.id.navlist); mdrawerlayout = (drawerlayout)findviewbyid(r.id.drawer_layout); mactivitytitle = gettitle().tostring(); setsupportactionbar(mtoolbar); adddraweritems(); setupdrawer(); getsupportactionbar().setdisplayhomeasupenabled(true); getsupportactionbar().sethomebuttonenabled(true); public void adddraweritems() { log.d(constants.debug, "adding drawer items"); draweradapter = new draweradapter(this); mdrawerlist.setadapter(draweradapter); mdrawerlist.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position,

java - spring cloud netflix jersey version conflict -

hello have spring boot application using <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-jersey</artifactid> </dependency> this dependent on jersey version 2.7. when trying use <dependency> <groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-starter-eureka</artifactid> </dependency> that internally uses jersey version 1.1, application fails given 2 different versions of same library. any advice in how fix issue, have tried use version 2.7 seems not compatible each-other thanks java.lang.nosuchmethoderror: javax.ws.rs.core.application.getproperties()ljava/util/map; @ org.glassfish.jersey.server.applicationhandler.(applicationhandler.java:303) @ org.glassfish.jersey.server.applicationhandler.(applicationhandler.java:284) @ org.glassfish.jersey.servlet.webcomponent.(webcomponent.java:311) @ or

How to write SQL Server query which can give result from any of 4 tables -

i have 4 tables (say emp1, emp2, emp3, emp4) identical columns. want fetch details (select empid, empname emp1 empid = '1' ) union (select empid, empname emp2 empid = '1') union (select empid, empname emp3 empid = '1') union (select empid, empname emp4 empid = '1') the thing if got result first query (emp1) should ignore queries below (emp2, emp3, emp4). if result emp2, should ignore (emp3, emp4) , on. remember in emp1, emp2, emp3, emp4 there different empname associated same empid . that's why union giving results. in case have prefer result uppermost table i.e emp1 > emp2 > emp3. tried using 'case' things not working me. sample data emp1 1 deepak emp2 1 nitin emp3 1 sateesh emp4 1 chandra and expected result is 1 deepak i hope clear you. please me thank you you can add arbitrary column specify priority. sql fiddle ;with cte as( select *, n = 1 emp1 empid = 1 union sel

ios - Add a drop down suggestion below a UISearchbar and UITextfields -

in ios app, there 3 separate text entry fields. 1 in searchbar , 2 in uialertview(that has 2 entry fields). need give drop down menu below fields can give suggestions user. have data needed in array(all 3 fields need same array suggestion). how this? should programmatically create uitableview appear below textfields(with basic cell, containing 1 text field) ? if so, how can right frame? or else, other method should refer? here simple example. here taking 1 uitextfield. when becomes first responder, showing drop down i.e., uitableview . when object selected table view drop down collapse. - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. mutarr=[[nsmutablearray alloc]init]; [mutarr addobject:@"object1"]; [mutarr addobject:@"object2"]; [mutarr addobject:@"object3"]; [mutarr addobject:@"object4"]; [mutarr addobject:@"object5"]; [mutarr addobject:@&q

javascript - How can i get data from two input field under a radio button -

i have form used radio button. when user select file, input field of file show , when select text input field of text show. problem how can data radio button have 2 input field. <div class="span7"> <b>select file or link</b> <input type="radio" name="telephone" value="filelink1" id="rad1" checked="" />file <input type="radio" name="telephone" value="filelink2" id="rad2" />link </div> <div class="span7" id="linkname"> <b>press release link</b> <br/> <input type="text" name="link" placeholder="press link" /> </div> <div class="span7" style="margin-left:42px;display: none;" id="filename"> <b>press release file</b> <br/> <input type="file" name="fil

lucene - Elasticsearch: Inconsistent number of shards in stats & cluster APIs -

i uploaded data single node cluster , named index 'gequest'. when http://localhost:9200/_cluster/stats?human&pretty , get: "cluster_name" : "elasticsearch", "status" : "yellow", "indices" : { "count" : 1, "shards" : { "total" : 5, "primaries" : 5, "replication" : 0.0, "index" : { "shards" : { "min" : 5, "max" : 5, "avg" : 5.0 }, "primaries" : { "min" : 5, "max" : 5, "avg" : 5.0 }, "replication" : { "min" : 0.0, "max" : 0.0, "avg" : 0.0 } } } when on http://localhost:9200/_stats?pretty=true "_shards" : { "total" : 10, "succ

asp.net mvc - How to combine google recaptcha and login in ASP MVC -

in our asp mvc site, login form members exists. trying add captcha reduce bot attacks (my login not simple membership, similar, concept remains same) . understand how login request works , making round trip server. how recaptcha work in tandem membership login-in site . i understand spam side of it , how work in tandem user authentication/authorization during login. so, pass on authenticate after captcha passes, or checks , steps follow? picture , sample help... if implement recaptcha in tandem membership , sequence of steps happening or should happen , can model code? the steps captcha below generate captcha ( image + key ) store key in session . send image user receive response user key user interpret image verify if original key session match user key input . take decision, if valid register/login else captcha invalid, repeat step 1 notes: usually steps done async , in group of 3. steps 1,2,3 providing captcha. steps 4,5,6 verify capt

jquery - Alert if the checkbox is checked without a value and submitted -

i want when click on submit button, should alerts me if checkbox checked without value in text box. , after corrected, when click on submit, should values of text box checked. <center> proceed checking? <input type="radio" id="radio1" name="radio" value='yes' /> <label for="radio1">yes</label> <input type="radio" id="radio2" name="radio" value='no'/> <label for="radio2">no</label> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <br><br> <div class="result1"></div> <div class="result2"></div> <div class="result3"></div> <div class="result4"></div> <script> $(function() { $("input[name='radio']").on("change",

sitecore - Added a Field to WeBlog Entry template, trying to get the field in Category.ascx.cs -

i have followed steps in following link template settings , created custom templates entry, comment , category. custom entry template, have added additional field. have requirement display in categories.ascx. able override categories.ascx unable value of added field using weblog's api. here's code using. issue class entryitem doesn't have additional field have added. there way read field using weblog api? entryitem[] blogentries = managerfactory.entrymanagerinstance.getblogentries(); entryitem inherits customitem believe, can use inneritem property access actual item. field should available this: entryitem.inneritem["youfield"]; you can use field renderer in categories.ascx file display value of field , use data binding item assigned field renderer. <sc:fieldrenderer id="fieldrenderer1" runat="server" fieldname="yourfield" item='<%# entryitem.inneritem %>'/>

sqlite - PHP/Sqlite3: Fatal error: Call to undefined function sqlite_num_rows() -

i getting error when call function sqlite_num_rows . must not dependency issue since other sqlite functions working. i'm able open connection , data db. relative info on php.net neither of "sqlite_num_rows($result)" , "$result->numrows()" not working on sqlite3 ! should use way: <?php $db = new sqlite3('databasename.db'); $result = $db->query("select * users"); $rows = count ($result); echo "number of rows: $rows"; click me

java - How to design classes based on requirements or functionality -

i'm struggling class design. think have read class organization, class diagram , class design can not apply concrete project. want create snake game in java using mvc or mvp architecture. there requirements: the snake , food snake should drawn on screen it should displayed current game score the snake should move using key arrow the food should grouped each group have amount of point , color game speed should determined on score threshold the question how organize classes (with methods , "all") according requirements? maybe have book or link suggest guidance or examples. please share rule of thumb creating , organizing classes through example? here example of simple snake game clone in java might refer ideas on how structure things. since ask book recommendation, recommend book helped me immensely in grasping object oriented analysis , design. teaches solving real problems step step. quite different not follow typical flow of technical books

Highchart bubble cut off with max x/yAxis -

i need have bubble chart xaxis , yaxis 0 5. if have bubble on xaxis or yaxis 5, bubble cut of. $(function () { $('#container').highcharts({ chart: { type: 'bubble', zoomtype: 'xy', height: 500, width: 500, }, title: { text: 'highcharts bubbles' }, yaxis: { min: 0, max: 5, gridlinewidth: 1, }, xaxis: { min: 0, max: 5, gridlinewidth: 1, }, series: [{ data: [[5, 4, 2], [3, 1, 1], [4, 2, 3], [1, 2, 3], [1, 4, 1], [2, 5, 1], [5, 2, 3], [3, 2, 1]] }] }); }); http://jsfiddle.net/tum3zzzu/1/ i somehow found trick doing max: 5.5 work xaxis. on yaxis max: 5.5 rounded 6. how can solve problem? you can use tickpositioner tell chart show ticks. used showlastlabel: false hide last tick (which 5.5). here's can i

java - Given final block not properly padded(BadPaddingException) -

i using ftpclient java in want encrypt file , decrypt again. the encryption done using below code: string s= enumerationsqms.returnstatus.success.getreturnstatus(); int read; ftpconfig objftp = (ftpconfig)gethibernatetemplate().find(" ftpconfig sstatus='a'").get(3); ftpclient ftpclient = new ftpclient(); ftpclient.connect(objftp.getshost(),objftp.getnport()); logger.info("objftp.getsip()"+objftp.getsip()); boolean strue = ftpclient.login(objftp.getsusername(),objftp.getspassword()); logger.info("objftp.getsusername()"+objftp.getsusername()); logger.info("objftp.getspassword()"+objftp.getspassword()); ftpclient.enterlocalpassivemode(); ftpclient.setfiletype(ftp.binary_file_type); if(strue) { string st = generalfunctiondaoimpl.getabsolutepath() + objdbfilestorage.getsfilename(); logger.info("file name--->"+st); file firstlocalfile = new file(st); string uniquefilename =objdbfilest

php - Sending binary file content using JSON -

i've written rest interface owncloud app. i've method getfilefromremote($path) should return json object file content. unfortunately works when file i've specified in $path plaintext file. when try call method image or pdf status code 200 response empty. returning file contents use file_get_contents retrieving content. note: know owncloud has webdav interface, want solve rest only. edit code server side (owncloud): public function synchronisedown($path) { $this->_syncservice->download(array($path));//get latest version $content = file_get_contents($this->_homefolder.urldecode($path)); return new dataresponse(['path'=>$path, 'filecontent'=>$content]); } the first line retrieves downloades content on owncloud server , works completely. you have base64_encode file content make json_encode/decode handle properly: return new dataresponse([ 'path'=>$path, 'filecontent' => ba

php - Cannot save data in more than one array in Laravel -

i trying save data in laravel has multiple arrays. the array looks this: array ( [0] => array ( [client_personnel_name] => ron [client_id] => 52 [client_personnel_email] => abc@gmail.com ) [1] => array ( [client_personnel_name] => john [client_id] => 52 [client_personnel_email] => abc@gmail.com ) ) when save data: $personnel = clientspersonnel::create($client_personnel); $personnel->save(); on debugging data being created insert. in attributes sent data stored [attributes:protected] => array ( [updated_at] => 2015-04-23 06:53:05 [created_at] => 2015-04-23 06:53:05 [id] => 2 ) how can save data has multiple arrays? you can use db::insert() , this: db::table('client_personnel')->insert(array($client_personnel)); as alternative, using loop like.

ios - cellForItemAtIndexPath of collectionView is not called when I reload the cells from a method of another class(navigationviewcontroller) -

i have viewcontroller in implementing collection view. have set delegate , datasource of collection view inside viewdidload of viewcontroller.the action trying implement if click button on navigationbar(which implemented programatically in navigationviewc) should reload collectionview cells in viewcontroller.but if add action selector navigation bar button function in navigationviewcontroller reloads data of collection view not calling cellforitematindexpath method.can me please you should add barbuttonitem in regular viewcontroller: override func viewdidload() { super.viewdidload() navigationitem.rightbarbuttonitem = uibarbuttonitem(title: "reload", style: .plain, target: self, action: "reloadbuttontapped") } func reloadbuttontapped() { println("reload") }

c - Backward Analysis of Expression -

suppose have following code segment in c. i = j = k = 1; j = (i++) + (++k); result = + j + k; //poi //expected result = 7 here, want find value of result through backward analysis. when perform backward analysis, go through following expressions in order. j = (i++) + (++k); ++k; i++; = j = k = 1; j = k = 1; k = 1; during backward analysis replace each variable corresponding expression, whenever applicable. i'm confused how deal increment/decrement operations. my current strategy produce following result result = + j + k //after j = i++ + ++k result = (i+(i+(k+1)))+k //after ++k result = (i+(i+((k+1)+1)))+(k+1) //after i++ result = ((i+1)+((i+1)+((k+1)+1)))+(k+1) //after = j = k = 1 result = ((1+1)+((1+1)+((k+1)+1)))+(k+1) //after k = 1 result = (((1+1)+((1+1)+((1+1)+1)))+(1+1)) //simplifying result = 9 which ofcourse not true. can me this? i think should more this result = + j + k //after j = x + y // didn't analyse ++k , i++ yet r

html - How to get text(file names) present between anchor tags in PHP? -

i've following strings me in file name present in between anchor tags: $test1 = test<div class="comment_attach_file"> <a class="comment_attach_file_link" href="http://52.1.47.143/feed/download/year_2015/month_04/file_3b701923a804ed6f28c61c4cdc0ebcb2.txt" >phase2 screen.txt</a><br> <a class="comment_attach_file_link_dwl" href="http://52.1.47.143/feed/download/year_2015/month_04/file_3b701923a804ed6f28c61c4cdc0ebcb2.txt" >download</a> </div>; $test2 = holiday list.<div class="comment_attach_file"> <a class="comment_attach_file_link" href="http://52.1.47.143/feed/download/year_2015/month_04/file_2c96b997f03eefab317811e368731bb6.pdf" >holiday list-2013.pdf</a><br> <a class="comment_attach_file_link_dwl" href="http://52.1.47.143/feed/download/year_2015/

datetime - How can I convert milliseconds to "hhmmss" format using javascript? -

i using javascript date object trying convert millisecond how many hour, minute , second is. i have currenttime in milliseconds var currenttime = new date().gettime() and have futuretime in milliseconds var futuretime = '1432342800000' i wanted difference in millisecond var timediff = futuretime - currenttime the timediff was timediff = '2568370873' i want know how many hours, minutes, seconds is. could help? var secdiff = timediff / 1000; //in s var mindiff = timediff / 60 / 1000; //in minutes var hdiff = timediff / 3600 / 1000; //in hours updated function mstohms( ms ) { // 1- convert seconds: var seconds = ms / 1000; // 2- extract hours: var hours = parseint( seconds / 3600 ); // 3,600 seconds in 1 hour seconds = seconds % 3600; // seconds remaining after extracting hours // 3- extract minutes: var minutes = parseint( seconds / 60 ); // 60 seconds in 1 minute // 4- keep seconds not extracted min

How to convert getColorStateList (JAVA->C# xamarin for android) -

this java code-: mtext.settextcolor(getresources().getcolorstatelist(r.color.xml_color_selector)) tried convert c#(this code in getview) mtext.settextcolor(parent.context.resources.getcolorstatelist(resource.drawable.xml_color_selector));; unhandled exception: android.content.res.resources+notfoundexception: file res/drawable/xml_color_selector.xml color state list resource id #0x7f0200a3 how convert c# code? ps. xml_color_selector.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_activated="true" android:drawable="@color/menu_item_background_color_pressed" /> <!-- pressed tab --> <item android:state_pressed="true" android:drawable="@color/menu_item_background_color_pressed" /> <!-- non pressed tab --> <item android:state_pressed="false" android:dr

Spring data JPA Spel - @Query Issue -

i having trouble getting spel , spring data jpa work following repository package eg.repository; public interface myentityrepository extends jparepository<myentity, long>,jpaspecificationexecutor<myentity> { @query("select e eg.domain.myentity e " + "where e.title = :#{#filter.title}" ) page<myentity> list1(@param("filter") myfilter filter,pageable pageable); } filter component package eg.service; import org.springframework.stereotype.component; @component("filter") public class myfilter { public string titlefilter() { return "%title%"; } private string title = "title title1"; public long[] idfilter() { return new long[] { 1l, 2l }; } } following myentity package eg.domain; @entity public class myentity implements serializable { @id @generatedvalue(strategy = generationtype.identity) private lon

git - Github pages: Jekyll changes not showing in _site -

i set jekyll site on github pages, , whole site works fine when going pages url, new posts appear correctly etc. _site folder isn't showing changes when viewing repository via github. does github pages generate site _site on same repository , serve _site @ url? idea use github pages kind of staging server, new posts in prose.io, make sure working checking github pages url, pull down _site folder contents own server. have set , running correctly, when pull down there arent new changes in _site folder despite changing being shown on pages url. github generates site your, it's useless push _site folder. now can still : edit prose on github page test result pull changes github local make jekyll build locally push own server

.net - How to Create a new culture assembly WPF -

i following tutorial on implementing localization in application . but cant head around step 4, says create new culture assembly. the loaded assemblies resourcedictionaries used replace default 1 within main assembly. create normal wpf app, , use resourcedictionary strings use mergeddictionary in app.resources make sure localizable controls using dynamicresource <label content=”{dynamicresource label1}”/> create new culture assembly sensible name, such culture_fr-ca for assembly created in step 4, create mirror image resourcedictionary matches original assemblies resourcedictionary . translated strings compile culture assembly folder under main assemblies bin\debug folder. demo assumes folder called “culturefiles” when main app runs, current culture , load matching assembly disk from loaded culture assembly, extract resourcedictionary using extracted resourcedictionary , replace current application.mergedresources dictionary newl

php - Document root for mobile version (.htaccess?) -

i have webshop, , since google decided promote mobile versions of webpages, developing m.example.com . here trick. not want, m. domain. want is, when user coming, check user agent, , if coming mobile, show mobile version, if come desktop, show desktop version. but, want use same urls users. so, http://example.com/contact/ url both desktop users, , both mobile users. the mobile version of page under subdirectory ./mobile/ . is possible somehow force apache, change document root, if coming mobile, keep original urls? for example: http://example.com/contact/ should run /var/apache/example.com/mobile/contact.php , desktop version, should run /var/apache/example.com/contact.php ? mentioned, urls same. if question not clear, please leave comment. something this? (collated this answer , doing rewriterule ) rewriteengine on # check if noredirect query string rewritecond %{query_string} (^|&)noredirect=true(&|$) # set cookie, , skip next rule rewriteru

javascript - Jquery, cloned element been remove together when the original element removed -

i have form containing 1 input. when user clicking on button, input cloned , clone inserted after original input. the user able remove clone. my problem is, when remove original element used create clone, cloned element removed too. i want remove target input user choosing. a cloned element not linked original element. more selector using delete element has broad scope , deleting them all. can happen if selecting id and, commenter has suggested, have cloned id each element well. without code snippets, it's hard diagnose issue.

python - Loading QImage from memory using OpenimageIO -

i'm trying load qimage memory. pyopenimageio gives me pixels in python array: array('f',[r1,g1,b1,r2,g2,b2]). using function: img = qtgui.qimage(pixels,spec.width, spec.height, qtgui.qimage.format_rgb888) or img = qtgui.qimage(pixels.buffer_info()[0],spec.width, spec.height, qtgui.qimage.format_rgb888) gives me wrong result, this: https://dl.dropboxusercontent.com/u/6325775/nodes/images/out.png setpixel() gives correct result, slow. taking , filling char* img.constbits() little bit faster. how load qimage memory of python array?

box api - Search query parameter is ignored in BOX REST API -

i'm trying make call method search restsharp in vs2013. box ignoring subquery string. have consulted documentation , tested call "postman" , works well. string query = "asterisk"; string subquery = "file_extensions=docx"; var client = new restclient(base_url); client.authenticator = new oauth2authorizationrequestheaderauthenticator(dev_access_token, "bearer"); var request = new restrequest(method.get); request.resource = "search?query={query}&{subquery}"; request.addparameter("query", query, parametertype.urlsegment); request.addparameter("subquery", subquery, parametertype.urlsegment); request.requestformat = dataformat.json; var response = client.execute(request); var content = response.content; regards the problem you're adding entire file_extensions=docx string url parameter. res

c# - Cannot implicitly convert type Interface to 'System.Collections.Generic.IList<T>' -

stuck in below issue please help, have 1 below class , contain 1 method return type interface public class helper { public irestresponse getcam (string searchterm, int page, int pagesize) { restrequest request = new restrequest(method.get) { requestformat = dataformat.json, resource = string.format("/assets/campaigns?search={0}&page={1}&count={2}&depth=complete", searchterm, page, pagesize) }; irestresponse response = _client.execute(request); return response; } } in interface have set, public interface irestresponse { string content { get; set; } string contentencoding { get; set; } long contentlength { get; set; } string contenttype { get; set; } ilist<restresponsecookie> cookies { get; } exception errorexception

hibernate - In JPA , Is em.flush() is exceptional usage or not -

hi i'm updating parent entity (department) has child(employees) ,along update want delete child , add new set of child . , have unique constraint employee_name db side . first i'm finding department , calling clear (collection clear ) list of employees adding new child department , committing . i'm getting unique constraint violation .if use em.flush() after clear() deleting child , inserting new child . know flush() exceptional use, commit uses flush() internally . there solution delete , insert child in single transaction ?? , i'm using orphanremoval = true in department entity public void deleteemployee(department updatingdepartment){ list<employee> employees = new arraylist<employee>(); employee employee1 = new employee(); employee1.setemployeealary(16667); employee1.setemployeename("manju"); employee employee2 = new employee(); employee2.setemployeealary(16667); employee2.setemployeename("sunil")