Posts

Showing posts from June, 2013

knockout.js partial mapping from json -

on knockout.js site's documentation when data server can this: // every time data received server: ko.mapping.fromjs(data, viewmodel); i'd partially map data object model. possible? i have viewmodel.jobs[i].jobtype child object, i'd this: ko.mapping.fromjs(data.jobtype, viewmodel.jobs[i].jobtype); ... meaning i'd map in jobtype result server specific job's jobtype field. ... keeping in mind: // not work because viewmodel.jobs[i].jobtype() not function. viewmodel.jobs[i].jobtype(data.jobtype); this worked: ko.mapping.fromjs(data.job, viewmodel.jobs[i]);

Bash: Two conditions in if -

i'm trying write script read 2 choices, , if both of them "y" want "test done!" , if 1 or both of them won't "y" want "test failed!" here's came with: echo "- want make choice ?" read choice echo "- want make choice1 ?" read choice1 if [ "$choice" != 'y' ] && [ "$choice1" != 'y' ]; echo "test done !" else echo "test failed !" fi but when answer both questions "y" it's saying "test failed!" instead of "test done!". , when answer both questions "n" it's saying "test done!" i've done wrong ? you checking wrong condition. if [ "$choice" != 'y' ] && [ "$choice1" != 'y' ]; the above statement true when choice!='y' , choice1!='y' , , program correctly prints "test done!" . the corrected script is echo "- want mak...

sql - I want to join tables but still receive results from one table even if the other table has no results -

i'm doing in chrome webdb/sqlite i have members table , answer table member may or may not have answered. i trying result set includes member name , answer gave.. if didnt give answer, still want name come back. can try , me on this? select m.lastname, m.firstname, m.middlename, s.surveyanswer members m left join surveyanswers s on s.memberid = m.id m.id = ? , s.eventid = ? [results.rows.item(i).memberid, eventid], this try still receive members answered question , in surveyanswers table. make s.eventid part of join rather where clause. your select statement should more this: select m.lastname, m.firstname, m.middlename, s.surveyanswer members m left join surveyanswers s on s.memberid = m.id , s.eventid = ? m.id = ?

r - Episode count for each row -

i'm sure has been asked before life of me can't figure out search for! i have following data: x y 1 3 1 3 1 3 1 2 1 2 2 2 2 4 3 4 3 4 and output running count resets everytime either x or y changes value. x y o 1 3 1 1 3 2 1 3 3 1 2 1 1 2 2 2 2 1 2 4 1 3 4 1 3 4 2 try like df<-read.table(header=t,text="x y 1 3 1 3 1 3 1 2 1 2 2 2 2 4 3 4 3 4") cbind(df,o=sequence(rle(paste(df$x,df$y))$lengths)) > cbind(df,o=sequence(rle(paste(df$x,df$y))$lengths)) x y o 1 1 3 1 2 1 3 2 3 1 3 3 4 1 2 1 5 1 2 2 6 2 2 1 7 2 4 1 8 3 4 1 9 3 4 2

java - How to compile jsoup through Ant? -

i tried use ant compile jsoup source. can compile successfully, cannot pass test. here process: jsoup version: 1.6.3 ; ant version: 1.8.2 the source of jsoup in directory src/ i made build file src/build.xml this file contains <project name="jsoup"> <target name="compile"> <mkdir dir="build/classes"/> <javac srcdir="src" destdir="build/classes" includeantruntime="false"/> </target> <target name="jar"> <mkdir dir="build/jar"/> <jar destfile="build/jar/jsoup.jar" basedir="build/classes"> <manifest> <attribute name="main-class" value="statetrace"/> </manifest> </jar> </target> <target name="run"> <!--<java jar="build/jar/jsoup.jar" input="htmls/index.html" fork="true"/>--> <exec executable="java"> <arg value=...

defining web root in php for all files access -

i've been trying work around this: in file structure this: root: -----index.php (file inside root) -----template (folder inside root) -----user (folder inside root) -----products (folder inside root) -----config (folder inside root) i've been trying use dirname(dirname(__file__)) inside file in config folder define webroot constant not working well, if try access files other folders, it's calling webroot current folder instead of going root. pls can any1 me code/logic defining web root in situation this. thanks. you can use "define": define('root', '/home/username/public_html/'); then, in page page defined in included: echo root;

php - Persisting Authentication Across keep-alive Connection -

currently on website when user logged in, every webpage request have go database , check cookie confirm are, doing across keep-alive connections waste because connection authenticated, how can i, using php and/or apache, persist authentication across keep-alive connection? not possible? just check cookie enter site connection database, if checking ok: create session cookie unique encryption exemple md5("name"."pass".time())) you using sql once per session ;)

What's the difference between /usr/lib/python and /usr/lib64/python? -

i using ubuntu. i found many python libraries installed went in both /usr/lib/python , /usr/lib64/python . when print module object, module path showed module lived in /usr/lib/python . why need /usr/lib64/python directory then? what's difference between these 2 directories? btw some package management script , egg-info lived in both directories links packages in /usr/share . most python modules links, so files not. the 64-bit version of libraries? what version of python running? if running 32-bit version, won't need files.

android - HTML text input not showing in Droid -

for reason, on droid, <input type="text"> field not showing correctly. not show user typed until user moves on next field. checked on online forums , seems may droid internal issue. however, despite that, there way around it? (note: i'm using bootstrap.js , input field inheriting css styles it. not sure if bootstrap plays nicely droid?) here's html input fields (not sure if matters): <label for="firstname">first name*</label> <input type="text" class="requiredinput" name="firstname" value=""> <label for="lastname" class="">last name*</label> <input type="text" class="requiredinput" name="lastname" value=""> here's css applies field, apart bootstrap.js css: width: 100%; box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; padding: 12px 4px; margin-bot...

How to bulk-load an r-tree in C#? -

i looking c# code construct r-tree. have code builds r-tree incrementally i.e. items added 1 one tree, guess better r-tree built if items given @ once tree creation algorithm. please let me know if knows how bulk-load r-tree in manner. tried doing search couldn't find useful. the common method low-dimensional point data sort-tile-recursive (str). that: sort data, tile optimal number of slices, recurse if necessary. the leaf level of str-loaded tree point data have no overlap, good. higher levels may have overlap, str not take extend of objects account. a proven bulk-loading key component priority-r-tree, too. and when not bulk-loading, insertion strategy makes big difference. r-trees built linear splits such guttmans or ang-tan worse built r*-tree split heuristics. in particular ang-tan tends produce "sliced" pages, unbalanced in spatial extend. fast split strategy , simplest, results aren't good.

How do I save geolocation data for an HTML5 or trigger.io app for path mapping later? -

im creating app needs track location of user (with knowledge, running app) can show them route later. should use html5 timeout interval save coordinates every n seconds , if so, how should save data , how should save (locally using local storage or post server?) also, easiest way display map of user has been later? has done before? the timeout interval forge.geolocation , balance of responsiveness of application. also, network traffic expensive. maybe can buffer... last 10 geopositions... , http post (or whatever... see parse below) in bulk? , since geo data sounds temporary device data why there need persist using forge.prefs ? unless maybe need app work "offline"? for permanent storage @ parse (generous free plan) , parse.geopoint class via javascript or rest api 1 possible solution. have nifty methods (kilometersto, milesto, radiansto) - https://parse.com/docs/js/symbols/parse.geopoint.html

c++ - Cannot read from pipe in separate thread from suspended process -

i trying create process createprocess in suspended state , read it's stdout. base took msdn code. after creating process i'm going set job restrictions(not implemented yet) on process , i'm starting reading in separate thread stdout pipe. before thread initiated resume suspended process. in result i'm getting nothing readfile call, stops , waits data arrive when process finished. here code #include <windows.h> #include <tchar.h> #include <stdio.h> #include <strsafe.h> #define bufsize 4096 handle g_hchildstd_in_rd = null; handle g_hchildstd_in_wr = null; handle g_hchildstd_out_rd = null; handle g_hchildstd_out_rddup = null; handle g_hchildstd_out_wr = null; handle g_hsavedstd_out_wr = null; handle g_hinputfile = null; dword winapi createchildprocess(lpvoid param); void writetopipe(void); dword winapi readfrompipe(lpvoid param); void errorexit(ptstr); process_information piprocinfo; int _tmain(int argc, tchar *argv[]) { security_attributes saattr...

Limiting the number of queries returns in SQL Server 2008 -

this query select fullname, rank, id_no, tin, birthdate, hair, eyes, blood, height, weight, marks, name, address [******_domain\****_*****].*******view problem is, source table has many duplicates, how limit query latest row on database? i'm using sql server 2008. thanks in advance my next problem view shows me birthdate string format of yyyymmdd , need change mm/dd/yyyy can please provide me function? using same string above? for duplicates, can limit records using select distinct , , retrieve amount of records, can use select top # # amount of records. latest record- i'm not sure can done unless have date field on record of when inserted.

html - Placing an image behind a div -

i'm trying place image (the bamboo) behind div (contact form) using "z-index". however, image pushing div out of way. page can seen here: http://www.abijahchristos.com/sample/springspa jsfiddle here: http://jsfiddle.net/abijah/4n9lz/ you can use background property it. try not need z-index .copy_right { background: url("../images/bamboo1.png") repeat scroll 0 0 transparent; border: 2px solid #cccccc; border-radius: 4px 4px 4px 4px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3); float: left; height: 310px; margin: 0 25px 0 30px; padding: 5px 0 0; width: 310px; z-index: 2; }

java - how to display a list based on a foreign key groovy grails -

i have 2 tables: region , district . region_id foreign key table district (a region has 1 or many districts ). so, when select region on list want display districts associated particular region . correct code displays districts independently of region : def list = { params.max = math.min(params.max? params.int('max') : 20, 100) [districtinstancelist : district.list(params), districtinstancetotal: district.count()] } does know how display based on foreign key constraint? know write sql query in list closure, suppose grails has way it. database mysql , , grails version 2.0.1 . district domain is: class district { def scaffold = true string name string description string logo string homepage // defines 1:n constrain region table static belongsto = [region : region] // defines 1: constraint stream table static hasmany = [streams : stream] static constraints ={ name(blank:false, minsize:6, maxsize:30) description(blank: false, maxsize:100) } public string tostring()...

jQuery combobox Styling issue -

Image
i rendering jquery combobox, height of input element not match height of toggle button shown in screen shot below. happening in both, ie 9 , firefox 13. the style being used jquery combobox below. <style> .ui-combobox { position: relative; display: inline-block; } .ui-combobox-toggle { position: absolute; top: 0; bottom: 0; margin-left: -1px; padding: 0; /* adjust styles ie 6/7 */ *height: 1.7em; *top: 0.1em; } .ui-combobox-input { margin: 0; padding: 0.3em; } .ui-autocomplete { height: 200px; overflow-y: auto; } </style> you should update combo-box widget jqueryui page . , make sure use latest jquery-ui (this issue fixed recently). this helped me...

PHP curl cannot read a page -

php curl @ our localhost works fine not on other server here code $ch = curl_init(); curl_setopt($ch, curlopt_useragent, "mozilla/5.0 (x11; ubuntu; linux i686; rv:13.0) gecko/20100101 firefox/13.0.1" ); curl_setopt($ch, curlopt_url, 'http://50.7.243.50:8054/played.html'); curl_setopt($ch, curlopt_post, 0); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_header ,0); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch,curlopt_timeout,120); curl_setopt($ch,curlopt_maxredirs,20); $data = curl_exec ($ch); if ($data == false) echo "curl error : ".curl_error($ch)."<br>"; curl_close ($ch); even if curl_setopt($ch, curlopt_url, 'http://50.7.243.50/played.html'); curl_setopt($ch, curlopt_port, 8054); it shows error couldn't connect host any appreciated.... try code, have tested , working. $html = "http://50.7.243.50:8054/played.html"; $header = array(); $header[] = 'accept: text...

python - Virtualenvwrapper not found -

given know python, problem i'm having shouldn't been happening. installed virtualenvwrapper on mac os x snow leopard pip. it's there in /library/python/2.6/site-packages. when try import virtualenvwrapper, python tells me there's no such module name. other modules (e.g. virtualenv) load fine, , /library/python/2.6/site-packages right @ top of python path. there weird virtualenvwrapper python isn't finding it? mine in /usr/local/bin/virtualwrapper.sh should able add .bashrc, .bash_profile, or .profile put environment. (remember source .bashrc or open new terminal window) source /library/python/2.6/site-packages/virtualenvwrapper.sh edit here's entire bash profile related pip, virtualenv , virtualenv wrapper since looks ugly comment # python export path=/usr/local/share/python:$path export pythonpath=/usr/bin/python:$pythonpath export path=/usr/local/macports/library/frameworks/python.framework/versions/2.7/bin:$path export virtualenvwrapper_python=/usr/l...

Migrate trigger Oracle to SQL Server -

people, i need migrate oracle trigger sql server, not do. the trigger in oracle simple: create or replace trigger trigger_teste before insert or update on teste each row declare begin :new.id := (coalesce(:new.id, 0)); :new.vlr_sal := (coalesce(:new.vlr_sal, 0.00)); end; i tried several ways none successfully! thank help! my t-sql bit rusty, should work. note sql server not have row level triggers, statement level triggers. create trigger trigger_teste on teste before insert or update update inserted set id = coalesce(id, 0), vlr_sal = coalesce(vlr_sal, 0.0) go (not sure if got missed semicolon or not. never understood when sql server needs or deosn't need one) see manual more details: http://msdn.microsoft.com/en-us/library/ms189799%28v=sql.90%29 http://msdn.microsoft.com/en-us/library/ms191300%28v=sql.90%29

Save frame from webcam to disk with opencv python bindings -

i'm trying use opencv save frames webcam jpgs or pngs or whatever. it's proving more difficult i'd thought, despite having examples 1 here: capturing single image webcam in java or python i trying this: if __name__ == "__main__": print "press esc exit ..." # create windows cv.namedwindow('raw', cv.cv_window_autosize) cv.namedwindow('processed', cv.cv_window_autosize) # create capture device device = 0 # assume want first device capture = cv.capturefromcam(0) cv.setcaptureproperty(capture, cv.cv_cap_prop_frame_width, 640) cv.setcaptureproperty(capture, cv.cv_cap_prop_frame_height, 480) # check if capture device ok if not capture: print "error opening capture device" sys.exit(1) while 1: # forever # capture current frame frame = cv.queryframe(capture) if frame none: break # mirror cv.flip(frame, none, 1) # face detection detect(frame) # display webcam image cv.showimage('raw', frame) # handle events k = cv.waitkey(10) i...

error handling - GLES 2 Android Emulator -

i keep on getting error when trying run opengles 2 application on emulator running 4.0.3 gpu emulation enabled: failed create context 0x3005 emulator: warning: not initialize opengles emulation, using software renderer. not wglgetextensionsstringarb not wglgetextensionsstringarb not wglgetextensionsstringarb not wglgetextensionsstringarb not wglgetextensionsstringarb not wglgetextensionsstringarb not wglgetextensionsstringarb not wglgetextensionsstringarb : tried find suitable driver thinking solve solution didn't work. appreciated. in advance. is "force gpu rendering" enabled on device? i mean option in settings => developer setting => force gpu rendering

vb.net - how to use recordset movelast -

i need code can use old rs.movelast vb.net 2010.. simple way query record automatic select last.. here connection sample call in form../// public function executesqlquery(byval sqlquery string) datatable try dim sqlcon new oledbconnection(cnstring) dim sqlda new oledbdataadapter(sqlquery, sqlcon) dim sqlcb new oledbcommandbuilder(sqlda) sqldt.reset() ' refresh sqlda.fill(sqldt) catch ex exception msgbox("error : " & ex.message) end try return sqldt end function sqldt.rows(sqldt.rows.count-1) last record of datatable sqldt. sqldt.rows.count-1 return last index of rows in filled table. hope you. thanks imports system.data.oledb public class form1 public cnstring string = "provider=sqloledb;data source=hp-pc\sqlexpress;persist security info=true;password=sa;user id=sa;initial catalog=accounts" private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click dim ssql string = "select * tbl_access" dim dt dat...

rearrange the UIButton position in a UIView iphone? -

i have set of uibuttons in class. according url fields uiwebview need rearrange position of buttons. my button array is buttonarray = [[nsmutablearray alloc] initwithobjects:btn1,btn2,btn3,btn4,btn5,btn6, nil]; these buttons arranged in order, if mu url field gives value false means need remove button btn1 , other buttons should retain display order. i tried code if(false) { btn1.hidden=yes; btn2.center=cgpointmake(btn1.frame.origin.x, btn1.frame.origin.y); } but btn2 not take position of btn1. how arrange buttons such other buttons should retain display order when of buttons missing in display. hope help. not @ accessible computer guess...try: cgrect buttonframe = btn1.frame; [btn2 setframe: buttonframe];

java - How best to get List nodes for a cache implementation -

Image
okay first preface "i very new java" (i.e., few days in), programmer trade. i have come across situation want load data. however, cache data prevent extraneous calls api (or, whatever data source may be). after thinking bit, have come cache scheme seems pretty reasonable me: idea datacache class has 2 collections: hash table key type "string" , value type "cachedata". cachedata has 2 data members - actual result of api call in string form, , ref (listiterator?) node of linked list. brings 2nd collection - linked list of keys. idea when request comes in data, see if it's in hash. if not, fetch api, add resulting key front of linked list, , store data object in hash containing result, along ref first node of linked list (the 1 added). if data found in hash, break node out of linked list, put front, , return data cachedata. benefit, every operation guaranteed execute in o(1), if i'm understanding correctly. can store integer hash value of 'requ...