Posts

Showing posts from January, 2010

function - Why does sage treat local python variables as global? -

new sage , python, i'm not sure i'm abusing. i'm trying define following function acts on input list a, every time input function affects global value of a. how can make behave locally? def listxgcd( ): g,s,t=xgcd(a.pop(0),a.pop(0)) coeffs=[s,t] while a!=[]: g,s,t=xgcd(g,a.pop(0)) coeffs=[s*i in coeffs] coeffs=coeffs+[t] return coeffs i've tried setting b=a , substituting b everywhere doesn't work either don't understand. need declare sort of sage-y variable thing? def listxgcd( ): b=a g,s,t=xgcd(b.pop(0),b.pop(0)) coeffs=[s,t] while b!=[]: g,s,t=xgcd(g,b.pop(0)) coeffs=[s*i in coeffs] coeffs=coeffs+[t] return coeffs much thanks! you passing reference container object listxgcd function , function retrieves elements container using pop . not scope issue, fact there operating directly on container have passed function. if don't want function modify cont

sorting - Sort two-dimensional NSMutableArray using the last element the inner arrays -

i have following nsmutablearray: (a|b|c|d|e|255, f|g|h|i|j|122, k|l|m|n|o|555) i trying sort objects in array using last component (255, 122, 555). right have following code: [myarray sortusingselector:@selector(localizedcaseinsensitivecompare:)]; as expected, method sorts array first element (a, f, k). i read nssortdescriptor, example: nssortdescriptor *sort = [[[nssortdescriptor alloc] initwithkey:@"datemodified" ascending:yes] autorelease]; if use it, not clear put parameter in initwithkey . you can use sort descriptor, takes last object of "inner" arrays , sort that. since sort descriptors use key-value coding (kvc), need aware arrays respond valueforkey: in special way - pass normal key on each of objects contain. you need know methods not take parameter and return value can accessed through kvc if normal properties. all adds following: each of objects contained in array (i.e., inner arrays) have key want sort by: last

Functional programming style vs performance in Ruby -

i love functional programming , love ruby well. if can code algorithm in functional style rather in imperative style, it. tend not update or reuse variables as possible, avoid using "bang!" methods , use "map", "reduce", , similar functions instead of "each" or danger loops, etc. try follow rules of article . the problem functional solution much slower imperative one. in article there clear , scary examples that, being until 15-20 times slower in cases. after reading , doing benchmarks afraid of keep using functional style, @ least in ruby. by other hand feel more comfortable writing code in functional style because smart , clean, tends less bugs, , think more "correct", specially nowadays can use concurrency , parallelism better performance. so confused style use in ruby. wise recommendation appreciated.

Java Graphics Invert Color Composite -

basically want make cursor jcomponent that's pixels appear inverse of color over. example, take mouse , hover on letters in url page. if closely, pixels of cursor on black pixels of letter turn white. know can invert rgb color subtracting current red, green, , blue colors 255 each corresponding field, don't know how implement way want. this part of basic paint program making. jcomponent mentioned before "canvas" can draw on various tools. not using java.awt.cursor change cursor because want cursor change dynamically according under it. "cursor" using defined .png image, , creating bufferedimage file can draw on top of existing bufferedimage of whole component. redraw image using point defined mouselistener. i looked alphacomposite , looks close want, there nothing inverting colors underneath cursor want. please help. edit: so had hard way algorithm because there's nothing built in purpose. here's code little out of context: /** * chang

arrays - Ruby, Working on a recursive bubble sort method and totally stuck -

so i'm doing chris pine's "learn program", , i've been having no end of trouble writing own recursive sorting method. i have been making slow (very slow) progress trial , error...but i'm stuck , have no clue. here's code: (and know got lots of other problems, work out in time, want answer question asked below, thanks) array = ['v', 't','k','l','w','o','a','y','p','f','x','g','h','j','z'] sorted_array = [] def mysort(array, sorted_array) if array.length <= 0 return end x = 0 y = 0 while y < array.length if array[x] < array[y] y += 1 elsif array[x] > array[y] x += y y += 1 else y += 1 end end sorted_array.push(array[x]) array.delete(array[x]) puts "test complete" end mysort(array, s

api - Instagram: sort photos with a specific tag with most likes -

i'm running contest on web image likes wins. it's tiresom having go through 900 images manually want is, sort images tag lets #computer after amount of likes, liked pics on top. have searched net crazy program or site (extragram, gramhoot, statigram, webstagram) none offer sort amount of likes , drives me insane! it's relevant request. i've tried istafeed.js doesn't include images, leaves out ones moest likes defies purpose. there's nothing know of in instagram api sends media sorted likes in advance. don't think there's tool either, writing 1 relatively simple imo , i've done before contest specifically. the simplest thing do following: use instagram api (via library or pure rest) query tag. instance, if care tagged media or want process date, can use [/tag/tag-name/media/recent][1] enpoint. page through each result page processing next_max_id/next_max_tag_id. collect results locally database. receive "like" count eac

Sum Specified Column Jagged Array -

my homework assignment asking output sum of specified column of jagged 2d array. i've seen other solutions show how sum of columns, not specific one. issue i'm running java.lang.arrayindexoutofboundsexception if column entered , no element exists in row of 2d array. // returns sum of specified column 'col' of 2d jagged array public static int columnsum(int[][] array, int col) { int sum = 0; // loop traverses through array , adds items in specified column (int j = 0; j < array[col].length; j++) { sum += array[j][col]; } return sum; } // end columnsum() example: ragged array input (class named raggedarray) int[][] ragarray = { {1,2,3}, {4,5}, {6,7,8,9} }; system.out.println(raggedarray.columnsum(ragarray, 2)); this gives me arrayindexoutofboundsexception, don't know how fix if specified column asked argument. ideas? appreciate or suggestions! in loop, a try{ sum += array[j][col]

javascript return all combination of a number -

i trying combination of number. example, input "123" should return ["123", "231", "213", "312", "321", "132"] . here function: function swapdigits(input) { (var = 0; i++; < input.length - 1) { var output = []; var inter = input.slice(i, + 1); var left = (input.slice(0, i) + input.slice(i + 1, input)).split(""); (var j = 0; j++; j <= left.length) { var result = left.splice(j, 0, inter).join(""); output.push(result); } } console.log(output); return output; } however function returns undefined , tell me what's going wrong? the errors for loop , scope have been mentioned. besides that, splice method change string operates on. means inner loop never terminate because left keeps on growing, j never reaches left.length . if new language, suggest starting implementation close algorithm want

java - Using delimiter to organize a set -

is there way use delimiter every other time delimiter symbol comes up? for example, have set of strings separated commas so: (yes, 2, my, 15, face, 9) want word paired number following it, , separate above set following: ((yes, 2), (my, 15), (face, 9)). using custom list this, in realty add each element [ex. (yes, 2]) list. you can use regex pattern. code describes solution (since don't know how want store it, printing out). string data = "yes,2,my,15,face,9"; pattern p = pattern.compile("[^,]*,[^,]*,?"); matcher matcher = p.matcher(data); while (matcher.find()) { string[] splitted = matcher.group().split(","); system.out.println(splitted[0]); system.out.println(splitted[1]); system.out.println("******************"); } this outputs : yes 2 ****************** 15 ****************** face 9 ****************** another solution use scanner delimiter "," , pair returned parts.

javascript - How to open the current url in chrome to other available browsers? -

i trying create first extension open current url in other/all available browsers. have idea how it? have constructed codes opens current url new tab/new window: chrome.windows.create({url: newtab, type: "normal"}); if not possible, know language can it. unfortunately, chrome extensions cannot execute other programs. did find simple way around however. you need native application running outside of browser accept requests browser extension. did on http on odd-ball port accessible localhost. when button in extension clicked, fires off http request application, can whatever need do. there api communicating native applications chrome extensions, not familiar it.

php array to html table sort by columns -

i have php array output table. need sort table first column, second, third , fourth. im not sure if should use function or ksort. have below. seem have notice: use of undefined constants when run it. <!doctype html> <html> <body> <?php $state=array ( array('alabama', 'montgomery', 4779736, 23), array('alaska', 'juneau', 710231, 47), array('arizona', 'phoenix', 6329017, 18), array('arkansas', 'littlerock', 2915918, 32), array('california', 'sacramento', 37253956, 1), array('colorado', 'denver', 5029196, 22), array('connecticut', 'hartford', 3518288, 29), array('delaware', 'dover', 897934, 45), array('florida', 'tallahassee', 18801310, 4), array('georgia', 'atlanta', 9687653, 9), array('hawaii', 'boise', 1360301, 42) ); echo "<table border=\"5\" cellpadding=\"1

c++ - What are the default character separators for boost::char_separator (for use with boost::tokenizer)? -

the answer question seems should obtainable looking @ boost documentation char_separator , or googling. however, can find answer question: default separators boost::char_separator (for use boost::tokenizer )? thanks! http://www.boost.org/doc/libs/1_55_0/libs/tokenizer/introduc.htm ... if not specify anything, default tokenizerfunction char_delimiters_separator defaults breaking string based on space , punctuation . ... according source code, "punctuation" defined std::ispunct(e) != 0 , while "space" defined std::isspace(e) != 0 .

scala - Running ScalaTest in Play Framwork 2.2.X -

i'm trying run functional scalatest in play 2.2 can't seem able import de @test annotation needed run tests. i've tried looking solutions seem different versions since none work 2.2 version. can guide me on running scalatest on play? the super basic test class tried run is: class test extends assertionsforjunit { @test def test() { } } while error is: type mismatch; found : server.test required: scala.annotation.annotation can paste example of test class? need include scalatest in build file: librarydependencies += "org.scalatest" %% "scalatest" % "2.1.0" % "test"

c# - Task.Factory.StartNew with parameters and return values -

trying call method requires parameters in order result , pass result proceed. i'm new task area , can't seem figure out correct syntax. appreciated. task.factory.startnew(() => checkconflict(startdate, enddate, actid, repeatrule,whichtime)) .continuewith( getconflictdelegate(result), taskscheduler.fromcurrentsynchronizationcontext); assuming want continue result of checkconflict() , continuewith takes task<t> argument. task<t> has property result , result method invocation. see code snippet below, example. new taskfactory() .startnew(() => { return 1; }) .continuewith(x => { //prints out system.threading.tasks.task`1[system.int32] console.writeline(x); //prints out 1 console.writeline(x.result); });

SQLite with strftime('%w', ...) not giving expected results -

i need determine if particular date sunday, find date following sunday. using strftime function below check day of week, case statement not evaluate properly. example 2014-03-09 (iso format) sunday. have expected following sqlite case statement evaluate 7. select strftime('%w', date('2014-03-09')) , case when strftime('%w', date('2014-03-09')) = 0 7 else 0 end generates 0|0 <-- why isn't 0|7? what missing? my version of sqlite is sqlite 3.7.11 2012-03-20 11:35:50 00bb9c9ce4f465e6ac321ced2a9d0062dc364669 in query, you're comparing string integer, evaluate false. try comparing string: case when strftime('%w', date('2014-03-09')) = '0'

html - how to give box-shadow in mail -

i want create own mail html code. now have written following code <table style="margin:auto;box-shadow:0 0 11px #090909"> </table> the properties working effect of boxshadow not working in gmail , yahoo works in other company domain it supported in few email clients. better off using images if want 100% support.

python - PyQt Progressbar QThread does not work correct -

i have problem code. plan show progress of loop using progressbar. idea use qthread. code below works somehow, not 100 percently correct. progressbar shows progress of loop, not via thread i.e. if try click more once on stop gui freezes. not qtcore expert. can please me , tell me why not work way want work? thanks lot! from pyqt4 import qtgui, qtcore #progressbar class mycustomwidget(qtgui.qwidget): def __init__(self, parent=none): super(mycustomwidget, self).__init__(parent) layout = qtgui.qvboxlayout(self) self.progressbar = qtgui.qprogressbar(self) self.progressbar.setrange(0,100) layout.addwidget(self.progressbar) #update progressbar def onprogress(self, i): self.progressbar.setvalue(i) if self.progressbar.value() >= self.progressbar.maximum(): self.close() #threading class class asa(qtcore.qthread): notifyprogress = qtcore.pyqtsignal(int) def run(self, i): #sends

git push error: not Signed-off-by author/committer/uploader in commit message footer -

i newbie in using git. in right direction lot. i working on issue, on local repository, , found bug fixed in kernel.org repository. so trying pull in (cherry-pick) fix (commit-id) kernel.org branch , submit local gerrit. , trying maintain commit message of commit kernel.org branch. when try push fix on local gerrit, face following error: error: ssh://@123.321.12.1:1234/mirror-sec/asdfgt/hjks ! [remote rejected] -> refs/for/ (not signed-off-by author/committer/uploader in commit message footer) error: failed push refs 'ssh://@123.321.12.1:1234/mirror-sec/asdfgt/hjks' following steps followed: did, git remote add 'tag' git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux did, git fetch 'tag' searched commit, git log 'tag'/master cherry-picked specific commit-id needed, git cherry-pick did, git commit --amend, new change-id cherry-picked commit-id did git push, submit change local gerrit. git push ssh://@123.321.12.1:1234/

html5 canvas - Develop a game using android or web technologies? -

i haven't created game before have 2d-game on mind wanted develop. though quite familiar using javascript , aware of html5's canvas, not aware of performance impact of creating using tech on android game. aware chrome app , it's ability work offline. what guide in choosing between 2 (advantage, disadvantage)? can responsive feature of web applied on game? imagine game cut rope example... considering performance , usability between browser , android, in case there no difference. it comes down planning achieve creating game of yours. whether planning make fortune way or not. advantages of browser games are: easier create (considering know how program in javascript) web browser more common these days android therefore accessability of such game bigger for play game, enough type correct web address( , biggest problem overcome, either using existing game platform such facebook, or have other means of how advertise web page, or doomed) advantages o

udp - Python - Is sendto()'s return value useless? -

in recent project, need use udp protocol transmit data. if send data using size = s.sendto(data, (<addr>, <port>)) , udp protocol ensure data packed 1 udp packet? if so, size == len(data) true ? there misunderstood? more precisely, 'sendto()' split data several smaller chunks , pack each chunk udp packet transimit? the length of udp packet limited. if data large, return value can't equal length.there situations, such not enough send buffer, network fault. size means bytes have been sent send buffer.

android - Set Image Resource from Enum -

i trying set image based on enum. did try research on how using post : how match int enum wasn't sure how use according code. here's enum: public enum imagevalue{ image1(1,r.drawable.clubs1), image2(2,r.drawable.hearts), image3(3,r.drawable.diamonds), image4(4,r.drawable.spades); private int imagevalue; private int image; private imagevalue(int value, int drawable){ this.imagevalue = value; this.image = drawable; } public int getimagevalue(){ return image; } } this getting image values , other values: public void newdeck() { deck = new arraylist<card>(); (int = 0; < 13; i++) { value = cardvalue.values()[i]; (int j = 0; j < 4; j++) { card = new card(value, suit.values()[j], imagevalue.values()[j] ); this.deck.add(card); } } coll

php - What kind of entities i should create in doctrine for this db structure -

Image
i have 2 tables in db (topic, topic_content): what kind of entities should create symfony2? think, should have in symfony structure (entities/topic.php, entities/topic_content.php) me please.. yes, create topic , topic content. , user entity (because user_id looks foreign key). however, idea in symfony2 approach application model site instead of database site. quoting https://doctrine-orm.readthedocs.org/en/latest/tutorials/getting-started-database.html : development workflows when code first , start developing objects , map them onto database. when model first , modelling application using tools (for example uml) , generate database schema , php code model. when have database first , have database schema , generate corresponding php code it. for database first, there generator derive objects based on schema: https://github.com/beberlei/doctrinecodegenerator the recommended approach though have doctrine generate db schema entities. quoting get

c# - WndProc no suitable method found to override -

i creating custom user control , trying call wndproc in control. but, gives me error wndproc: no suitable method found override. public partial class mycontrol : usercontrol, icloneable, icomparable<mycontrol> { [system.security.permissions.permissionset(system.security.permissions.securityaction.demand, name = "fulltrust")] protected override intptr wndproc(system.windows.forms.message m) { codes } } how override method in usercontrol? related partial modifier? the signature is: protected virtual void wndproc(ref message m)

how to convert a Iterator[Long] to Iterator[String] in scala -

i have requirement have convert iterator[long] iterator[string] in scala. please let me know how can it thanks well other collection use map . example: scala> val ls = list(1,2,3).toiterator ls: iterator[int] = non-empty iterator scala> ls.map(_.tostring) //it map(x+""). see comments on why bad res0: iterator[string] = non-empty iterator scala> res0.next res1: string = 1 scala> res0.next res2: string = 2 scala> res0.next res3: string = 3

logging - How to modify the twisted log format? -

i use twisted's dailylogfile ,and run this: twistd --logfile=test.log myserver_tapname the log file this: test.log.2014_3_9 but hope log this: test.log.2014_03_09 how can format output filename? thanks! given file named my.py code: from twisted.python.log import filelogobserver import time extension = time.strftime("%y_%m_%d") def logger(): return filelogobserver(open("/tmp/test.log."+extension, "w")).emit invoking twistd --logger my.logger ... will log file named /tmp/test.log.2014_03_28.log

android intent - Calling activity not returned when back button is pressed -

i have 3 activities - activity (launcher,main), activity b - called activity , activity c (which share intent used share files images on social networking sites). activity b calls activity c. if user presses button in activity c, activity started instead of activity b. how rectify problem? i want activity c should return activity b when "sharing" cancelled pressing button. remove finish() when send intent activity c.

javascript - Speed issues with ngRepeat. Is it possible to reuse a DOM-part in AngularJS? -

i displaying list lot of data , getting slow fast (>5 entries = slow). tinkered around little bit , found not amount of data problem many dom elements generated. i show table meta information. each table row there 2 more hidden table rows include detail data , edit form. clicking on row opens detail info , clicking on edit button switches edit row. simplified plunkr without edit portion available here . the problem each entry there 3 rows generated include ton of tags , data. pagination no solution since problem manifests in significant way few 4 or 5 entries. load detail data dynamically found bottleneck many tags ng-repeat has create. (am mistaken here?) when cut out detail , edit portion page loads reasonably fast 10+ entries. a solution write detail , edit part once , hide , dynamically shift around according entry. know direct dom manipulation frowned upon in angular. there better solution? a plunkr illustrates idea i looked angular.element , updated secon

ios - How can I draw a line from one cell to another cell when using UITableViewCell -

Image
i need draw chart 1 cell has line link cell, how can in uitableviewcell? below: something this? nsindexpath *ipathcellfrom = [nsindexpath indexpathforrow:0 insection:0]; nsindexpath *ipathcellto = [nsindexpath indexpathforrow:0 insection:0]; cgrect = [self.mytableview rectforrowatindexpath:ipathcellfrom]; cgrect = [self.mytableview rectforrowatindexpath:ipathcellto]; cgpoint fromcenter = cgpointmake(from.origin.x + from.size.width/2, from.origin.y + from.size.height/2); cgpoint tocenter = cgpointmake(to.origin.x + to.size.width/2, to.origin.y + to.size.height/2); cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsavegstate(context); cgcontextsetstrokecolorwithcolor(context, [[uicolor blackcolor]cgcolor]); cgcontextsetlinewidth(context, 1.0); cgcontextmovetopoint(context, fromcenter.x, fromcenter.y); cgcontextaddlinetopoint(context, tocenter.x, tocenter.y); cgcontextstrokepath(context); cgcontextrestoregstate(context); context code taken here

xcode - Svn commit fails due to outdated file despite updating directory -

i strange error when try commit file. error svn: e160042: commit failed (details follow): svn: e160042: file or directory 'xyz.m' out of date; try updating svn: e160024: resource out of date; try updating i updated file using svn up in command line in xcode. when update, success message says files have been updated. however, when try commit, same issue again. what doing wrong?

javascript - Displaying a div based on a dropdown selection -

i have part of jsp code : <div> <label>choose type of procedure want :</label><select id="proc-type"> <option value="with-param">with parameters</option> <option value="without-param">without parameters</option> </select> </div> now, if user chooses parameters, following div should displayed : <div class="drop" id="drop"> <label> select procedure (without parameters) : </label> <select id="combobox" name="combobox"> <option>proc 1</option> <option>proc 2</option> </select> and, if without parameters, should displayed <div class="drop" id="drop"> <label> select procedure (without parameters) : </label> <select id="combobox" name="combobox"> <option>proc 3</option> <option>proc 4</option> </select> &l

Android List view layout Similar to Google play -

Image
i want implement list layout similar google play have menu every individual row. please me create this. do need create popup menu or there option available achieve this. thanks looks trying way in image shown. giving example of how trying achieve this. here's how doing this. not difficult. straight implementation of popup menu. step 1 : adapter public class listadapter extends baseadapter{ private arraylist<string> mainlist; public listadapter(context applicationcontext, arraylist<string> questionforslidermenu) { super(); this.mainlist = questionforslidermenu; } public listadapter() { super(); this.mainlist = questionforslidermenu; } @override public int getcount() { return mainlist.size(); } @override public object getitem(int position) { return mainlist.get(positi

hibernate - JPA java.util.Date issue -

i have date field in database value "27-aug-10 15:30:00". using jpa retrieve , set model object. in model object date 1 day "2010-08-28 04:00:00.0". when retrieved date should 27 aug 2010, coming 28 aug 2010 can please suggest me why retrieving 1 day. import java.util.date; import javax.persistence.column; public class model { @column(name = "begin_date") private date startdate; public date getstartdate() { return startdate; } public void setstartdate(date startdate) { this.startdate = startdate; } } the database default store timezone in. in retriving date out won't add timezone in. date being displayed gmt. @ using jodatime better date library. i'll give example. need jodatime library , jadiratypes library persist jodatime dates hibernate. http://mvnrepository.com/artifact/joda-time/joda-time/2.3 http://mvnrepository.com/artifact/org.jadira.usertype/usertype.jodatime/2.0.1 your code this: @type(type=&

jquery - Calling a function from one JavaScript file in html -

i wrote javascript in separate file want use function written in .js file html <html lang="en"> <head> <title>try</title> </head> <body onload="hide()" > <div id="final"> <p> hello world</p> </div> <script src="js/userfunction.js"></script> </body> </html> js file function hide(){ $("#final").hide(); } its not working, please suggest you have not included jquery file <html lang="en"> <head> <title>try</title> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> function hide(){ $("#final").hide(); } </script> </head> <body onload="hide()" > <div id="final"> <p> hello world</p> </div> <script

java - Understanding libgdx -

i understand framework; more open-source cross-platform game development library. went libgdx homepage , followed instruction on video tutorial. after setting project able run default my-gdx-game project on multiple supported platforms. great, fine , dandy...now what? i have been scouring forums, wikis, javadocs, , many many more sites looking decent straightforward how-to's. unfortunately couldn't find any, of out there assumes have basic knowledge of library. i feel video tutorial showed me how set project correctly, getting feet wet, assumed know how swim, , left me 300 miles out sea or something. i'm having trouble digesting library, because started using yesterday, i'm complete newcomer when comes libgdx. i want move existing projects on libgdx, i'm use bufferedimages, jframes , things that. experienced veterans nice. by way posted core project below, guys can walk me through going on here... <code> package com.me.mygdxgame; import com.bad

c# - Can't get the right datatype to pass parameter by reference -

i need here, keep receiving error ... has invalid arguments in part: this.search(ref objresult, ssql); i can't pass collection reference. internal override models.basecollectionmodel<models.categorymodel> onfind(string objqueryargs) { models.collection.categorycollectionmodel objresult = new models.collection.categorycollectionmodel(); string ssql = string.empty; ssql = "select * " + this.tablename; this.search(ref objresult, ssql); return objresult; } internal virtual void search(ref system.collections.ienumerable objresult, string squery) { //statement goes here... } just additional info categorycollectionmodel inherits from models.basecollectionmodel<models.categorymodel> inherits system.collections.objectmodel.observablecollection<t> make type objresult ienumerable , per method declaration: system.collections.ienumerable objresult = ^------+----------^ | +- right u

java - Return value unaffected if Exception is thrown? -

if exception thrown inside method, return value left before? for example: public int test(int a) { throw new exception(); } and then: a=2; a=test(a); ...after catch... system.out.println(string.valueof(a)); //a=? is affected upon exception? seems logically not so(?) can't find info on though. neeed sure. no, a not affected. declared in separate method test() method. int = 2; try { = obj.test(a); } catch (exception e) { system.out.println(string.valueof(a)); } system.out.println(string.valueof(a)); both sop print 2.

How to use OSM map in an android application.? Is there any tutorial to learn about using OSM in android.? -

hi guys past 1 week i'm searching tutorial/manual or steps include open street map android application. found either big project lot more functionality on it, otherwise many questions ended without proper conclusion "how"..! is there proper blog/site or document can fresher can refer.? i don't know of tutorials here's code wrote minimal example using osmdroid. // need display osm map using osmdroid package osmdemo.demo; import org.osmdroid.tileprovider.tilesource.tilesourcefactory; import org.osmdroid.util.geopoint; import org.osmdroid.views.mapcontroller; import org.osmdroid.views.mapview; import android.app.activity; import android.os.bundle; public class osmdroiddemomap extends activity { private mapview mmapview; private mapcontroller mmapcontroller; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.osm_main); mmapvie

arrays - MATLAB - get fieldnames of each element -

given when call fieldnames(md) , have list of element class md. now each element in md many subclasses own sub-elements, example first item fieldnames(md) returns called mesh , , when call fieldnames(mesh) , list of string contains items mesh , that's it. the goal here write items md subclasses text file. i tried following: mfields = fieldnames(md); fid = fopen('textfile.txt','w'); i=1:numel(mfields) j=1:numel(fieldnames(mfields{i})) fprintf(fid,'%s\r\n',fieldnames(mfields{i})) end end but apparently fieldnames doesn't take char argument. i'm new matlab please suggest if there other function job many thanks try this: mfields = fieldnames(md); fid = fopen('textfile.txt','w'); i=1:numel(mfields) %// check if field struct itself, otherwise not have subfields. if isstruct(md.(mfields{i})) subfields=fieldnames(md.(mfields{i})); else

mocking - How to use Jmock to produce mock Json request? -

in our code json object activemq , decide action , other parameter action , return json object activemq. unit test have mock json object request. what mock action instead? @mock private action action; private actiondispather subject = new actiondispather(action); @test public void doaction1givensomestateistrue() throws throwable { final message message = new message(); message.setstate(true); //message (json object in case) population omitted context.checking(new expectations() { { oneof(action).doaction1(); } }); subject.on(message); } @test public void doaction2givensomestateisfalse() throws throwable { final message message = new message(); message.setstate(false); //message (json object in case) population omitted context.checking(new expectations() { { oneof(action).doaction2(); } }); subject.on(message); } the json parsing handled in consumer, therefo

How to sort an array on a certain variable in php? -

i have piece of var_dump of 1 of array items displayed here: protected 'created_at' => object(carbon\carbon)[178] public 'date' => string '2014-01-23 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'europe/amsterdam' (length=16) my question how can sort array on created_at variable? should descending. thanks effort! uasort() should trick! see working example here . uasort($data, function($a, $b) { $first = $a['created_at']->format('u'); $second= $b['created_at']->format('u'); if ($first == $second) { return 0; } return ($first < $second) ? -1 : 1; }); the callback using date's timestamp ( ->format('u'); ) compare 2 dates. please note, uasort() maintains key-value association while usort() not .

javascript - WebService in JqueryMobile(Response in Json) -

i'm doing project in jquery mobiles , need webservice. in android have http connection , got response xml/json etc.. parse data , processed view. here,in case of jquery , facing problem solve issue.. read ajax call using webservices. sample code $.ajax({ type: "post", contenttype: "application/json; charset=utf-8", url: "some url", data: "{}", datatype: "json", success: function (msg) { alert(msg); //$("#resultlog").html(msg); } }); also,i refer google api_place search, service entirely different referncelink click here ! does suggest proper way implement webservice interact server , retrieve json response? thanks in advance!

python - Modify DataFrame passed as argument -

i have timeseries dataframe (df) need add column, , pass df function modifies content of time slice of single column. idea follows: rng = pd.date_range('1/1/2011', periods=3, freq='h') df= pd.dataframe([0,0,0],columns=['a'],index=rng) df['b']=0 def v(dff,n): dff.loc[rng[0]:rng[1],:].b=n as far understand python argument passing, call v(df,n) should modify dataframe problem id not time. the following code demonstrates problem: v(df,1) print("ater first: ", df) v(df,2) print("after second: ", df) ('ater first: ', b 2011-01-01 00:00:00 0 0 2011-01-01 01:00:00 0 0 2011-01-01 02:00:00 0 0 [3 rows x 2 columns]) ('after second: ', b 2011-01-01 00:00:00 0 2 2011-01-01 01:00:00 0 2 2011-01-01 02:00:00 0 0 which surprising, because expect column b ether 0,0,0, or first 1,1,0, , 2,2,0. the things stranger if put single print(df) before first call v. c

python - Deadlock when creating index -

i try create index cypher query using py2neo 1.6.2 , neo4j 2.0.1: graph_db = neo4j.graphdatabaseservice() query = "create index on :label(prop)" neo4j.cypherquery(graph_db, query).run() the query works fine in neo4j web interface throws deadlock error in py2neo: py2neo.neo4j.deadlockdetectedexception: don't panic. a deadlock scenario has been detected , avoided. means 2 or more transactions, holding locks, wanting await locks held 1 another, have resulted in deadlock between these transactions. exception thrown instead of ending in deadlock. see deadlock section in neo4j manual how avoid this: http://docs.neo4j.org/chunked/stable/transactions-deadlocks.html details: 'transaction(15438, owner:"qtp1927594840-9525")[status_active,resources=1] can't wait on resource rwlock[schemalock]since => transaction(15438, owner:"qtp1927594840-9525")[status_active,resources=1] <-[:held_by]- rwlock[schemalock] <-[:waiting_for]- transacti

How to separate text and image in WordPress using foundation zurb -

i can't find solution how separate text , images page/post (not featured image) , put them in 2 separate columns using foundation, know how works in static website in wordpress. is there way text , image alone rather whole post. i want them in order. <div class="large-9"> texts here </div> and <div class="large-3"> image here </div> this template have html. http://dmd-winchester.org.uk/digihub/

vb.net - "System.NullReferenceException" while filling dictionary with keys from an array -

i have problem in code. here problematic snippet. reading of line work, @ point should fill zeilendict keys , values, throws "system.nullreferenceexception" , dont know why. did wrong in loop, or dictionary not right iniziated? or arr1 empty? module module1 public zeilendict dictionary(of string, integer) public insertdict dictionary(of string, string) public sub einlesen() form1.id = 0 form1.openfiledialog1.showdialog() form1.path = form1.openfiledialog1.filename form1.openfiledialog1.dispose() dim fs filestream = new filestream(form1.path, filemode.open, fileaccess.read) dim sr streamreader = new streamreader(fs) dim erstezeile = sr.readline() form1.arr1 = erstezeile.split(new char() {";"c}) sr.close() fs.close() dim integer = 0 form1.arr1.length - 1 form1.datagridview1.rows.add(form1.arr1(i)) next dim i1 integer i1 = 0 form1.arr1.length - 1 zeilendict.add(form1.arr1(i1),

javascript - Error : no response while calling php web service from java script -

i have script me calls php webservice $(document).ready(function(){ }); function sendpushnotification(id){ var data = $('form#'+id).serialize(); $('form#'+id).unbind('submit'); $.ajax({ url: "send_push_notification_message.php", type: 'get', regid: data, message: data, beforesend: function() { }, success: function(data, textstatus, xhr) { $('.push_message').val(""); }, error: function(xhr, textstatus, errorthrown) { } }); return false; } </script> sendpushnotification function: <?php require_once('loader.php'); $gcmregid = $_get["regid"]; // gcm registration id got device $pus

c# - How to load assembly dynamically by Assembly.Load in Windows phone 8? -

Image
now have problem, want load assembly dynamically depend on platform(x86,arm). create conditional compilation symbol _m_arm distinguish between x86 , arm. so use system.reflection.assembly.loadfrom(@"mp3/arm/mp3enclib.dll") , occur exception assembly.loadfrom not support on windows phone. so use method system.reflection.assembly.load(@"mp3/arm/mp3enclib.dll") , throw exception additional information: not load file or assembly 'mp3/arm/mp3enclib.dll, culture=neutral, publickeytoken=null' or 1 of dependencies. given assembly name or codebase invalid private void application_launching(object sender, launchingeventargs e) { #if _m_arm system.reflection.assembly.load(@"mp3/arm/mp3enclib.dll"); #else system.reflection.assembly.load(@"mp3/x86/mp3enclib.dll"); #endif } this solution anybody know how use method. or better way i believe must qualify assembly somecompany.somenamespace, version=1.0.0.0, cultu

Output not satisfactory in C program due to scanf function -

i executing program. on running program, first asks " enter number of test cases" , after enter number of test cases . after entering number of test cases cursor again in state of asking input user. don't know after giving number of test cases input why asking input . grateful? #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int i,n; char * arr[n]; printf("enter number of test cases\n"); scanf("%d \n",&n); printf("enter string\n"); for(i=0;i<n;i++) { arr[i]= (char *)malloc(100*sizeof(char)); scanf(" %s ",arr[i]); } for(i=0;i<n;i++) { printf("the enter string : %s \n",arr[i]); } for(i=0;i<n;i++) { free(arr[i]); } return 0; } thanks friends discussing question. got answer , real problem scanf function. got nice link read problem. hope it. http://c-faq.com/stdio/gets_flush2.html the

performance - Refresh web page taking too long time to load -

we developing single installer web application using following technologies. wcf - named pipe binding. javascript, jquery. signalr mvc4 we have published web application in iis 7.5 , os windows 7. here problem while running application 3 4 hours after can't in browser totally hanged. few things want share you, few cases hide , show html in dom instead of removing. event handling - binding events don't check if event mapped element. signalr 1 of doubt. because pooling frequently. right if stuck browser restart application pool.after comes under control. so, can please tell me why happening, might post not clear can outlook you use chrome profiler (in dev tools > profiles) potential memory leaks. common cause of memory leaks forgetting unregister event listeners when not required more. , mention binding, think it's lead follow.

ios - Importing external fonts to iPhone application -

Image
this question has answer here: custom fonts in ios 7 8 answers how can import external arabic , english fonts iphone application ? for importing custom fonts in ios app add .ttf or .otf font downloaded in application. modify plist file i.e. application-info.plist file. add key "fonts provided application" in new row. and add each .ttf or .otf file (of font) each line. and in label or textfield yourlabel.font = [uifont fontwithname:@"your_font" size:15];

performance - Matlab parfor, cannot run "due to the way P is used" -

i have quite time consuming task perform in loop. each iteration independent others figured out use parfor loop , benefit i7 core of machine. the serial loop is: i=1 : size(datacoord,1) %p matrix: person_number x z or p(i,1) = datacoord(i,1); %pn p(i,4) = datacoord(i,5); %or p(i,3) = predict(barea2, datacoord(i,4)); %distance (z) dist = round(p(i,3)); %round distance how many cells x = ceil(datacoord(i,2) / (im_w / ncell(1,dist))); p(i,2) = pos(dist, x); %x end reading around parfor, doubt had use dist , x indexes calculated inside loop, heard problem. error matlab way p matrix used though. how it? if remember correcly parallel computing courses , interpret correcly parfor documentation, should work switching for parfor . any input appreciated, thanks! unfortunately, in parfor loop, 'sliced' variables such you'd p cannot indexed in multiple different ways. simplest solution build single row, , make single assignment p

tsql - SQL - How to select a column alias from another table? -

i have table in sql data , table holds alias column. used translation purposes. i wondering how can select on columns retrieve alias table? this table holds real column names: id pageid colname order type width isdeleted 1 7 custtype 2 null null 0 2 7 description 3 null null 0 3 7 applyvat 4 null null 0 4 7 produceinvoices 5 null null 0 5 7 purchasesale 6 null null 0 6 7 termsdays 7 null null 0 7 7 datetimelastupdated 8 null null 0 this table holds alias (text): id colid userid text order enabled? 50 22 1 id 1 1 51 1 1 custtypes 2 1 52 2 1 description 3 1 53 3 1 applyvat null 0 54 4 1 produceinvoices null 0 55 5 1 purchasesale null 0 56 6 1 termsdays null 0 57 7 1 datetimelastupdated null 0 i believe need use dynamic sql this, e.g.: declare @sql

javascript - how to select the select box item based on another and vice versa -

how select select box item based on 1 , vice versa.here use ajax redirect query page. while($fet = mysql_fetch_assoc($sql1)) { echo "<option value=".$fet['username'].">".$fet['username']."</option>"; } echo '</select></td>'; echo "<td><div id='mydiv'><select id=id name=id onchange=loadxmldoc()>"; $sql = "select * sample"; $sql1 = mysql_query($sql); while($fet = mysql_fetch_assoc($sql1)) { echo "<option value=".$fet['id'].">".$fet['id']."</option>"; } echo '</select></div></td>'; you need use ajax that, example have select this <select id=id1 name=id1 onchange=loadxmldoc()> here second 1 want change <select id=id2 name=id2> on javascript call php file via ajax this function loadxmldoc(){ $.ajax({ // think used jquery on project