Posts

Showing posts from March, 2011

c# - How do I update the parent viewmodel when child viewmodel is updated -

in first view model (renamed mainviewmodel) have list of actionviewmodels. in xaml have listbox bound list, in listbox have template binds properties actionviewmodel. so far , works. when selecting 1 of listitems navigate actionviewmodel , pass id it. actionviewmodel retrieves information static list in memory mainviewmodel retrieved information create list of actionviewmodels. so far still good, can edit properties, bindings work fine , i'm happy. clicking save button information gathered , stored in static list. when hit button go list, unfortunately values showing there still same, there way send command reload items in list? pass complete viewmodel reference new actionviewmodel? or property tells parent 'this viewmodel in list has been updated'? i sure above text bit confusing, here code clarify bit (hopefully) mainviewmodel.cs private list<actionviewmodel> _actionviewmodels; public list<actionviewmodel> actionviewmodels { { return _actionv

html - Styling a vertical-line -

i want make vertical line looking this: http://i41.tinypic.com/2na44n7.png i've tried following code: div.vertical-line{ float:right; width:5px; background-color:black; margin-right:20px; background: #ffffff; background: -webkit-gradient(linear, 0 0, 0 bottom, from(#ffffff), to(#cfcfcf)); background: -webkit-linear-gradient(#ffffff, #cfcfcf); background: -moz-linear-gradient(#ffffff, #cfcfcf); background: -ms-linear-gradient(#ffffff, #cfcfcf); background: -o-linear-gradient(#ffffff, #cfcfcf); background: linear-gradient(#ffffff, #cfcfcf); -pie-background: linear-gradient(#ffffff, #cfcfcf); behavior: url(/pie/pie.htc); } but result wasn't expected. here result: http://jsfiddle.net/rlyyc/ it's close, doesn't "fade-out" @ end of line. any suggestions? thanks in advance! using this generator , got you: background: #ffffff; /* old browsers */ background: -moz-linear-gradient(top, #fff

Inno setup disable two buttons on the same page -

disable 2 buttons on same page tried several ways did not closer example not correct [button next = time] [button back= no time (only disable)] find error bound [code] var counter: integer; timerid: integer; type ttimerproc = procedure(wnd: hwnd; msg: uint; timerid: uint_ptr; systime: dword); function wraptimerproc(callback: ttimerproc; paramcount: integer): longword; external 'wrapcallback@files:innocallback.dll stdcall'; function settimer(hwnd: hwnd; nidevent, uelapse: uint; lptimerfunc: uint): uint; external 'settimer@user32.dll stdcall'; function killtimer(hwnd: hwnd; uidevent: uint): bool; external 'killtimer@user32.dll stdcall'; procedure ontimertick(wnd: hwnd; msg: uint; timerid: uint_ptr; systime: dword); begin counter := counter - 1; begin counter := counter - 1; if counter <= 0 begin wizardform.nextbutton.enabled := true; wizardform.nextbutton.caption := setupmessage(msgbuttoninstall); if timerid <> 0 killt

Get AngularJS scope variable (inside javascript) defined in resolve/promise -

i defining rootscope variable in routes using resolve/promise want variable available before controller gets executed. $routeprovider.when('/', { templateurl: 'test.html', controller: 'test', resolve: { ccapp: ['$q','$rootscope','$location',function($q,$rootscope,$location) { var defer = $q.defer(); $rootscope.teststring = "this test data"; defer.resolve($rootscope.teststring); return defer.promise; }] } }); and trying access in javascript as: <script type="text/javascript" > var teststring = $('[ng-controller="test"]').scope().teststring; </script> i didn't use rootscope inside javascript rootscope not defined in javascript. but not working. doubt whether can use controller here. otherwise, h

php - Notice: Use of undefined constant self - assumed 'self' , When put in property_exists as the first argument -

i'm trying use self instead of typing class name inside propery_exists function follows : private static function instantiate($record){ $user = new self; foreach($record $name => $value){ if(isset($user->$name) || property_exists(self, $name)){ $user->$name = $value; } } return $user; } but when ran script error : notice: use of undefined constant self - assumed 'self' in /var/www/photo_gallery/includes/user.php on line 36 line 36 line property_exists method called. when change self user (the class name). works perfectly. i want know why using self giving such notice ? doesn't self refer class? use self refer current class. not class name . try using magic constants: if(isset($user->$name) || property_exists(__class__, $name)){ from php manual: __class__ the class name. (added in php 4.3.0) of php 5 constant returns class name declared (case-sensitive). in php 4 value l

viewport - Phonegap / Cordova InAppBrowser handels content different then Safari/Chrome Mobile -

i open external page in phonegap application window.open("https://external.com/external", "_blank", 'location=yes,enableviewportscale=yes'); unfortunately viewport not same in mobile-phones native browser. if open same page in chrome on nexus 4 see complete page (correct scaled). if open page through inappbrowser of phonegap see half of page , have scale see entire page. the view-port meta tag following: <meta name="viewport" content="width=640,user-scalable=no"> i tried set to <meta name="viewport" content="width=device-width,user-scalable=no"> but page has scaled in native browser , displays correctly in inappbrowser. can 1 me fix please? thanks! use <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> the above code open c

visual studio 2008 - How to Apply Multicolumn in another Details Section C#, Crystal Reports, vs2008 -

Image
i having report in here having 4 details section a,b,c,d , , want apply multi column in 1 details section, section has sub report currently. have used sub report because thought, applying multiple column 1 details section not possible.... and got burden, report can have more 2500 pages, while using subreports, slow while printing , / or navigating last page. so, in section c have show data in 2 columns across data layout. , rest of sections a, b, d , can have 1 column. and also, have 2 tables rptdoc -> documents[list of documents] , rptsche -> schedules[list of schedules]. every document can have 1 or more schedules each, so, have show document record associated schedules.. schedules must in section c 2 columns. is possible?? to first question regarding columns: if other detail sections (a, b, c & d) of report pulling same data source there no reason why can't place columns wherever want in sections. place fields required in each section. can

javascript - Nestling multiple accordions in jQuery tabs -

i need create page 3 tabs across top, accordion inside each tab, able load first accordion, , others appear unrendered. appreciated. did see accordion should placed before tabs in instance, thats not working me either. <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>details</title> <!-- website styles --> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"> <link href="css/smoothness/jquery-ui-1.10.3.custom.css" rel="stylesheet"> <style type="text/css"> body { background-color: #000000; } </style> </head> <body> <div class="wrapper"> <div class="one_half"> </div> <div class="one_half last"> <!-- accordion --> <h2 class="demoheaders"

r - Find color names for colors close to colorBrewer palette -

Image
i want use r package sna social network analysis. sna colors elements using r color names (text names). i'd find near matches colorbrewer palette (set3) color names in r. there aren't many exact matches in rgb space. require(rcolorbrewer) brew10 <- brewer.pal(10, "set3") rcol <- colors() brew10rgb <- col2rgb(brew10) allrgb <- col2rgb(rcol) apply(t(brew10rgb), 1, paste, collapse="$$") %in% apply(t(allrgb), 1, paste,collapse="$$") brew10rgb[,1] fltr <- allrgb[1,]==141 allrgb[,fltr] fltr <- allrgb[2,]==211 allrgb[,fltr] is there way pick color names qualitative palette in r, or map these rcolorbrewer colors existing colors? see if useful. (it's li distance on rgb space): col.dist <- function(inp, comp) sum( abs(inp - col2rgb(comp) ) ) colors()[ apply(col2rgb(brew10), 2, function(z) which.min( sapply(colors(), function(x) col.dist(inp=z, comp=x) ) ) ) ] #-------

excel - Determining the number of matches to a "Find" on a given range -

i have macro selects particular range , find number "0" on it. know how many times "0" appears in range i've selected can create variable equal number. how can set variable equal number of times find returns match query? activecell.select selection.offset(0, 1).select item = activecell.value sheets("lights").select rows(3).select selection.find(what:=item, after:=activecell, lookin:=xlvalues, lookat:= _ xlpart, searchorder:=xlbyrows, searchdirection:=xlnext, matchcase:=false _ , searchformat:=false).select q = activecell.row() z = activecell.column() range(cells(q, z), cells(72, z)).select selection.find(what:="0", after:=activecell, lookin:=xlvalues, lookat:= _ xlpart, searchorder:=xlbyrows, searchdirection:=xlnext, matchcase:=false _ , searchformat:=false).activate so if there 7 instance of 0 on range want set variable m= 7 m = worksheetfunction.countif(selection, 0) or partial matches:

android - Trouble getting time out of TimePicker -

i trying set time form time picker reason , not happening. i using getcurrenthour , getcurrentminute() don't seem doing job.i have tried clearfocus() did not make difference. i trying time on button click. have attached relevant code below , let me know if need see anymore. button next_button = (button) findviewbyid(r.id.next_button); next_button.setonclicklistener(new view.onclicklistener() { public void onclick(view arg0) { //calendar current = calendar.getinstance(); calendar cal = calendar.getinstance(); //time_picker = (timepicker) findviewbyid(r.id.time); // time_picker.clearfocus(); // did not cal.set( time_picker.getcurrenthour(), time_picker.getcurrentminute(), 00); toast.maketext(getapplicationcontext(), "set time: "+cal.gettime(), toast.length_long).show(); // returning current time

ESI (Edge Side Include) and hinclude content on search engine? -

first of i'm sorry if question belong, if please let me know should post if possible. i have discovered esi , hinclude ways boost side performance, have searched , down , not find document on how search engines index pages using these. think since hinclude use javascript not possible search engines index content included dynamically them. i'm not sure esi, content indexed or left out well? hope can shed light on me on topic. regards esi processed "edge-side" - example akamai or varnish. client never sees esi include tags, see rendered page. hinclude processes client-side means search engine's spider need able process javascript. search engines seem moving direction may not support it.

c# - Efficiently Upload Output to Server -

i have created simple aspx page log output of process running on remote machine. my url is: .com/log.ashx?data=somestring should use webrequest or webclient? more efficient , less resource intensive? i need 20 times in minute. ashx file not show output. neither 1 more efficient other. webrequest offers more functonality webclient. if webclient exposes enough functionality need go that. if doesn't use webrequest.

c++ - Program received signal SIGILL, Illegal instruction -

i using linux x86_64 machine build program. have linked shared library executable. in project calling function has declared vector<string> inside function. program gets killed when function gets called. when debugging through gdb below output get. program received signal sigill, illegal instruction. 0x00002aaaac4d2be7 in oc_catalog_c::file_totext (this=0x611aa0) @ /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:87 87 : _tp_alloc_type(__a), _m_start(0), _m_finish(0), _m_end_of_storage(0) (gdb) bt 0 0x00002aaaac4d2be7 in oc_catalog_c::file_totext (this=0x611aa0) @ /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:87 is issue of compilation of shared library?? banged head enough on it. please help. -chaks adding more info queries: yes,function calling file_totext virtual function in class oc_catalog_c. member variable of other class has object of class oc_catalog_c have virtual fu

android - ANDROID_HOME not overriding local.properties -

i have local.properties file in git repo android project. on build server checking out git , running gradle targets execute unit tests. build server linux , i'm on mac android sdk installed different, change don't want to. does android_home override local.properties; can't tell if i'm setting environment variable correctly in jenkins (build server) or if local.properties beats env variable. source i've been reading is: http://tools.android.com/tech-docs/new-build-system/user-guide note: need local.properties file set location of sdk in same way existing sdk requires, using sdk.dir property. alternatively, can set environment variable called android_home. on tools i've seen, local configuration override environment variables. from jenkins perspective, using environment variables makes sense can propagated multiple projects.

javascript - Avoid same points being plotted twice in Google Visualization Chart API -

i plotting line graph google's visualization chart api , change in number of leads(an integer) every 30minutes. here have done till now: google.load("visualization", "1", {packages:["corechart"]}); google.setonloadcallback(drawchart); function drawchart() { var jsondata = 'json string goes here'; var report = $.parsejson(jsondata); //make json object var data = new google.visualization.datatable(); data.addcolumn('timeofday', 'time'); data.addcolumn('number', 'leads'); var interval = 1000 * 60 * 30; //interval of 30mins var graphdata = report['rush_hour_reports']; var length = graphdata.length; var normalized_data = {}; //placeholder object for(var i=0; i<length; i++){ var dt = new date(graphdata[i]['my_hour']); //date obj timestamp //next round of time in chunks of 30mins(interval) var dt_rounded = new date(math.round(dt.gettime() / interval) * interva

javascript - Convert string of variables separated by & into array -

this question has answer here: how can query string values in javascript? 73 answers i want grab variables contained in url after logs facebook app. for example: // window.location = .../#access_token=cttg4ft3ci...&expires_in=5298 hash = window.location.hash; data = parse(hash); console.log(data['access_token'] + ', ' + data['expires_in']); // returns: caag4ft3ci..., 5298 is there method or function similar json.parse() convert "hash" array or object? function parse (hash) { var l, chunk, = 0, out = {}; var chunks = hash.substr(1).split('&'); ( l = chunks.length; < l; i++ ) { chunk = chunks[i].split('='); out[ chunk[0] ] = chunk[1]; } return out; } here's fiddle: http://jsfiddle.net/vwljs/

java - How to upload a File with hibernate-ogm and Mongodb? -

i have been able upload strings , dates mongodb, cannot figure out how file in there using webapp. i'd rather not use gridfs, byte[] or blob (but if must use gridfs, then, must). here have far: index.jsp: <form action="./fileuploadservlet" method="post"> <input type="text" name="subject"/><br> <input type="date" name="docdate"/> <%--todo: accept file db--%> <input type="file" name="filecontent"/> <input type="submit" value="submit"> </form> fileuploadservlet.java: //imports... @webservlet(name = "fileuploadservlet", urlpatterns = {"/fileuploadservlet"}) public class fileuploadservlet extends httpservlet { throws servletexception, ioexception, exception { response.setcontenttype("text/html;charset=utf-8"); printwriter out = response.getwriter();

Android button click event won't fire sometimes -

the onclick() event button in android app won't fire. button "next" button in 1 activity in series of configuration activities. first time go through series of configuration activities, onclick() event fires fine. however, if way out of app (using button) , relaunch, event never fires. i've verified putting breakpoint in next() method; method calls subsequent activity. here's code: button xml in layout: <button android:id="@+id/gender_button_id" android:layout_height="wrap_content" android:layout_width="fill_parent" android:onclick="next" android:text="@string/gender_button" /> activity code: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_gender); } public void next(view view) { intent = new intent(this, weightactivity.class); startactivity(i); } put log/println sta

ms access - Read Excel file sheet names -

i have export process transfers data access tables excel file. couple times have had issues process didn't generate 1 or more of sheets (1 sheet = 1 table) in excel. when transfers complete want access check if sheets located in excel file. have of check process worked out need way "read" sheet names excel file in table. how can read sheet name (not data)? from access can automate excel, open workbook file, , read sheet names worksheets collection. this sample uses late binding. if prefer binding, add reference microsoft excel [version] object library , enable "early" lines instead of "late" lines. give procedure full path workbook file pworkbook parameter. public sub list_worksheets(byval pworkbook string) 'dim objexc excel.application ' 'dim objwbk excel.workbook ' 'dim objwsh excel.worksheet ' dim objexc object ' late dim objwbk object ' late dim objwsh object ' late

swing - How to achieve abstract variable functionality in Java -

i trying create custom class extends class ( jframe ) forces assignment of variable upon implementation (i want each jframe in application have "screen id"). java, however, not have abstract variables. nor able figure out how make interface extends jframe . one's got head spinning =d the class code similar this: public interface customframe extends javax.swing.jframe { public abstract int screen_id; } and implementation of customframe this: public class newframe implements customframe { public int screen_id = 5; newframe() { setvisible(true); // etc... } } does problem make sense anyone?? know objective lost trying work out in brain.... create external frameid generator generate new id @ each call (just simple example implemented singleton: no synch or generic return type etc): class frameidgenerator { private static int nextid = 0; private frameidgenerator(){} private static frameidgenerator instance = nul

c# - Compare attribute does not use Display attribute of compared property -

i have viewmodel used changing password, , uses compare dataannotation so: [display(name = "new password")] public string new { get; set; } [compare("new")] [display(name = "confirm password")] public string confirmpassword { get; set; } unfortunately compare attribute not utilize display attribute of compared property. the error message displays as 'confirm password' , 'new' not match. which can see uses comparing property's display attribute, not compared property's. i'll specify don't want use errormessage parameter because i'd hard-coding property name rather acquiring existing attribute. i'd keep solution best-practice possible. how can make compare attribute utiliize display attribute of compared property? i think may issue compare attribute, since can see otherdisplayname attribute in list of properties, , correctly uses display name property decorating ("confirm passwor

ios - Is there a way to figure out what thread an NSManagedObjectContext is on? -

my understanding of threads respect nsmanagedobjectcontext can execute core data fetch requests, deletes, etc., on thread created. there way check see thread nsmanagedobjectcontext created on, or if @ particular point of execution current thread of particular nsmanagedobjectcontext ? thanks! my understanding of threads respect nsmanagedobjectcontext can execute core data fetch requests, deletes, etc., on thread created. that's not accurate. better contexts cannot used concurrently more 1 thread or queue. common approach dealing create different contexts each thread/queue. it's possible use performblock , performblockandwait methods use contexts on multiple threads while keeping context access single-threaded. as result, contexts don't have notion of belonging thread or queue, nor threads have reference contexts created on them. if follow approach of 1 context per thread or queue, need keep track of code run , use appropriate context. example whe

version control - Update SVN branched working copy from trunk -

i have branch trunk out of date. working copy commits , updates branch. simplest way bring either branch or working copy date trunk? i tried merging trunk branch, , got permission error (i think because don't have permissions necessary commit modify trunk directly) using command: svn merge [url_to_trunk] [url_to_branch] to circumvent have been deleting contents of branch , copying trunk on again; inconvenient, i'd know if there's way update working copy trunk url, commit branch. you must read svn book basic merging or, @ least, svn merge you do not use merge blindly , without understanding process you do not use 2-url merge unless needed you'd use 1st form of merge, "complete" merge after all: merge source[@rev] [target_wcpath] where source url of trunk target_wcpath local path working copy of branch (clean wc without local modifications, mixed revisions etc.). may omitted if current directory root of wc after merge

html - How to make Javascript questionnaire show different link with different answers -

how make if questions 1, 2, 3 , 4 have blue, red, green , black chosen shows link page1 or if orange, pink, red , blue chosen shows link page2 , on. prefer using html , javascript. need help. example of i'm trying accomplish is: http://glyde.com/sell/iphone-4s <html> <head> <style type="text/css"> <!-- .bgclr {background-color: white; color: black; font-weight: bold;} --> </style> <script language="javascript"> <!-- begin // insert number of questions var numques = 4; // insert number of choices in each question var numchoi = 3; // insert number of questions displayed in answer area var answers = new array(4); // insert answers questions answers[0] = "cascading style sheets"; answers[1] = "dynamic html"; answers[2] = "netscape"; answers[3] = "common gateway interface"; // not change below here ... function getscore(form) { var score = 0; var currelt; var currselection; (i

spring data - Neo4j Same Entity Relationship persistence issue -

is possible pls advice me how go about.. doing same entity relationship.. for ex. entity(class person) relatesto entity(class person). code: @nodeentity public class person { @graphid @generatedvalue private long id; @indexed(indextype = indextype.fulltext, indexname = "searchbypersonname") private string personname; @fetch @relatedto(type = "connects_to", direction = direction.both) private set<connectedpersons> connectedpersons; public connectedpersons connectsto(person endperson, string connectionproperty) { connectedpersons connectedpersons = new connectedpersons(this, endperson, connectionproperty); this.connectedpersons.add(connectedpersons); //null pointer here(connectedpersons null) return connectedpersons; } } code: @relationshipentity(type = "connected_to") public class connectedpersons{ @graphid private long id; @startnode private person

android - How to implement a ViewPager with different Fragments / Layouts -

Image
when start activity implements viewpager, viewpager created various fragments. want use different layouts each fragment, problem viewpager shows 2 layouts @ max (second layout on of remaining fragments after 1). here code swipeactivity implements viewpager : public class swipeactivity extends fragmentactivity { mypageadapter pageadapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_swipe); pageadapter = new mypageadapter(getsupportfragmentmanager()); viewpager pager=(viewpager)findviewbyid(r.id.pager); pager.setadapter(pageadapter); actionbar bar = getactionbar(); bar.setdisplayhomeasupenabled(true); } /** * custom page adapter */ private class mypageadapter extends fragmentpageradapter { public mypageadapter(fragmentmanager fm) { super(fm); } @overrid

Replacing "<" with "*" with a Python regex -

i need go through strings in list "listb", replacing character "<" "*". i tried this: import re in listb: = re.sub('\<','\*', 0) but keep getting typeerror: expected string or buffer. not sure doing wrong , examples on net not help. see docs as per seth's comment, best way using regular expressions going be: listb = [re.sub(r'<',r'*', i) in listb] as @paco, said, should using str.replace() instead. if still want use re: you're putting 0 string supposed go! typeerror third parameter. it's int, needs string. side note: use raw strings, denoted r'' , in regexes, don't have escape. >>> listb = ['abc', '<asd*', '<<>>**'] >>> in listb: ... = re.sub(r'<',r'*', i) ... print ... abc *asd* **>>** >>> listb ['abc', '<asd*', '<<>>**

javascript - Access Validation Failed Field Name in Spring Template -

i using jquery validation form validation. form errors shown not @ affected field in div below submit button. thus, have list of errors use for element attribute reference failed field. populate fields.errors object in thymeleaf tmeplate. currently, have errors showing in error div, cannot figure out how access failing field. can tell me how find name of field failed specific error message in fields.errors? check thymeleaf sprint validation

python - SQLAlchemy Columns result processing -

i'm working ibm db2 database using ibm_db2 driver , sqlalchemy. model is: class user(model): id = column('uid', integer, primary_key=true) user = column('user', string(20)) password = column('password', string(10)) name = column('name', string(30)) string fields database (e.g. name ) comes in form of: >>> "john " , value filled right blanks full length of field schema. i need change behavior sqlalchemy type string (or derivative thereof) produced follow (e.g. value.strip() ) before output results query.all() : >>> "john" how can this? @property decorator not applicable. need change behavior of standard sqlalchemy string class. i not want change behaviour of standard string make new type (you can rename string per module basis or whatever) cleanest way: from sqlalchemy import types class strippedstring(types.t

knockout.js - How to access knockout viewmodel from javascript -

i trying understand how manage scope in javascript code. once create viewmodel, how access rest of javascript? (last line in code generates 'not defined' error note: have found several posts on differences between function/var ko, none have said there scoping advantage using var... have tried both methods. //function appviewmodel() { // this.gridsize = ko.observable("30"); // this.canvaswidth = ko.observable("600"); // this.canvasheight = ko.observable("600"); // this.displaycoords = "axial"; // this.pixel="0"; // this.hex="0"; //} //ko.applybindings(new appviewmodel()); var appviewmodel = { gridsize: ko.observable("30"), canvaswidth: ko.observable("600"), canvasheight: ko.observable("600"), displaycoords: "axial", pixel:"0", hex:"0" }; ko.applybindings(appviewmodel ); var test = appviewmodel.gridsize;

Error message -> shouldOverrideUrlLoading Webview Android -

i need solved problem webview , method shouldoverrideurlloading. i want display message indicating user doesn't have twitter app installed on phone @override public boolean shouldoverrideurlloading(webview view, string url) { if (url.startswith("tel:")) { intent intent = new intent(intent.action_dial, uri.parse(url)); startactivity(intent); }else if(url.startswith("http:") || url.startswith("https:")) { view.loadurl(url); }else if (url != null && url.startswith("market://")) { view.getcontext().startactivity( new intent(intent.action_view, uri.parse(url))); return true; } else if (url != null && url.startswith("twitter://")) { view.getcontext().startactivity( new intent(intent.action_view, uri.parse(url))

basic python with Django -

i'm reading of django docs , i've come across obj, created = person.objects.get_or_create(first_name='john', last_name='lennon', defaults={'birthday': date(1940, 10, 9)}) i'm still learning python in process. i'm bit confused "obj, created = " part of code. assume both "obj" , "created" perform person.objects.get_or_create(first_name='john', last_name='lennon', defaults={'birthday': date(1940, 10, 9)}) person.objects.get_or_create returns 2 values, assigned obj , created respectively. obj actual object gotten or created, , created flag tells if created (or gotten).

debugging - Where is the ruby debugger taking me? -

i'm using 'debugger' gem go through ruby code. upon passing line 2 in code, debugger jumps frame after frame of scurrilous ruby functions , methods. what's happening here. i've stepped 50 times through debugger , hasn't jumped code yet. my code [-3, 6] in c:/ruby/prep-work-master/coding-test-2/practice-problems/spec/00_neare 1 require '00_nearest_larger' => 2 require 'rspec' 3 4 # write function, `nearest_larger(arr, i)` takes array , 5 # index. function should return index, `j`: should 6 # satisfy: (rdb:1) n debugger jumps here: this? c:/railsinstaller/ruby2.0.0/lib/ruby/2.0.0/rubygems.rb:982 spec = @path_to_default_spec_map["#{path}#{suffix}"] [977, 986] in c:/railsinstaller/ruby2.0.0/lib/ruby/2.0.0/rubygems.rb 977 ## 978 # find gem::specification of default gem +path+ 979 980 def find_unresolved_default_spec(path) 981 gem.suffixes.each |suffix| => 9

java - Remove and Insert in a circular queue -

in college professor has asked devise algorithm implement circular queue. have write algorithms 'remove()' , 'insert()' functions. came after hours of thinking. declarations: q = circular queue structure contains 3 elements --> x[max] = array of max integers --> rear = logical pointer used inserting elements @ particular index --> front = logical pointer used deleting elements @ particular index predefined functions: --> incr (int y) : special function set y 0 once contains max else y++ --> decr (int y) : special function set y max if contains 0 else y-- preconditions : @ initial time of defining structure set rear , front both @ 0 algorithm remove(q): returns int 1. set <- q.x[q.front] 2. incr (q.front) 3. if q.front >= q.rear 1. decr (q.front) 2. print "queue empty" else 1. return algorithm insert(q,a) : returns nothing 1. in

javascript - Caching jQuery variables -

i read if referring same dom element on , on in function better cache them in local variable : var btn = $('#clearbtn'); i have followed necessary when accessing object have used $(btn).somemethod(); although can access directly btn.somemethod(); i need know whether have negative impact ? there's no point in passing jquery object through jquery constructor. it's wasteful. if dollar sign looks nice you, prepend variable name , use $btn in place of $(btn) : var $btn = $('#clearbtn');

multithreading - Python class instance starts method in new thread -

i spent last hour(s???) looking/googling way have class start 1 of methods in new thread instanciated. i run this: x = myclass() def updater(): while true: x.update() sleep(0.01) update_thread = thread(target=updater) update_thread.daemon = true update_thread.start() a more elegant way have class doing in init when instanciated. imagine having 10 instances of class... until couldn't find (working) solution problem... actual class timer , method update method updates counter's variables. class has run functions @ given time important time updates won't blocked main thread. any appreciated. thx in advance... you can subclass directly thread in specific case from threading import thread class myclass(thread): def __init__(self, other, arguments, here): super(myclass, self).__init__() self.daemon = true self.cancelled = false # other initialization here def run(self): ""&q

list - get keys value's from dictionary in python -

i have list of dictionary: dictlist = [{'url': 'google.com', 'a': 10, 'content': 'google', 'd': 80, 'f': 1, 'lock': 'dd'}, {'url': 'fb.com', 'z': 25, 'content': 'google', 'd': 60, 'p': 1, 'a': 19}] i need create new dictionary above dictlist . newdict= {} sumlist = ['a', 'z', 'd'] #get values these dictlist dict in dictlist: newdict['newurl'] = dict['url'] newdict['newtitle'] = dict['content'] newdict['sumvalue'] = ????? #so 1st item 'sumvalue'= + z + d = 10 + 0 + 80 = 90 (zero 'z') #and 2nd item has 'sumvalue' = + z + d = 19 + 25 + 60 = 104 print newdict[0] # should result {'newurl': 'google.com', 'newtitle': 'google', 'sumvalue' : 80 } i don&

asp.net - why a string is added in wrong format to the razorview? -

i'm trying add few classes listitem object in html using razor , helper method. i defined @functions{} section method : public string addclasses() { return "classes=\"class1 class2\""; } when using in razor <li @addclasses()>tekst</li> the result is: <li class=""class1" class2&quot;">tekst</li> what doing wrong? razor automatically html encodes string turns " &quot; . to turn off html encoding need use html.raw method ( msdn ): <li @html.raw(addclasses())>tekst</li>

c# - Parsing Flickr JSON Responses with DataContractJsonSerializer -

so i'm trying parse json data flickr using datacontractjsonserializer i'm receiving json response , keeping in stream no problems, meaning have tested passing writing file , json there. jsonflickrapi({"photos":{"page":1, "pages":372738, "perpage":10, "total":"3727375", "photo":[{"id":"9578613971", "owner":"7960563@n07", "secret":"b7b80b75f8", "server":"3734", "farm":4, "title":"1970 - 1978 toyota corolla e20 coup\u00e9", "ispublic":1, "isfriend":0, "isfamily":0, "url_t":"http:\/\/farm4.staticflickr.com\/3734\/9578613971_b7b80b75f8_t.jpg", "height_t":"67", "width_t":"100", "url_o":"http:\/\/farm4.staticflickr.com\/3734\/9578613971_0eda23bccb_o.jpg", "height_o":"1000",

Oracle SQL Query Help needed for below -

i have table below : id ref num type time stamp ------------------------------ 1 456 x time 1 2 456 y updated timestamp 3 678 x time 3 4 678 y updated timestamp i need in building query shall give me result below : ref num type time difference ------------------------------------ 456 x (timestamp diff between type x , type y ref num) 678 y (timestamp diff between type x , type y ref num) you can conditional aggregation: select t.refnum, (max(case when type = 'x' timestamp end) - max(case when type = 'y' timestamp end) ) typetimestampdiff t group t.refnum;

php - Magento, how to edit magento for access magento admin area without authentication -

i want speed test magento admin area 3rd party tool. can't magento admin area requires authentication. there way disable it? yes there is. magento ships source , allowed modify it. fork source repo, branch out testing code-base, hack , create patch can apply testing. after testing inverse-apply patch. if non-test code-base changes, rebase testing branch on top of it. please take note tests might limited, because not speed-test original admin area modified one. e.g. speed tests not cover parts removed. might obvious, however, when you're testing , seeing results somehow forgotten. leaving note here.

java - Copy fileto SD Card from Raw folder after context-menu selection? -

i'm (slowly) making app displays list of tones , lets user "long press" 1 brings context menu asking if you'd copy sd card. problem last part, need help. tones stored in raw folder, , need it copies selected tone file sd card, preferably in notifications folder. just wondering if give me example of how go because i'm absolutely lost? here's code import java.util.arraylist; import android.app.listactivity; import android.media.mediaplayer; import android.os.bundle; import android.view.contextmenu; import android.view.contextmenu.contextmenuinfo; import android.view.menuinflater; import android.view.menuitem; import android.view.view; import android.widget.adapterview.adaptercontextmenuinfo; import android.widget.listview; import android.widget.toast; public class mainactivity extends listactivity { private arraylist<sound> msounds = null; private soundadapter madapter = null; static mediaplayer mmediaplayer = null; /** called when activity first

django form without any fields -

what trying achieve is: user fills in form user has option see preview if content provided user can accept preview or work on form my problem when user clicks on preview can pass modelform data , show him. since there no fields in can click on accept publish content. need form deny/accept dialog still related model because have make changes before saving database. i tried exclude fields , fields=none i read this solution looks little hacky. formpreview not want because different approach. is there way create form consists of button? able pass data view view, in worst case hasnt modelform. i found solution fits needs: take any_field , make hidden field: from django.forms import hiddeninput class mymodelform(modelform): class meta: model = mymodel widgets = {'any_field': hiddeninput(),} dont forget exclude other fields.

javascript - Highcharts- How to create streaming bar charts -

i'm new highcharts , need create 1 reporting purposes. creating 1 simple seems 1 asked not simple @ all. should streaming graph if comes in start plotting until done. so scenario this. it needs column chart/columnrange type. the x-axis time. , should moving right left. in 1 second or 2 seconds interval. doesn't matter. so if data comes in, let's call comes in. time comes should start ploting/drawing bar until call done. and should able see stock. pretty 1 in here http://www.highcharts.com/stock/demo/ can select range , zoom in range. i hope i'm making scenario clear enough. reply appreciated. best because haven't provided code go with, response here going more of guidance further research: select chart type column n/a since you're using jquery, if data coming in json format - check out $.getjson otherwise check out $.ajax or similar functions data dynamically. need go through series.addpoint() was asked on stackoverflow

css - Animate using CSS3 -

i have fiddle .according fiddle when class='hide' added span,it should animate,however not working well.i want animate span when class='hide' added.it should animate while changing width. it because defining width: auto 1 of frames of animation. css animations work fixed values. try setting width: 100px example , check out. http://jsfiddle.net/mhj2y/3/ a solution getting & setting width fixed value via jquery on document load.

Mysql/php: Select file extension types simple query? -

i trying select images table. column file_ext , contains jpg, jpeg, mp3, avi , on extensions. how can create sql query this?: and file_ext = 'jpg, jpeg' or select extensions and file_ext = '*' because not want write and file_ext = 'jpg' , file_ext = 'jpeg' .... how guys solve problems this? thanks! try in like select * table mycondition , file_ext in ('jpg','jpeg','png',....) and try avoid mysql_* statements due entire ext/mysql php extension, provides functions named prefix mysql_* , officially deprecated of php v5.5.0 , removed in future . there 2 other mysql extensions can better use: mysqli , pdo_mysql , either of can used instead of ext/mysql .

ember.js - changes not propagated from controller to view -

i thought executing update update view: emberapp.blogcontroller = ember.objectcontroller.extend({ productname: 'test', update : function() { this.set('productname', 'll'); } }); the template is <div> {{productname}} </div> test displayed. calling update has no effect. i call update this: onchange : function(e) { var mycontroller = emberapp.__container__.lookup('controller:blog'); mycontroller.update(); }, // onchange event kendoui grid regards roger i guess should use send invoke methods on controller. try instead: onchange : function(e) { var mycontroller = emberapp.__container__.lookup('controller:blog'); mycontroller.send('update'); }, // onchange event kendoui grid hope helps.

c++ - A CUDA parallel program help needed -

i new cuda , parallel programming. want double parallel part in cuda can me out here. sorry posting here little confused , not find nice tutorial or it. want make function such works parallel in cuda , want make function of cuda called in parallel function possible in kernel function of cuda ? edit for example have 2 kernel functions my_prog , my prog_1 calling them this main_function { my_prog<<core,threads>>(); } my_prog() { //here want call my_prog_1 in parallel my_prog_1<<core,threads>>(); } if want learn how write cuda programs, suggest taking of tutorials available. nvidia has webinar page variety of tutorials. for starters, these 2 webinars give basic intro cuda enough knowledge able write cuda programs run fast: gpu computing using cuda c – introduction (2010) introduction basics of gpu computing using cuda c. concepts illustrated walkthroughs of code samples. no prior gpu computing experience required gpu computi