Posts

Showing posts from February, 2015

Mercurial commit and merge -

with mercurial see scenario need gradually commit push, if person commits in middle of problem. example: assume hg repo has 4 files a.txt, b.txt, c.txt, d.txt , have 2 users mickey , goofy: mickey does: $ echo "change1" >> a.txt mickey does: $ echo "change2" >> b.txt mickey does: $ echo "change3" >> c.txt mickey does: $ hg commit -m "i good" a.txt goofy does: $ hg pull -u; echo "change4" >> d.txt; hg commit -m "the donald change" mickey gets ready commit , push, has has merge: mickey does: $ hg pull -u now mickey has 2 changes - in b.txt , c.txt. lets assume changes in c.txt complex , cannot released now. how can mickey changes in a.txt , b.txt committed , pushed without committing c.txt yet? just issue filenames you're interested in committing: hg commit a.txt b.txt -m'partial commit' then push usual. edit: iyou try saving local changes patch, revert ...

How Camera starts in Android -

i understanding code flow of android camera available in android source code. can please tell me method in camera activity responsible invoke camera hardware when switch on camera home activity? i checked in camera.java(first activity called when user starts camera home) did not find suitable path. any appreciated. create intent launch camera application: private static final int camera_pic_request = 9999; // can intent cameraintent = new intent(android.provider.mediastore.action_image_capture); startactivityforresult(cameraintent, camera_pic_request); handle result got camera: protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == camera_pic_request) { bitmap thumbnail = (bitmap) data.getextras().get("data"); // picture taken } } to use camera in application need request special permission well. put manifest file: <uses-feature android:name="android.hardware.camera"...

Loading a module from the current directory in racket -

i have file euler.rkt in current working directory. how load module? -> (require euler) ; readline-input:20:9: euler: standard-module-name-resolver: collection not ; found: "euler" in of: (#<path:/home/ben/.racket/5.2.1/collects> ; #<path:/home/ben/racket/collects>) in: euler [,bt context] -> should add directory collects? if so, correct way it? try this: (require "euler.rkt")

sql - Get value for each date if not exist then take previous last updated value -

i have table have column employeeid, accountid,updated date. each row have data account if changes on date. if no change there no record accountid on date. example employeeid accountid updateddate 1775 1 2010-12-04 00:00:00.000 1775 1 2010-08-13 23:59:59.000 1775 1 2010-08-13 00:00:00.000 1775 2 2010-12-04 00:00:00.000 1775 3 2010-12-04 00:00:00.000 1775 4 2010-12-04 00:00:00.000 1775 5 2010-12-04 00:00:00.000 1775 6 2010-12-04 00:00:00.000 1775 7 2010-12-04 00:00:00.000 1775 7 2010-06-29 23:59:59.000 i have value of each account each person on each day . if there no value on current day should take last update value previous day based on max update date value. , show result like employeeid,date, values of each account. 1775;20120307;45;0;0;0;0;0;0;0;0;0;0;504;0;0;25.0;0.0;0.0;0.0;0.0;0.0;0.0;100;;;;; can 1 me? you can either create table of dates , left join against that, or create dates dynamically descri...

java - Delete records from table in many to many relationship? -

i using hibernate many many association. have 3 tables(student,course , student_course). among 3 tables 2 main tables , 1 table intermediate table providing relation ship. when record deleted student corresponding mapping deleted student_course. requirement should delete record course table. consider student_course entries below: s-id c_id 101 201 102 202 when 101 deleted form student table, first entry above table deleted record corresponding 201 in course table stays is. how can delete record? need execute delete query? many many relation ship not take care? below configuration: <set name="course" table="student_course" inverse="false" lazy="false" fetch="join" cascade="all" > <key> <column name="s_id" not-null="true" /> </key> <many-to-many entity-name="course"> <colu...

ruby on rails implement generic search -

i have 2 tables in db - "illness" table , "symptoms" table. i've implemented generic search searching both tables. goal display results in result page, each result should hyperlink leads result "show" page (illness/id/show or symptom/id/show). as i'm passing generic results result page, don't know whether current result illness or symptom. wonder best way information (should try collect informaiton in controller , somehow pass html? should somehow run query html?) i'm using rails 3.x, , controller code looks this: class searchcontroller < applicationcontroller def index @results = illness.search(params[:search]) + symptom.search(params[:search]) respond_to |format| format.html # index.html.erb format.json { render json: @results } end end end thanks, li you don't have worried it. let rails serve it: - @results.each |result| = link_to 'show...

ruby on rails - Could not find i18n-0.6.0 in any of the sources (Bundler::GemNotFound) -

could not find i18n-0.6.0 in of sources (bundler::gemnotfound) i getting error when trying run redmine using phusion passenger under rvm on osx lion. i have "redmine" , "global" rvm gemsets under ruby 1.9.3. "global" gemset contains passenger gem, other redmine specific gems in "redmine" gem set. there lot of similar posts on stack overflow deal ( 1 , 2 , 3 ), accepted answers, don't believe of them "correct" solution. how can overcome error while having passenger installed in global gemset please? checking first mentioned post there important part use wrappers: passengerruby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby the wrappers sets proper environment default ruby, using gemsets follow rvm integration instructions: https://rvm.io/integration/passenger/

objective c - What problems may cause setting nib file's owner to nil? -

if can load object nib file without using file's owner reason of existence of file's owner? outlet-action connections can created without use of file's owner. example can make connections directly object nib. again can't understand need file's owner. have relation mvc pattern? file's owner must of uiviewcontroller type? during loading of nib file, cocoa generates each object serialized in nib file. then, each connection in nib file, calls setvalue:forkey: on target object create connection. connections object nil . setvalue:forkey: messages sent whatever object passed file owner. if have no file owner, nil connections ignored. if have no nil connections, no different not having file owner. not particularly common. all of allows instantiate multiple instances of same nib file objects, passing different file owners to loading process. edit: remember, nib file bunch of serialized objects. when programmatically create view controller initw...

asp.net - LINQ driven cache items invalidation -

i'm making asp.net mvc project , implement business data caching @ repository (linq2sql) layer. since entities related each other, need invalidate related ones when i'm invalidating base entity. have blog/post/comments relation , when user makes new comment need invalidate cached post entity since has outdated totalcomments field. there more complicated logic invalidation other entities. well, need implement flexible invalidation mechanism purpose. i've found before: - sql notifications service. notifies app each time table has changed. since i'll have high-loaded application, changes on tables gonna often. cached comments post drop each time new comment added. - caching linq(or sql) queries. in case rendered query placed cache using hash key. not bad impossible drop "all comment entities having blogpostid = deletedblogpostid" and idea is. wanna use linq queries on httpruntime.cache items find items deleted properties (e.g. in case of deleting blog p...

ios - How to find out what eats up memory in Cocos2d -

Image
i developing game using cocos2d ios. there scenes menu , , main game scene. on main scene there 3 dynamic objects. these objects periodically shoot @ each other (until these objects killed or moved out of scene). now problem: game eats memory. , want find out doing wrong. there no obvious leaks over-retained objects. scene gets dealloc ed, objects gets removed parents , cleaned up, animations gets stopped etc. anyway, memory keeps going somewhere. using following code + (void) reportmemory { struct task_basic_info info; mach_msg_type_number_t size = sizeof(info); kern_return_t kerr = task_info(mach_task_self(), task_basic_info, (task_info_t)&info, &size); if (kerr == kern_success) nslog(@"memory in use (in kbytes): %f", info.resident_size / 1024.0); else nslog(@"error task_info(): %s", mach_error_string(ke...

sql - SQLITE: Show total (sum) for each category -

i have 2 tables (inputs , categories): create table categories ( iid integer not null primary key autoincrement, sname text not null, iparent integer, foreign key (iparent) references categories(iid) ); create table inputs ( iid integer not null primary key autoincrement, icategory integer, dvalue double not null, foreign key (icategory) references categories(iid) ); i need sums(dvalue column) inputs table each category. if sum result zero. if possible better if sum each parent category ( when categories.iid = categories.iparent , summing results of child categories parent category ) can me? appreciate help! thanks! try this: select c.iparent, sum(i.dvalue) categories c left outer join inputs on i.icategory=c.iid group c.iparent edit : accounts: select c.iparent, a.icurrency, sum(i.dvalue) categories c left outer join inputs on i.icategory=c.iid left outer join accounts on i.iaccount=a.iid group c.iparent,a.icurrency

How do I get HTML 5 video player to play my video on PC Firefox? -

i'm using win xp, service pack 3. have m4v video i'm trying embed in web page using html 5 video player found here -- http://videojs.com/ . when view page through apache 2.2, video plays fine on chrome , ie 7, not on firefox (just black square without video controls) ... <!doctype html> <html> <head> <link href="css/video-js.css" rel="stylesheet" /> <script src="js/video.js"></script> </head> <body> <video id="my_video_1" class="video-js vjs-default-skin" controls preload="auto" width="960" height="540" poster="css/video-js.png" data-setup="{}"> <source src="videos/unpacking_w_students.m4v" type='video/m4v'> </video> </body> </html> any ideas may going wrong? if there additional things add web page firefox play it, ideal, if there other setting adjust, great know we...

java - How to make J2EE weblogic application resilient to database problems -

i have web application running on oracle weblogic server 11g . uses datasource defined in application server connect oracle database (11g too), class oracle.jdbc.xa.client.oraclexadatasource if reason database becomes not present , comes backs, application running ok (it gets exceptions while trying access db fine , can again new connections when db comes back) however, if database down during weblogic server startup , the datasource not deployed on server , application throws exception because has not datasource available, deployment marked failed , of course nothing repair automatically. is there way make datasource deployed if database not present during server startup ? (such application becomes usable when database back) why want deploy application without valid datasource? you possibly fake datasource (create dummy datasource same jndi name) , assuming application not validate datasource schema @ startup semi-functional running application (which fai...

forms - Accepting login number with changing prefix with PHP -

i have flatfile database file following numbers: 1 2 3 4 5 etc. the numbers correspond user id person enter of numbers above, in order login. i not want modify file. question is, if there's way add accepted "prefix". for example, user logs in with: abcd1 abcd2 abcd3 abcd4 abcd5 etc. but data file still, not contain prefix "abcd": 1 2 3 4 5 etc. it have "perfect" match. tests have done far have not been conclusive i guess using accepted "array" way go? my present login php script this, only works on exact match number, add prefix can change later on: <?php date_default_timezone_set('america/new_york'); $today = mktime(0, 0, 0, date("m"), date("d"), date("y")); $currenttime = date('h:i:s:u'); list($hrs,$mins,$secs,$msecs) = split(':',$currenttime); echo "<center><form action=\"" . $php_self . "\" method='post'><i...

c# - How to use a Resource Image in Word document? -

i'm working on project auto-generate word , html reports. if don't provide image use in header of word report, customer wants use logo. have logo stored in resources of 1 of projects .jpg. the method add picture range needs path string image, without overloads. know when file added resources of project, doesn't exist gets embedded inside .dll gets created. there no way utilize embedded resource in method? do need copy file part of install directory? i'm thinking may easiest solution, should testing purposes? i making lot harder needed be. all have make image object resource: image img = data.properties.resources.imagefile; then after that, have save it: img.save(@"c:\destinationfolder\image.jpg"); now have file use want. won't matter if you're in debugging or not (as far application.run location) in event have in subfolder in project (as should), wouldn't have in same path @ end. i way over-thinking other day when...

ios - UIGraphicsBeginImageContext wasteful? -

is not wasteful there requirement if want draw uiimage, has new uiimage created uigraphicsbeginimagecontext? if frequent drawing needs happen, why not let draw preexisting uiimage? or there way already? this because uiimage not mutable. if rendering new cgbitmapcontext , doing wrong in application.

Multiple conditions php/mysql -

i'm working on multi critera search on php/mysql, search has 5 entries: - type, price min - price max , qty min - qty max : $type = $_post['type']; $pmin = $_post['pmin']; $pmax = $_post['pmax']; $qtmin = $_post['qtmin']; $qtmax = $_post['qtmax']; $query = "select * products type_product='$type' , price_min<='$pmin' , price_max>='$pmax' , qty_min<='$qtmin' , qty_max>='$qtmax' " ; this works fine, user have fill entries. , idea user can enter type, or type , price, or qty , .. tried use or clause didn't make work well. where (a = '$a' or '$a' = '') , (b <= '$b' or '$b' = '') , (c >= '$c' or '$c' = '') notice if variable empty string, condition satisfied.

java - Fixing the maximum size of a JList and changing the look of empty cells -

i'm working on ui stuff jlist can contain @ 8 items. logically have prevented application adding jlist once has reached it's limit, however, wondering if there way perhaps explicitly set limit on jlist itself. next thing want do, repaint empty cells (up 8 cells @ most) indicate empty slots can filled. i'm trying find way (perhaps extending listui) not involve adding placeholder elements jlist represent empty spaces. i think simple way implement list model (using defaultlistmodel or abstractlistmodel) idea model have 8 items. of them empty message. if add new item model can replace empty text specific text item. model keep track how many items added model. if try add more max_items can thow exception or that. implement defaultlistmodel easy , have lot of samples on internet.

css - changing fill colors when combo box is disabled -

i've been stuck on problem few days. solution seems simple, haven't found 1 yet. i'm working flex 3, , i'm trying change color of combobox when disabled lighter. current css this: combobox { color:#000000; fillaphas: 1, .5, .55, .35; fillcolors: #ffffff, #cccccc, #999999, #666666; fontweight: normal; backgroundalpha: 1; fontsize:11; } the problem when use backgrounddisabledcolor property, enabled disabled combo boxes altered new color. there way set disabled fill color property, or somehow turn off fill colors when combo box disabled? thanks. ** seeing not change fill colors disabled combobox directly css property, , flex 3 not css attribute selectors, added property link skin when disabled , made combobox skin lighter colors. seemed best option. thank help. did try setting disabledcolor style ? i pretty sure component disabled, visually, drawing semi transparent graphic on top of it. i'm not sure i'd recommend trying change background co...

objective c - add/hide UITabBarItem -

i have uitabbarcontroller , add tab, ability make disappear. added 2 tabs xcode. can add third tab program? know command like: [self setviewcontrollers: [nsarray arraywithobjects: x1, nil] animated: no]; you can retrieve array uses xcode add third view? thanks i can not load view code. created view controller storyboard, when try load code black screen, use code: viewcontrollera *x1 = [[viewcontrollera alloc] init]; [self setviewcontrollers:[nsarray arraywithobjects: x1, nil] animated:no]; yes, if use [uitabviewcontroller setviewcontrollers: animated:] can add in array containing 2 previous view controllers plus new third one. for example, you'd want this: // assuming you've set iboutlet tab bar controller nsarray * currentsetofviewcontrollers = [apptabbarcontroller viewcontrollers]; if((currentsetofviewcontrollers == null) || [currentsetofviewcontrollers count] == 0)) { nslog( @"i don't see view controllers; tab bar controller outlet ...

ios - Add Developers in Xcode -

assume have xcode project running on github , multiple developers. have new developer clone git repository , start working on app. want add ios devices devices can run builds without having reissue certificates , long process on ios dev center. how can that? want him clone repo, connect device xcode , able run app on device. thanks if paid ios developer , there no reason use specific provisioning profile won't need anything. xcode can automatically provision device when compiles it. use automatic profile selection development builds in build settings. if important both use correct provisioning profile (for example test push notifications) there no way around adding device profile on developer portal. plus need let him sign binary you, using developer certificate , private key (which have export keychain on development machine).

object - Python TypeError in traversing a list -

i'm teaching myself python 3.2 , i'm trying make program match list of names. plist multidimensional list string @ column 0, integer @ column 1, , boolean @ column 2. however, whenever try , call function (which runs if number of rows in list even), typeerror. traceback (most recent call last): file "c:\users\metc\dropbox\assassins.py", line 150, in <module> main() file "c:\users\metc\dropbox\assassins.py", line 11, in main update(ops, plist) file "c:\users\metc\dropbox\assassins.py", line 125, in update b = match(plist) file "c:\users\metc\dropbox\assassins.py", line 47, in match q, p = 0 typeerror: 'int' object not iterable any appreciated, keep in mind i'm beginner language, gentle. :) don't mind if technical though; have experience computer science. def match(plist): b = [] z = len(plist)-1 x in range(z): b.append([plist[x][0],0]) x in range(z): isvalid = false ...

.net 3.5 - Creating a com object with another com object in C# -

this follow previous question. i'm trying convert vb.net code c#. com object created (atldirectorobject.atldirector) , used create com object (atl3270tool) parameter. atl3270tool not getting created in c# version. going wrong route trying reference atl3270tool through object array? 'working vb code dim atl3270tool dim errmsg string dim atldirectorobject = createobject("atldirectorobject.atldirector") atldirectorobject.createtool("3270", 1, true, true, 0, atl3270tool, errmsg) 'atl3270tool working com object @ point = success //non-working c# code object atl3270tool = null; string errmsg = null; object atldirectorobject = activator.createinstance(type.gettypefromprogid("atldirectorobject.atldirector")); //atldirectorobject com object //attempt reference atl3270tool inside object array object[] p = { "3270", 1, true, true, 0, atl3270tool, errmsg }; microsoft.visualbasic.compilerservices.newlatebinding.latecall(atldirectorobject, n...

c# - Creating Set of sequnces(12345678) -

i create set of strings , below limitation. same digit should not repeat. string range 1-8(12345678) or 1-16(12345678910111213141516) example:(set of series) 12345678 12345687 12345876 12345867 ... ... 87654321 like 2^8(1-8) , 2^16(1-16) possibilities there. how can generate these strings efficiently less computation? your 8 case possible run out of space after that. this not 2^n case think -- it's n! case. for 8, there 40,320 permutations. permute(k,n) = k! / (n-k)! permute(8,8) = 8! / (8-8)! = 8! = 40320 for 16, there 20,922,789,888,000 permutations. @ 16 bytes / permutation, you'll need 304tb store them. @kol's answer should permutations think need change requirements.

Move File within Vim -

is there way move file within vim? e.g. opened file foo/bar.txt in vim. know 2 ways move file: first solution: delete buffer :bd bar.txt perform move on shell mv foo/bar.txt foo/bar2.txt load file in vim :e foo/bar2.txt second solution: close vim, buffer closed. perform move on shell... start vim , load file. but these 2 solutions embarrassing. know, there plugin renaming files vim-enuch , isn't there vim way performing such basic functionality? there no atomic way move file that, should close: function! movefile(newspec) let old = expand('%') " improved: if (old == a:newspec) return 0 endif exe 'sav' fnameescape(a:newspec) call delete(old) endfunction command! -nargs=1 -complete=file -bar movefile call movefile('<args>') now say: :movefile file2.txt to rename file2.txt :movefile %.0 to move file2.txt file2.txt.0

CMake: custom target's flags -

how can write cmakelists.txt in way has 2 targets all (default) , test , test target has flags differ all target's flags. problem when build libraries tests need link stuff shouldn't in release build. cmake_minimum_required(version 2.8.0) project (rootproject) option(build_testing "build tests." off) if(build_testing) # custom compiler option add_definitions(-zc:wchar_t-) endif(build_testing) add_subdirectory(lib1) add_subdirectory(lib2) add_subdirectory(lib3) add_subdirectory(lib4) add_subdirectory(bin) if(build_testing) # more custom compiler option tests add_definitions(-zc:wchar_t-) add_subdirectory(testlib1) add_subdirectory(testlib2) add_subdirectory(testbin) message( status "testing folders have been added." ) endif(build_testing)

Test if a link is Opengraph friendly -

i have website extract opengraph metadatas links in database.. , have create verify code check if link user sending through submit box website database opengraph friendly. need kind of test in link , see if has @ least meta property="og:image" on source code, , avoid submission of links not work properly. i’m using recaptcha avoid spammers , thinking use same verify code of recaptcha opengraph test. have idea of how can this? i need kind of test in link , see if has @ least meta property="og:image" on source code well, should obvious means reading source code of page, , meta element. wether want read first x bytes of ressource (that’s fb afaik), , perform string/regexp search, or if want use html parser on , in dom, that’s decision make … first maybe little more error-prone, while second means more complexity.

Intellij IDEA, build artifact using Ant? -

Image
i might missing something, have been struggling problem time now. i have web application ant build script. set artifact module, (which .war file, generated using ant), deploy war file, configured tomcat server. but not able figure out, how make intellij use ant script build artifact. see option run ant targets, runs ant target , intellij proceeds generate artifact, in usual way. please let me know if question ambiguous. problem not ant integration intellij. use ant window , run target , make ant target run part of build. problem associate artifact module , leverage ant script build artifact. need enable, tight tomcat integration, since while integrating tomcat server, can specify artifact deployed. note: intellij idea version 11.1 idea can either deploy artifact or external source (directory or file) built ant or other tool: it's not possible associate idea artifact ant build.

openjpa - JPA: load a related entity from another persistence context? -

i have entity called route, has related entity called employee: public class route { @manytoone private employee driver; // more fields... } public class employee { // more fields... } these 2 entities stored in different databases. so, live in 2 different persistence contexts. because of that, when load route entity, "driver" field null. is possible load route , automatically fetch "driver" field somehow? no, it's not possible. how jpa execute such basic query? select r route r r.driver.name = :name you'll have store id of driver in route entity, load explicitely, , hope it's there (because don't have foreign key constraint).

subprocess - Python and environment variables -

in following code snippet (meant work in init.d environment) execute test.classpath. however, i'm having trouble setting , passing classpath environment variable defined in user's .bashrc. here source of frustration: when below script run in use mode, prints out classpath ok (from $home/.bashrc) when run root, displays classpath fine (i've set /etc/bash.bashrc classpath) but when "sudo script.py" (to simulate happens @ init.d startup time), classpath missing !! the classpath quite large, i'd read file .. $home/.classpath #!/usr/bin/python import subprocess import os.path osp import os user = "username" logdir = "/home/username/temp/" print os.environ["home"] if "classpath" in os.environ: print os.environ["classpath"] else: print "missing classpath" proclog = open(osp.join(logdir, 'test.log'), 'w') cmdstr = 'sudo -u %s -i java test.classpath'%(...

c - Heap sort using linked lists -

i wondering if has ever used linked lists heap sort , if have provide code. have been able heapsort using arrays, trying in linked lists seems unpractical , pain in know where. have implement linked lists project im doing, appreciated. also using c. the answer "you don't want implement heap sort on linked list." heapsort sorting algorithm because it's o(n log n) , it's in-place. however, when have linked list heapsort no longer o(n log n) because relies on random access array, not have in linked list. either lose in-place attribute (but needing define tree-like structure o(n) space). or need without them, remember linked list o(n) member lookup. brings runtime complexity o(n^2 log n) worse bubblesort. just use mergesort instead. have o(n) memory overhead requirement.

javascript - Add style to element from user input -

i have basic generator border radius, user types in number of choice , inserts number preview code. want have preview box changes according number have inserted. half way there can't seem figure out last bit. html: <label>border radius:</label> <input name="border-radius" id="jj_input" class="jj_input" type="text" size="2" value='' onkeyup='changeradius()' /> <span>px</span> <div class="yourcode"> <p>border-radius: <span id="radius"></span>px; </p> <p>webkit-border-radius: <span id="radius2"></span>px; </p> </div> <div id="preview"> <span class="preview_text">preview text</span> </div> javascript: function changeradius(){ var jj_input = document.getelementbyid('jj_input').value; document.getelementbyid('radius...

c - possible memory leak by returning "local" heap-allocated object -

int do_memory() { int * empty_ptr = (int *) malloc(sizeof(int)); *empty_ptr = 5; return *empty_ptr; } ... int b = do_memory(); free(&b); //obviously not valid when b goes out of scope, right in assuming memory in empty_ptr still exists? impossible free , therefore bad code? the "int *empty_ptr" (the pointer allocated memory block) never released, return value do_memory. if want no leaks, use this int* do_memory() { int * empty_ptr = (int *) malloc(sizeof(int)); *empty_ptr = 5; return empty_ptr; } ... int* b = do_memory(); int b_local = *b; free(b); // valid or (no leaks, no allocations except var on stack, no performance hit): void do_memory(int* retvalue) { *retvalue = 5; } ... /// b allocated locally on stack int b; do_memory(&b); // no free() calls needed

java - Spinner not a view that can be bounds(sp) by this SimpleCursorAdapter -

i'm trying adapt query spinner object trouble, error listed title. here code portion crashes: spinner classdropdown = (spinner) this.findviewbyid(r.id.classdropdown); int[] = new int[] { r.id.classdropdown }; string[] classfields = new string[] { "classname" }; simplecursoradapter cursoradapter = new simplecursoradapter(this, r.layout.main, cursor, classfields, to); cursoradapter.setdropdownviewresource(r.id.classdropdown); classdropdown.setadapter(cursoradapter); i had problem cursor wasn't being filled fixed now. can give me on debugging issue? edit: think problem "to" field. should be? edit 2: also, here xml spinner object: <spinner android:id="@+id/classdropdown" android:layout_width="match_parent" android:layout_height="wrap_content" /> edit 3: i've fixed above reflect fixing code. fixes particular problem. i'm not getti...

php - seeking advise for a mobile client-server application strategy -

i'm seeking advice regarding following plan have future project of mine. the big picture i want produce mobile client (ios, android, windows phone, etc.) query (read/write) database website , display results. plus several other features... i know directly accessing database (bypassing web server) client bad idea on internet. think shared webhosting plans prohibit anyway. here intended solution... mobile client sends data webserver through api call. the webserver processes rest api call , queries database. webserver works middleware between mobile client , database server. the webserver receives results db queries , passes them mobile client. mobile client displays/manipulates data on client-side. my experience apis limited consumption of twitter, instagram, , google shopping apis. experience, seems best transport data between mobile , webserver in json format. now, here concerns... how can ensure logged-in users can use api? oauth solution? for rest api,...

Exploding array values in PHP -

i'm working on script connects server using proxies, going through list until finds working proxy. the list of proxies this: 127.0.0.1:8080 127.0.0.1:8080 127.0.0.1:8080 127.0.0.1:8080 127.0.0.1:8080 127.0.0.1:8080 127.0.0.1:8080 of course, it's not same ip , port on , over. now, going use file() put them array, leaves array values including full line, obviously. ideally i'd array like "127.0.0.1" => 8080, "127.0.0.1" => 8080, "127.0.0.1" => 8080, "127.0.0.1" => 8080, "127.0.0.1" => 8080, "127.0.0.1" => 8080, "127.0.0.1" => 8080, "127.0.0.1" => 8080, but i'm not sure of easiest (and efficient) way that. suggestions? loop on file , parsing: $path = './file.txt'; $proxies = array(); foreach(file($path, file_skip_empty_lines) $line) { $proxy = trim($line); list($ip, $port) = explode(':', $proxy); $proxies[$ip] = $por...

Android, clear X amount of Activities from the activity stack -

how can clear variable number of activities activity stack? lets want clear 3 activities, won't use android:nohistory in manifest, won't use method clear whole stack and maybe call finish(); finish(); finish(); under condition, doesn't seem right. is there known method this? you register broadcastreceiver in classes want finish, send broadcast when want finish them.

iphone - iOS: static sectionHeaderView for tableView -

background: have implemented standard tableview has 4 sections. each of section contains custom view header. normally, previous header pushed away when header below scrolled top of tableview. question: possible prevent "pushed out" behavior. along line of "stacking" behavior. because user have full view of headers available. example, if 1 scroll lowest cell, 1 see headers on top of tableview. additional info: please not answer hacks, example, track movement of tableview, add header view manually when needed, resize tableview. it's not possible without using methods describe. @ least not built-in table view. one reason doesn't scale arbitrary content. if let section headers stack should happen when entire screen full of headers? how user able comfortably see , interact content under 6th or 7th section when there few pixels left show content because rest of screen taken header sections user not interested in. you want rethink ui. either...

apache - Reference: mod_rewrite, URL rewriting and "pretty links" explained -

"pretty links" requested topic, explained. mod_rewrite 1 way make "pretty links", it's complex , syntax terse, hard grok , documentation assumes level of proficiency in http. can explain in simple terms how "pretty links" work , how mod_rewrite can used create them? other common names, aliases, terms clean urls: restful urls, user-friendly urls, seo-friendly urls, slugging, mvc urls (probably misnomer) to understand mod_rewrite first need understand how web server works. web server responds http requests . http request @ basic level looks this: get /foo/bar.html http/1.1 this simple request of browser web server requesting url /foo/bar.html it. important stress not request file , requests arbitrary url. request may this: get /foo/bar?baz=42 http/1.1 this valid request url, , has more nothing files. the web server application listening on port, accepting http requests coming in on port , returning response. web server entirely...

javascript - How do I set the focal node in a D3.js Force Directed Graph? -

i have data set defines number of nodes use in force directed graph. looks like... var nodeset = [ {id: "n1", name: "node 1", type: "type 1", hlink: "http://www.if4it.com"}, {id: "n2", name: "node 2", type: "type 3", hlink: "http://www.if4it.com/glossary.html"}, {id: "n3", name: "node 3", type: "type 4", hlink: "http://www.if4it.com/resources.html"}, {id: "n4", name: "node 4", type: "type 5", hlink: "http://www.if4it.com/taxonomy.html"}, {id: "n5", name: "node 5", type: "type 1", hlink: "http://www.if4it.com/disciplines.html"} ]; how tell force.layout in d3.js library use "node 1" of id = "n1" primary root or focal node? if want root node can have root property in object , set true, treat node separately. can set root center. he...

data binding - Knockout Cart Editor Example questions : extending cascading drop-downs with nested arrays and functions -

here's my fiddle attempt combining code on knockout cascading cart editor live example on knockoutjs.com site, , rp niemeyer's example of data binding nested arrays try , achieve cascading cart extended product options in functional format given niemeyer. why doesn't quantity field update subtotal? why doesn't 'remove' work? why formatcurrency(price) produce 'unable parse bindings' error? why happen changing product field doesn't update price if 'add product' button pressed change appear in next line? in niemeyer's example 'add-product' , methods inside scope of functions rather cartline, copied 'subtotal' method - better place handle these operations? thanks work of s.sanderson, r.p.niemeyer, j.papa incredible effort in community promote knockout. it's awesome! alright, fiddle bit more complicated needs be, have tried leave structure alone in case planning expand. have few questions though, i...

c# - Roslyn CTP - How to Write Changes To File System -

i created empty visual studio solution called solution.sln load workspace int first line. add project solution, , update workspace latest solution should contain project. how write out files new stuff added empty solution? using system; using system.collections.generic; using system.linq; using system.text; using roslyn.compilers; using roslyn.compilers.csharp; using roslyn.services; namespace roslynmainapp { class program { static void main(string[] args) { iworkspace workspace = workspace.loadsolution(@"c:\roslynsolutions\solution.sln"); projectid projectid; isolution solution = solution.create(solutionid.createnewid("solution")); solution.addcsharpproject("project1.dll", "project1", out projectid); var success = workspace.applychanges(workspace.currentsolution, solution); if(success) { //how write out stuff ...

matlab - Solving non linear equations related to distance -

i want solve set of non linear equations in matlab. mean lets have 2 points defined (lat1,lon1) , (lat2,lon2). want find point lat3,lon3 such @ distance of 20km both of points. given intersection of circles radius 20km drawn points (lat1,lon1) , (lat2,lon2) center. however, bit confused how solve equation. i have function calculate distance between 2 points in matlab function [ distance ] = calculatedistance( latitude1,longitude1,latitude2,longitude2 ) radius = 6371; dlat = degtorad(latitude2-latitude1); dlon = degtorad(longitude2-longitude1); = sin(dlat/2) * sin(dlat/2) + cos(degtorad(latitude1)) * cos(degtorad(latitude2)) * sin(dlon/2) * sin(dlon/2); c = 2 * atan2(sqrt(a), sqrt(1-a)); distance = radius * c; end and trying use solve function of matlab available @ http://www.mathworks.com/help/toolbox/symbolic/solve.html however when define syms lat3 lon3 and try equations pass solve function throws error atan2 accepts arguments of type sym . how can on this? ...

mongodb - pymongo: Best way to query by reference? -

i have bunch of paper documents in papers collection. each paper has 1 dbref person document. person property in paper document dbref correct person person {'name' : 'person a', 'slug' : 'pa'}, {'name' : 'person b', 'slug' : 'pb'} paper {'name' : 'paper 1', 'person': dbref}, {'name' : 'paper 2', 'person': dbref}, {'name' : 'paper 3', 'person': dbref} i create query returns papers reference person (slug=='pa'). tried filtering in query, , failed @ map reduce statement. best way handle in pymongo? this query returns no results for paper in db['papers'].find({'person.slug' : 'pa'}): print paper map reduce returns 0 results mapper = code(""" function () { if (this.person.slug == slug) { emit (this, 1); ...

java - Cannot run a 64-bit JVM in 64-bit Windows 7 with a large heap size -

this 64-bit windows 7 enterprise , 64-bit java 7: java version "1.7.0_04" java(tm) se runtime environment (build 1.7.0_04-b20) java hotspot(tm) 64-bit server vm (build 23.0-b21, mixed mode) this happens using shell of both c:\windows\systemwow64\cmd.exe (which incorrectly thought 64-bit version) and c:\windows\system32\cmd.exe (which have found out, courtesy of pulsar, 64-bit application despite path name). the program trivial: public class trivial { public static void main(string[] args) { system.out.println("total = " + tomb(runtime.getruntime().totalmemory())); system.out.println("max = " + tomb(runtime.getruntime().maxmemory())); } private static long tomb(long bytes) { return bytes / (1024l * 1024l); } } i fooling around different -xmx , -xms arguments see happen. have though 64-bit java on 64-bit windows use pretty whatever size max , initial heap wanted, that's not what's happen...

python - Installing Numpy locally -

i have account in remote computer without root permissions , needed install local version of python (the remote computer has version of python incompatible codes have), numpy , scipy there. i've been trying install numpy locally since yesterday, no success. i installed local version of python (2.7.3) in /home/myusername/.local/, access version of python doing /home/myusername/.local/bin/python . tried 2 ways of installing numpy: i downloaded lastest stable version of numpy official webpage, unpacked it, got unpacked folder , did: /home/myusername/.local/bin/python setup.py install --prefix=/home/myusername/.local . however, following error, followed series of other errors (deriving one): gcc -pthread -shared build/temp.linux-x86_64-2.7/numpy/core/blasdot/_dotblas.o -l/usr/local/lib -lbuild/temp.linux-x86_64-2.7 -lptf77blas -lptcblas -latlas -o build/lib.linux-x86_64-2.7/numpy/core/_dotblas.so /usr/bin/ld: /usr/local/lib/libptcblas.a(cblas_dptgemm.o): relocation r_x86...

Add a variable to the stack in x86 assembly -

i wonder, how set local variable in asm's procedure ? thanks!! if want store variable on stack, need reserve space it, done sub esp,xxx sequence, xxx size of "variable" want make space for, aligned stack alignment (generally 4 bytes, can 8 or 16). exception rule when variable in register, in case can perform push on register. this space needs cleaned on function exit, if push ed register, should pop or, add esp,xxx xxx size sub 'ed/the size of register push ed aligned stack size. reading , writing done using mov , gets little tricky, have 2 cases, stack frames, , without stack frames. without stack frames requires more math, need compensate function arguments on stack, if our function takes 2 args, , allocate space integer on stack, can write via mov [esp + 0xc],value , reading same mov eax,[esp + 0xc] . with stack frame, arguments take positive index ebp , allocated memory negatively indexed ebp , same example above, you'd mov eax,[e...

validation - jQuery : validate date -

i using jquery validation plugin ' jquery.validation.js ' validate date data type in ' date_of_birth ' field i want display custom message above " date_of_birth " filed ' age should minimum of 16 ' . so have written following customised validation code : {literal} jquery.validator.addmethod("dob", function (value, element) { var startdate = $('#date_of_birth').val(); var findate = 01/03/2012 var age=date.parse(findate)-date.parse(startdate); if (age >= 16){ return false; } else { return true; } }, "age should minimum of 16"); {/literal} custom validation rules: rules: { date_of_birth: { dob: true } } but sad part it's not working. please me out... thanks in advance. $.validator.addmethod("dob", function() { var mindate = new date(); mindate.setfullyear(mindate.getfullyear() - 16); var dob = $('#date_of_birth').val(); ...

sql - How to get only column names as the following sample? -

currently, have string of column names below (this string computed in stored pro, , column name got several tables): @str = 'select fieldname1, fieldname2, fieldname3' in stored, how can return datatable no data , @str list of column name? tried query that: exec (@str) but requires table it. don't want put table because query data, , take long time finish. put 'null' in front of each column name, in: select null fieldname1, null fieldname2, null fieldname3

Can i get path from url i give in jquery? -

i want path name after request url setting. let put http://www.abc.com then server auto return me http://www.abc.com/sessionid/folder/default.aspx and need return url in jquery. got anyway this? i try ajax get/post response header location , null value. is reference code show @ below $.ajax({ type: 'post', url: '/echo/html', data: {}, datatype: "json", success: function(res,status,xhr) { //var location = xhr..getresponseheader('location'); alert(xhr.getresponseheader('content-type')); alert(xhr.getresponseheader('location')); }, error: function(jqxhr) { } });​ var result = 'http://www.abc.com/sessionid/folder/default.aspx', request = 'http://www.abc.com'; console.log(result.substring(request.length)); // /sessionid/folder/default.aspx http://jsfiddle.net/zerkms/znn4d/

c# - Passing querystring parameters without using OData conventions? -

is there way pass querystring parameters asp.net mvc4 web api controller without using odata conventions outlined here? http://www.asp.net/web-api/overview/web-api-routing-and-actions/paging-and-querying i have repository methods built using dapper don't support iqueryable , want able manually paginate them without using odata conventions, whenever try doing traditional asp.net way "route not found" errors. for instance, here's route: context.routes.maphttproute( name: "apiv1_api_pagination", routetemplate: "api/v1/{controller}/{id}", defaults: new { area = areaname, controller = "category", offset = 0, count = 100}); and here's signature match public class categorycontroller : apicontroller { // /api/<controller> public httpresponsemessage get(int id, int offset = 0, int count = 0) and whenever pass following query: http://localhost/api/v1/category/1?offset=10 i fo...

Aspect Ratio Stretching in OpenGL -

Image
i having trouble full screen mode. can set window 800x600, when full screen resolution, stretches. assume because of change in aspect ratio. how can fix this? edit #1 here's screen shot of see happening. left: 800x600 right: 1366x768 edit #2 my initgraphics function gets called every time re-size window (wm_size). void initgraphics(int width, int height) { float aspect = (float)width / (float)height; glviewport(0, 0, width, height); glenable(gl_texture_2d); glenable(gl_blend); //enable alpha blending glblendfunc(gl_src_alpha, gl_one_minus_src_alpha); glclearcolor(0.0, 0.0, 0.0, 1.0); glmatrixmode(gl_projection); glloadidentity(); gluortho2d(0.0, width, height * aspect, 0.0); glmatrixmode(gl_modelview); } solution: real problem ended being misusing gluortho2d function. instead of using this: gluortho2d(0.0, width, height * aspect, 0.0); you needed switch correct form this: gluortho2d(0.0, width, 0.0, height)...

gmail - Is there any documentation for read-only access to the Google Contacts API? -

i want read-only access user's google contacts. there stackoverflow member wanted this, , received following answer : yes, there is, use https://www.googleapis.com/auth/contacts.readonly scope , "view contacts". this exchange reference read-only access google contacts can find using google. simply using access token obtained attempt read usual google contacts api (i.e. https://www.google.com/m8/feeds ) fails insufficient permissions. similarly, using google contacts api on new target fails 404 errors (for example https://www.googleapis.com/auth/contacts.readonly/default/full ). is there documentation anywhere on how use api, or permissible way access google contacts api full read-write access?

MongoDB PHP insert into sub-array -

ok, not sure if mongodb can this, need following json inserted currency db. the part want update exchangehistory, need keep history of exchange rates day. , next day e.g. for e.g {"from":"usd","currentexchange":[{"to":"nzd","rate":"1.3194","updated":"6\/5\/20121:38am"},{"to":"kwd","rate":"0.2807","updated":"6\/5\/20121:38am"},{"to":"gbp","rate":"0.6495","updated":"6\/5\/20121:38am"},{"to":"aud","rate":"1.0228","updated":"6\/5\/20121:38am"}],"exchangehistory":{"6\/5\/2012":[{"1:38am":[{"to":"nzd","rate":"1.3194","updated":"1:38am"}]},{"1:38am":[{"to":"kwd","rate":"0.2807",...

amazon ec2 - Not able to connect through browser port 8080 -

i launched amazon ec2 t1.micro free usage tier instance. after creating private key-pair did following on mac (local machine) ec2-authorize default -p 22 ec2-authorize default -p 8080 ec2-authorize default -p 80 but not able connect port 80 or 8080. connection timed out error. on port 8080, run mulgara rdfstore. access using http://$publicdnsname:8080 my .profile looks like: export ec2_home=~/.ec2 export path=$path:$ec2_home/bin export ec2_private_key=pk-mykeyname.pem export ec2_cert=cert-mykeyname.pem export java_home=/system/library/frameworks/javavm.framework/home/ please help ah. fixed problem. allowing access default security group. instead should have used group created aws @ launch thanks!!

node.js - Strange issue with ActionScript 3 -

i have created sample flash-air fb application node.js rest api. call these rest api's through action script. since updated application on fb getting following strange behavior. as3 function: here 2 lines should make post request url request.url = "http://sample.com:3137/getdata"; request.method = urlrequestmethod.post; =================================================================== node.js function: here lines of code in node.js app.post('/getdata', function(req, res){ //res.send(req.params.paramtest); res.send("sending data"); }); app.get('/:methodname', function(req, res){ //res.sendfile('index.html'); res.send("in "+req.params.methodname); }); ============================================================================ here problem whenever call "/getdata" post request in as3 goes " app.get('/:methodname' " instead of " app.post('/getdata', ...