Posts

Showing posts from July, 2011

ember.js - Ember values in Component not binding -

i have object gets entered component {{edit-general item=item}} inside component, can edit values of array. {{#each value in item.values}} <div class="input-field col s6 l6"> {{input type='text' value=value}} </div> {{/each}} however, value not bind. item gets changed inside component, change not affect model. how make work way want to? jsbin: http://jsbin.com/modunewoca/31/edit?html,output you can't bind simple strings , objects, need wrap ember.object, allows bindings. function m(data) { return ember.object.create({ data: data }); } var model = [ember.object.create({ field: 'ethnicity', values: [m('african american'), m('asian'), m('caucasian'), m('hispanic'), m('other')] }), ember.object.create({ field: 'gender', values: [m('male'), m('female'), m('other'), m('prefer not disclose')] })]; {{#each it

r - How can I add freehand red circles to a ggplot2 graph? -

Image
last year posted an analysis of user activity meta stack overflow , including series of ggplot2 graphs. however, wooble shamed me pointing out fatal flaw plots: freehand red circles are of course necessary in plot on meta stack overflow , dismay not find way add them ggplot2 graph. know how add circle , such artificial construct has no personality , never pass muster on meta. as reproducible example, consider plot of own answering activity on time, created using stackr package: # devtools::install_github("dgrtwo/stackr") library(ggplot2) library(dplyr) library(lubridate) library(stackr) answers <- stack_users(712603, "answers", num_pages = 10, pagesize = 100) answers_per_month <- answers %>% mutate(month = round_date(creation_date, "month")) %>% count(month) ggplot(answers_per_month, aes(month, n)) + geom_line() this plot informative enough, has no soul . how can add freehand red circles it? you can use ggfr

r - In Shiny, how to make tabs appear one at a time without javascript, etc -

i use set of if , else statements select tabsetpanel use. idea have new tabs appear user performs prerequisite tasks. created seems try that, existing tabs reloaded, resetting state of tab, , therefore removing tab added. in example, can see second tab flash existence , disappear. how can make input in each tab persist upon recreation of tabsetpanel ? read response a similar question , not familiar javascript (or whatever code inside tags$script in answer), i'd solution requires r code. the app available on shinyapps . the code pasted below, , available on github . ui.r library(shiny) shinyui(pagewithsidebar( headerpanel("subset data before analyzing"), sidebarpanel(), mainpanel(uioutput("panels")) )) server.r library(shiny) shinyserver(function(input, output) { #this data d1 = data.frame( student = c("abe","bill","clare","abe","bill","clare"), class = c(&qu

java - XStream TreeSetConverter -

i'm having problems while trying unmarshall xml valueobjects, because there treesets along way. i've read necessary implement treesetconverter, in order make work, still don't understand why: http://x-stream.github.io/faq.html#serialization_implicit_different_type and i've found sample of treesetconverter: http://opensourcejavaphp.net/java/xstream/com/thoughtworks/xstream/converters/collections/treesetconverter.java.html i've read on xstream site implicit collections: "that collections additional information (e.g. treeset comparator) cannot restored, since comparator omitted @ serialization time". does mean can't marshall/unmarshall valueobjects treesets? about treesetconverter: converts java.util.treeset xml, , serializes associated java.util.comparator. converter assumes elements in xml sorted according comparator. this similar collectionconverter additional field storing java.util.comparator associated trees

c# 4.0 - How can I display error icon in cell of datagridview -

i working datagridview. need display error icon in each cell of datagridview, if cell empty. cells validated on button click , error icon need displayed. can please share ideas regarding same. you can use cellpainting event custom visuals on cells. it's lot of work add icon 1 column, msdn provides lot of example code can steal , modify suit own needs.

javascript - Ajax-JSON method 405 -

i don't understand error, want add new data in file json ajax : my script : function question(title, fa, sa){ this.title = title; this.fa = fa; this.sa = sa; } $(function() { $('#form').submit(function(event){ event.preventdefault(); var title = $('#title').val(); var fa=$('#firstalternative').val(); var sa=$('#secondalternative').val(); var q1 = new question(title,fa,sa); $.ajax({ url:"http://localhost:5000/gree/questions", type:"post", contenttype:"application/json", data : json.stringify(q1), datatype:"json", jsonpcallback:'jsoncallback', jsonp:false, success:function(data){ alert("hahahahahhahah"); }, error: function(){console.log('error');} }); return false; }); }); my form : my form basic, id

pip - How to remove package installed as egg? -

my pip3 list shows line: pulsar (3.4.0-beta.1, /home/dejan/work/myproject/src/pulsar) i can't find way remove it. normal pip3 uninstall not work. ideas? project work on has requirements.txt file following line: -e git+https://github.com/quantmind/pulsar.git#egg=pulsar - hope helps find out why can't uninstall it... here tried: dejan@mypc:~$ pip3 uninstall pulsar can't uninstall 'pulsar'. no files found uninstall.

javascript - d3 with jade template -

i new both d3 , jade. have jade template below, div(id='viz') script(type="text/javascript") d3.select("#viz") .append("svg") .attr('width', 600) .attr('height', 300) .append('circle') .attr('cx', 300) .attr('cy', 150) .attr('r', 30) .attr('fill', '#26963c') i trying add small circle in div viz . when page loaded dont see circle, html code via inspector below, <div id="viz"></div> <script type="text/javascript"><d3 body class="select"><div svg class="append"><div width 600 class="attr"></div><div height 300 class="attr"></div><div circle class="append"><div cx 300 class="attr"></div><div cy 150 class="attr"></div><div r 30 class="attr"&g

javascript - How do I handle a mouse event within an element, but not on one of its children? -

i want handle mousedown event 1 way on parent element, handle differently if event occurs on child of parent. this: $('.parent').on('mousedown', function(){ //stuff }); will fire if element within .parent clicked, want trigger function if parent element element being clicked, not 1 of it's children. how can this? bind handler child element, , use event.stoppropagation() in child handler. event won't bubble out parent.

c# - Nhibernate use extention functions in Query -

i have written query: from order in session.query<orm.entities.order>() order.finishable() select order); where finishable method containing business logic returns bool. nhibernate returning system.notsupportedexception: boolean finishable() exception. the logic in finishable() bit more complex. questions are: what can allow use of custom functions in queries? have change signature of method? is idea in way? try rewrite logic work nhibernate. result in duplicating logic somehow. unavoidable in case? i try fetch data necessary compute finishable() afterwards, first orders , fill them data, , after use function is. so best solution? any actual named function write going compiled compiler, , unusable linq query provider. you need create expression represents operation have. you want use lambda create expression, don't need inline lambdas, typical. can create method/property/fi

R how to extract specific elements in a data frame consisting of character lists -

i have data frame labels consisting of 3 rows of 1 column this: labels labels(n) 1 text, commission20120125 2 text, council2015mmdd 3 text, parliament20140312 with: labels[1,] [[1]] [1] "text" "commission20120125" and: labels[2,] [[1]] [1] "text" "council2015mmdd" and: labels[3,] [[1]] [1] "text" "parliament20140312" is there "simple" way access "text" , put in vector, this: c("commission20120125", "council2015mmdd", "parliament20140312") as solution far manually do: l1 <- as.vector(labels[1,]) l1 <- unlist(l1) l1 <- str_extract(l1, "[a-z][a-z]+[0-9]+") l <- l1[2] and on every raw. you may try sapply(labels[,1], '[',2) #[1] "commission20120125" "council2015mmdd" "parliament20140312" data labels

MongoDB CRM Database Design Efficiency -

in crm plan able support scale of 100 businesses now, ideally scale size. the way it's set right now: each business has 3 sections of data each section has 1000 "entries" each entry has 30 - 50 "data chunks" - each data chunk has id, entry corresponds to, value indicate type of data is, , value it's holding. 100 * 3 * 1000 * 30 = 9000000 pieces of data. i'll pulling 100 entries @ given time 3000-5000 or data chunks being pulled, once in while many 1000 entries or more @ once. i have collections businesses, sections, entries, , data chunks. i'm setting way because business keeping different kinds of data others , sql database doesn't work that. a sample generation of data might this: find 1 section name (ie business1 has section called section1) find 100 entries section find 30 data pieces each of entries that'd result in 101 find calls. find call entries , find call data array has 100 or key/value pairs, pull 100 dat

html - Trouble with vertical line between two divs' -

Image
i'm trying create vertical line divides 2 div's word or in middle of line(s). i'd vertical lines span entire height, instead 1px each. css needs responsive , height of form fields change depending on selection, can't use fixed height. <section> <div class="row"> <div class="col-md-5">form fields left</div> <div class="col-md-2"> <div class="col-md-12 v-separator"></div> <div class="col-lg-12" style="text-align: center">or</div> <div class="col-md-12 v-separator"></div> </div> <div class="col-md-5">form fields right</div> </div> </section> .col-md-2,.col-md-5,.col-md-12 { float:left; position:relative; min-height:1px; padding-right:15px; padding-left:15px } .col-md-2{width:16.66666667%} .col-md-5{width:41.66666667%}

How to access repo directory in a Perl program in Openshift? -

i hit 404 error when use following code in index.pl (i create 1 perl app in account) my $hello_link = "$env{'openshift_repo_dir'}hello.pl"; click <a href="$hello_link"><font color="ff00cc">here</font></a> run hello world cgi.</br> when log web autortl-rdlgen.rhcloud.com , click on ¨here"to run hello program. error message showed not found the requested url /var/lib/openshift/550f4df1fcf933b971000030/app-root/runtime/repo/hello.pl not found on server. i have uploaded hello.pl repo directory , can find after ssh account: [autortl-rdlgen.rhcloud.com repo]\> ls -tr hello.pl hello.pl you need use relative link "./hello.pl" instead of using other link env variable, showing complete filesystem path perl file. you may want check out perl tutorials started perl web programming: http://www.tutorialspoint.com/perl/perl_cgi.htm

Create Twitter app - Rate Limit Exceeded -

when creating new twitter app @ https://apps.twitter.com/ receive following error upon clicking submit. "error: rate limit exceeded" according other developers on twittercommunity.com, seems recent bug affecting new apps... there solution soon edit: trying create new application past 2 days , succeeded... looks bug , it's ok now... try :) https://twittercommunity.com/t/rate-limit-exceed-in-creating-new-app-at-apps-twitter-com/34985 https://twittercommunity.com/t/rate-limit-exceeded-when-i-try-to-create-an-application/21453/3

c++11 - C++ parameter pack fails to expand -

i'm playing variadic templates , can't understand why following code won't compile (gcc 4.9.2 std=c++11): it's example, need similar kind of use in code , fails well: template<int i> class type{}; template<typename ... tlist> class a{ public: template<int ...n> void a(type<n> ... plist){ } }; template<typename ... tlist> class b{ public: template<int ... n> void b(type<n> ... plist){ a<tlist...> a; a.a<n...>(plist ...); } }; and use example: b<int, int, int> b; b.b<1,7,6>(type<1>(),type<7>(),type<6>()); i following error: file.cpp: in member function ‘void b<tlist>::b(type<n>...)’: file.cpp:58:9: error: expected ‘;’ before ‘...’ token a.a<n...>(plist ...); ^ file.cpp:58:24: error: parameter packs not expanded ‘...’: a.a<n...>(plist ...);

Meaning of the PMI bit in the SCSI READ CAPACITY command -

i'm looking @ sbc-3 item 5.15 (read capacity (10) command). description of pmi bit (bit 0 of byte 8 in cdb) copied below: "a pmi bit set 1 specifies device server return information on last logical block after specified in logical block address field before substantial vendor specific delay in data transfer may encountered." my questions: if both pmi bit , logical block address (bytes 2-5 in cdb) aren't zero, should (as target) still report last lba on disk? if not above, should reported in case? what should logical block address (bytes 2-5) value when pmi bit set? (i know, pmi bit became obsolete in sbc-4, still need implement functionality according current standard) this out in sbc-3 now, of revision 28 (january, 2011) can see change here: (sign required) http://www.t10.org/cgi-bin/ac.pl?t=d&f=11-010r0.pdf . so, you're talking sbc-2 compatibility. anyway, don't think you'll ever see these fields set in practice. but, s

c# - Xamarin StreamWriter -

could hep me doubt have? i have embedded resource text file, , when try use streamwriter write on it, error: "a system.argumentexception thrown. can not write stream." this code: var assembly = assembly.getexecutingassembly(); var resourcename = "supermimo2.products.txt"; using (stream stream = assembly.getmanifestresourcestream(resourcename)) using (streamwriter writer = new streamwriter(stream)) { writer.writeline(txtlines.text); } could tell me can do? thanks attention! android , ios packages/bundles signed , not writable. write file, have use 1 of appropriate file system folders provided os. for ios, refer guide: http://developer.xamarin.com/guides/ios/application_fundamentals/working_with_the_file_system/ for android, can do var path = environment.getfolderpath(environment.specialfolder.applicationdata); var filename = path.combine(path, my_file_name); if want include file app , write it, first need include asset in app'

android - AsyncTask Cannot execute task: the task has already been executed -

i know previous execution of asynctask running - question how finish , re-execute , because parameters has been changed. protected class imagedownloadtask extends asynctask<response, void, void>{ @override protected void onpreexecute() { super.onpreexecute(); pooltasks.add(this); } @override protected void doinbackground(response... params) { int count=params[0].getgetposts().getpostscount(); for(int = 0; < count; i++){ post post = params[0].getgetposts().getposts(i); if(!iscancelled()){ try { //some code download images } catch (exception e) { } publishprogress(); } else pooltasks.remove(this); } return null; } @override protected void onpro

html - Facebook Page Plugin width doesn't apply -

Image
i'm trying implement facebook page plugin . set width 500, stays @ 280px. <div id="facebook-feed" style="text-align: center"> <div class="fb-page zdepth-1" data-width="400" data-href="https://www.facebook.com/facebook" data-hide-cover="false" data-show-facepile="true" data-show-posts="true"></div> </div> what doing wrong? the page plugin tries fit in smaller containers/screens the plugin renders @ smaller width (to fit in smaller screens) automatically, if container of slimmer configured width. it tries render nicely on smaller screens assuming container squeezes mobile. so probably, in case container holding plugin smaller configured width i.e. 500px .

angularjs - How to keep yeoman angular app alive using grunt-forever? -

i have yeoman angular based app run grunt serve . it critical keep application running time. i've used forever before , it's worked fine works on particular js file. whereas want use grunt serve task. i found plugin called grunt-forever - https://github.com/bustardcelly/grunt-forever - don't know how set gruntfile.js use call grunt serve command. the server section of grunt file standard 1 gets generated yeoman angular application. follows - grunt.registertask('serve', function (target) { if (target === 'dist') { return grunt.task.run(['build', 'express:prod', 'open', 'express-keepalive']); } grunt.task.run([ 'clean:server', 'bower-install', 'concurrent:server', 'autoprefixer', 'express:dev', 'open', 'watch' ]); }); anyone know how use grunt-forever call command? i trying figur

php - Optimalization task -

i have problem optimalization function generate document tax free. i add order positions : name, price, weight , numbers (count). like: product = array(); product[0] = array('name'=>'product_a','price'=>32.00,'weight'=>5.23,'numbers'=>100); product[1] = array('name'=>'product_b','price'=>22.00,'weight'=>2.23,'numbers'=>140); product[2] = array('name'=>'product_c','price'=>12.10,'weight'=>3.03,'numbers'=>150); product[3] = array('name'=>'product_d','price'=>5.12,'weight'=>4.03,'numbers'=>10); product[4] = array('name'=>'product_e','price'=>52.22,'weight'=>5.13,'numbers'=>22); no positions have generate smallest document tax free. in 1 document can have sum weight max 50 , sum price 2000 (price 1 element. if have numbers

python - Wrapping C/C++ Library with SWIG -

i've got project i'm working on requires use of topaz signature capture pad. our product uses activex control provided topaz collecting signatures on website, we're trying move desktop application powered python. python allow branch out multiple os's without work. topaz provides 'c' library ( http://www.topazsystems.com/sigpluslibrary.html ) interfacing devices. believe i've determined c++ (uses classes , other c++ constructs). i've attempted create wrapper python using swig , cython, have not had whole lot of luck. my directory structure swig this: sigswig includes (contains of headers topaz shared c library) setup.py siglib.i signature.i etc... setup.py # setup.py import distutils distutils.core import setup, extension module = extension( "_siglib", ["siglib.i"], swig_opts=['-c++'], language='c++',

mysql - How to add more than one value to a database table row? -

i have 2 tables named event , activity . have eventid foreign key of activity table , activityid fk of event table. problem is, activity can have 1 event, event can have many activities. can add 1 value activityid column in event table. can please suggest me solution it? you need junction table . . . eventactivities , this: create table eventactivities ( eventactivitiesid int not null primary key auto_increment, eventid int not null references events(eventid), activityid int not null references activities(activityid) ); then database have 3 tables, , don't need column directly connecting activities , events .

Tesseract OCR finds too few boxes / ignores small characters -

i have problem training/text recognition process tesseract. here trainingdata: http://s11.postimg.org/867aq10ur/dot_dotmatrixfont_exp0.png while training tesseract ignores dashes (i've marked them red boxes, make clear ones mean) , if i'm using trained data text recognition ignores them. today i've played around tesseract parameters (setvariable(name, value)) unfortunately had no success. can teach tesseract dashes? thank in advance! tesserect training pretty tricky. your best chance might handle dashes single char. if box editor or whatever tools using not see dashes all, try running image processing first, threshold or invert. try taking @ opencv. have excellent tool kind of image processing.

javascript - Open several times multiple file input without losing earlier selected files -

i have multiple file input. want customers choose multiple files when click on 'choose files' (i think done) , if forget select files, want code enable selecting new files (done) , add data data have selected before (couldn't solve it). how can append new files list? just give context: goal after send each file ajax php server. $("#upload-form").submit(function(e) { $('#displayfilenames').html(''); console.log('currently in files.'); var files = $('#myfileinput')[0].files; (var = 0; < files.length; i++){ $('#displayfilenames').append(files[i].name + '</br>'); console.log(files[i].name); } // send data ajax. }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form id='upload-form' action='' method='post' enctype='multipart/form-data'> <input id='myfi

eclipse - The moment I add glew.h in my code glut related errors start appearing -

i new c/c++ environment setup. right using eclipse ide. below steps have followed after installing mingw , running basic helloworld, c program 1) copied glew32.dll , glut32.dll "c:\mingw\bin" 2) copied gl.h, glew.h, glu.h , glut.h "c:\mingw\include\gl" 3) copied glew32.lib, glut32.lib , opengl32.lib "c:\mingw\lib" 4) in project->properties->c/c++ build->settings->tool settings->mingw c linker->libraries(-l) added "glew32", "glut32","glu32" , "opengl32" 5) copied below code compiles properly. the moment uncomment first line, ie glew.h, glut related compile errors (added below) appear, can 1 tell me going wrong during setup? //#include <gl/glew.h> #include <gl/gl.h> #include <gl/glut.h> void changeviewport(int w, int h) { glviewport(0, 0, w, h); } void render() { glclear(gl_color_buffer_bit | gl_depth_buffer_bit); glutswapbuffers(); } int main(int argc, char

Python Pandas - Logical indexing dataframe with multiple indexes based on single index -

i'm still pretty new pandas i've searched around quite bit , can't quite find i'm looking for. so here problem: i have 2 dataframe - 1 mutliple indexes , 1 index df1= value1 value2 ind1 ind2 1 1.1 7.1 b 2 2.0 8.0 c 3 3.0 9.0 4 4.0 10.0 b 5 5.0 11.0 c 6 6.0 12.0 df2= value1 value2 ind1 8.0 7.0 b 9.0 8.0 c 3.0 9.0 d 11.0 10.0 e 12.0 11.0 f 1.0 12.0 i index data df1 based on df2 value1 > value2 . df2['value1'] > df2['value2'] i know can data df2 with df2.loc[df2['value1'] > df2['value2']] but how data df1? tried: df1.loc[df2['value1'] > df2['value2']] but fails with *** indexingerror: unalignable boolean series key provided any suggestions appreciated, thank you!

java - how to know the data size returned from mysql server with connector-j -

i using mysql connector-j java perform query. know size of data returned when use with/without compression. best way obtain total amount of data passed server client? the code using works preparedstatement , resultset : preparedstatement preparedstatement = connection.preparestatement(sql); rs = preparedstatement.executequery(); while (rs.next()) { function.apply(rs); } can obtain amount of data in java? there external way it? you can make that: stringbuffer sb = new stringbuffer(); while (rs.next()) { function.apply(rs); sb.append(<your_data>); } double len = sb.tostring().length() / 1024;

Why can't Git handle large files and large repos? -

dozens of questions , answers on , elsewhere emphasize git can't handle large files or large repos. handful of workarounds suggested such git-fat , git-annex , ideally git handle large files/repos natively. if limitation has been around years, there reason limitation has not yet been removed? assume there's technical or design challenge baked git makes large file , large repo support extremely difficult. lots of related questions, none seem explain why such big hurdle: git large files what file limits in git (number , size)? git - repository , file size limits versioning large text files in git how handle large git repository? managing large binary files git what practical maximum size of git repository full of text-based data? [quora] basically, comes down tradeoffs. one of questions has example linus himself: [...] cvs, ie ends being pretty oriented "one file @ time" model. which nice in can have million files, , check out

IF THEN on a Dataframe in r with LAG -

i have dataframe multiple columns, 2 columns in particular interesting me. column1 contains values 0 , number (>0) column2 contains numbers well. i want create 21 new columns containing new information column2 given column1. so when column1 positive (not 0) want first new column, column01, take value column2 goes 10 back. , column02 goes 9 back,.. column11 exact same column2 value.. , column21 10 forward. for example column 1 column2 columns01 columns02.. columns11..columns20 columns21 0 5 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 1 3 0 0 3 5 4 0 10 0 0 0 0 0 0 83 0 0 0 0 0 0 2 0 0 0 0

eclipse plugin - XTEXT based DSL Save All before Build -

i have eclipse rcp dsl application. build option not work in case end user not save manually changed files. need find following : - can save dsl source file automatically when user click "build all" menu item. other hand have set "save before build" option programmaticaly thank alex there 'save automatically before build' option in preferences in 'general > workspace'. if option set build action like: iworkbenchwindow[] windows = platformui.getworkbench().getworkbenchwindows(); (iworkbenchwindow window : windows) { iworkbenchpage[] pages = window.getpages(); (iworkbenchpage page : pages) { page.savealleditors(false); } }

c# - using linq on datatable and putting result back into datatable with same format -

what m trying relatively simple. use linq compute aggregated function on group , put result datatable of same format. did lot of research , think should use system.data.datasetextensions , copy datatable funtion. here random datatable: datatable adatatable = new datatable("adatatable"); // fake table data adatatable.columns.add("plant", typeof(int)); adatatable.columns.add("pdcatype_name", typeof(int)); adatatable.columns.add("month", typeof(int)); adatatable.columns.add("year", typeof(int)); adatatable.columns.add("status_name_report", typeof(string)); adatatable.columns.add("savings_per_month", typeof(double)); (int = 0; < 15; i++) { (int j = 1; j < 5; j++) { datarow row = adatatable.newrow(); row["plant"] = j; row["pdcatype_name"] = j;

jenkins - Push to git without an email adress -

Image
i'm using jgit.sh on linux trying push file git reppository via shell commands on jenkins. my jenkins jobs following: fetch git repo via jenkins git plugin i use maven commands , additional files created under workspace. use jgit.sh push files git repository. i'm executing following commands: jgit.sh checkout master jgit.sh add ui5propreties.xml jgit.sh commit -m "commit files" jgit.sh push origin master i'm using jgit.sh user called solmanvoter , user doesn't have email adress on git. user. so following error when run job: remote: error: in commit d704a1f404f052f8117b456ac59a67a69cbfc281 remote: error: committer email address remote: error: not match user account. remote: error: remote: error: have not registered email addresses. remote: error: remote: error: register email address, please visit: remote: error: https://git.wdf.sap.corp/#/settings/contact remote: ssh://git.wdf.sap.corp:29418/sandbox/grcsandbox/pr1234_forcecommit

arrays - PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" -

i running php script, , keep getting errors like: notice: undefined variable: my_variable_name in c:\wamp\www\mypath\index.php on line 10 notice: undefined index: my_index c:\wamp\www\mypath\index.php on line 11 line 10 , 11 looks this: echo "my variable value is: " . $my_variable_name; echo "my index value is: " . $my_array["my_index"]; what these errors mean? why appear of sudden? used use script years , i've never had problem. what need fix them? this general reference question people link duplicate, instead of having explain issue on , on again. feel necessary because real-world answers on issue specific. related meta discussion: what can done repetitive questions? do “reference questions” make sense? notice: undefined variable from vast wisdom of php manual : relying on default value of uninitialized variable problematic in case of including 1 file uses same variable name. majo

Best place to enable lazy loading in entity framework 6 -

what best place keep lazyloading enable condition in web application. because when using database first approach of ef , when try update context setting got wiped out. below settings. public dbentities(): base("name=dbentities") { this.configuration.proxycreationenabled = true; this.configuration.lazyloadingenabled = true; } what best way these setting should not vanish after edmx update. there chance keep in global.asax. if yes downsides?. your placement looks fine. note, gert arnold has stated, these defaulted true . so, public dbentities(): base("name=dbentities") { } is need sake of brevity here, excluding explicitness.

vb.net - Conversion from type 'DBNull' to type 'Date' is not valid on tryparse -

i attempting datetime.tryparse date-formatted string, new column created part of dataview table. getting error when code runs conversion type 'dbnull' type 'date' not valid. this line of code: datetime.tryparse(dr("ix_articlestartdate"), dr("nstartdate")) and these values in watch when errors out. + dr("ix_articlestartdate") "2015/3/11" {string} object + dr("nstartdate") {} object i under impression tryparse return null value if fails convert datatypes. there should doing different convert string datetime datatype? dr instantiated datarow dim dr datarow = dv0.table.rows(i) vb implicitly try's cast dbnull value datetime, since method signature of datetime.tryparse is public shared function tryparse(s string, byref result date) boolean which fails. can use variable instead: dim startdate datetime if datetime.tryparse(dr("ix_articlestartdate").tostr

Block change value of variable when refresh page in javascript -

i have 2 variables name first , last. when window size less 768px, want first = 1 , last = 5. , when window size greater 768px, first = 1 , last = 3. here code. var first = 1; var last = 5; window.onresize = function(){ var w = window.innerwidth || document.documentelement.clientwidth || document.getelementsbytagname('body')[0].clientwidth; if (w <= 768){ first = 1; last = 3; } if (w > 768){ first = 1; last = 5; } } it's worked. when window size 600px (less 768px), press f5 (refresh), first variable = 1 , last = 5 (these values changed). want when press f5, if window less 768px, still 1 , 3. can now? me. thanks. this how should be. so now, have 1 function set variables per width of window. call 2 times when page loaded, should set variables (first,last) per size of window when page resized, should set variables again. var first = 1; var last = 5; function setvari

python - What path to enter in PyQt QIcon.setThemeSearchPaths() in pyqt on win7? -

as written in docs edit setthemesearchpaths() current code: if __name__ == "__main__": app = qtgui.qapplication([]) path in qtgui.qicon.themesearchpaths(): print "%s/%s" % (path, qtgui.qicon.themename()) it prints out: c:/python27/icons/ :/icons/ and no icons found. ask path have pass input argument in function setthemesearchpaths() on win7? as found out icons should on path/file: c:\windows\system32\imageres.dll but if input path .dll file nothing happens? windows doesn't have icon themes. qt uses freedesktop icon specification . using default paths, either extract icon theme c:/python27/icons/ or embed qt resource. you can try download faenza icons. should end file structure like: icons/<theme name>/index.theme icons/<theme name>/apps/ icons/<theme name>/actions/ ...

java - What do these JDatePicker Properties do? -

i viewed following code in context of implementing jdatepicker in this post . utildatemodel model = new utildatemodel(); //model.setdate(20,04,2014); // need this... properties p = new properties(); p.put("text.today", "today"); p.put("text.month", "month"); p.put("text.year", "year"); jdatepanelimpl datepanel = new jdatepanelimpl(model, p); // don't know formatter, there is... jdatepickerimpl datepicker = new jdatepickerimpl(datepanel, new datelabelformatter()); i wanted know properties keys "text.month" , "text.year" do. tried implementing code , no change when omitting them. furthermore, tried searching list of keys in properties class , found nothing helpful. know these property keys or how find out if omitting them acceptable? these internationalization support. jdatecomponentfactory has code load locale-dependent resource bundles in jdatepicker distribution. think you're s

objective c - Parse.com - after remove row from Installation class at Data Table my device token is not rcognize anymore -

after remove row installation class data table device token not recognize anymore. the didregisterforremotenotificationswithdevicetoken method not called anymore when app load. i'v tried restore iphone, nothing happen. try un-installing application reinstalling it. should trick.

python - Is there an easy way to get probability density of normal distribution with the help of numpy? -

i know, can use own function this: def gauss(x, mu, sigma): return (2*pi)**(-0.5) * sigma**(-1) * math.exp( - 0.5 * ((x - mu) / sigma)**2) probably, knows standard numpy or scipy function exists same? thanks! you can use scipy : from scipy.stats import norm x = np.arange(20) mu = 5 sigma = 3 mypdf = norm.pdf(x=x, loc=mu, scale=sigma)

android - uiautomator feature not consistent with all ROM -

i writing simple ui test app following uiautomator guildline . mentioned sample worked on s5, fail on of occasion. not sure why? another issue: same thing not working on mob sony-z have tested. following error log: com.android.uiautomator.core.uiobjectnotfoundexception: uiselector[description=apps] at com.android.uiautomator.core.uiobject.clickandwaitfornewwindow(uiobject.java:432) @ com.android.uiautomator.core.uiobject.clickandwaitfornewwindow(uiobject.java:410) @ com.org.example.test.launchsettings.testdemo(launchsettings.java:26) @ java.lang.reflect.method.invokenative(native method) @ com.android.uiautomator.testrunner.uiautomatortestrunner.start(uiautomatortestrunner.java:160) @ com.android.uiautomator.testrunner.uiautomatortestrunner.run(uiautomatortestrunner.java:96) @ com.android.commands.uiautomator.runtestcommand.run(runtestcommand.java:91) @ com.android.commands.uiautomator.launcher.main(launcher.java:83) @ com

mysql - Search order by query string -

i use following working mysql query: select nom_appellations appellations nom_appellations '%saint%' limit 8 and have result : lussac-saint-emilion montagne-saint-emilion puisseguin-saint-emilion saint-emilion saint-emilion grand cru saint-emilion grand cru classé but want order string "saint" pertinence this: saint-emilion saint-emilion grand cru saint-emilion grand cru classé lussac-saint-emilion montagne-saint-emilion puisseguin-saint-emilion how can data order featured string ? you can first appearance of saint in nom_appellations : select nom_appellations appellations nom_appellations '%saint%' order locate('saint', lower(nom_appellations)) limit 8;

c# - Migrate Post action to web forms -

i have action on mvc application , need same thing in application uses web forms. i'm sorry if such stupid thing i'm not expert on web forms. this action: [httppost] public actionresult login(string username) { } how do httppost in web form? update i discovered if put (page.request["login"]) in code i'm able retrieve post parameters. i believe want use httpwebpost class class. something private void onpostinfoclick(object sender, system.eventargs e) { string strid = userid_textbox.text; string strname = name_textbox.text; asciiencoding encoding=new asciiencoding(); string postdata="userid="+strid; postdata += ("&username="+strname); byte[] data = encoding.getbytes(postdata); // prepare web request... httpwebrequest myrequest = (httpwebrequest)webrequest.create("http://localhost/default.aspx"); myrequest.method = "post

python - Insert into MongoDB retuns cannot encode object -

i'm doing rather simple insert local mongodb sourced of python pandas dataframe. i'm calling datframe.loc[n].to_dict() , getting dictionary directly df. far until attempt insert, i'm getting 'cannot encode object'. looking @ dict directly showed looked (while writing question) dawned me check each type in dict , found long id number had converted numpy.int64 instead of simple int (which when created dict manually int insert fine). so, unable find within pandas documentation on adding arguments to_dict allow me override behavior , while there brute force methods fixing issue, there must bit more eloquent way sort issue without resorting sort of thing. question then, how convert row of dataframe dict insertion mongodb, ensuring using acceptable content types ... or, can further here , use simpler approach each row of dataframe document within mongo? thanks as requested, here addendum post sample of data using. {'account created': 'about 3 hou

python - Django project on two domains - limiting access to urls/views -

i working on django project. utilizes multiple small apps - 1 of them used common things (common models, forms, etc). i want separate whole project 2 domains, i.g.: corporatedomain.com , userportal.com i want corporatedomain.com use different urls, same userportal.com. is possible? if so, how can this? how should configure urls? you have separate settings file anyway define different root_urlconf each domain. update : if don't want use different settings have write middleware change request.urlconf attribute using http_host header. here example of such middleware .

if statement when environment variable exists/not exists in batch files -

i want check if environment variable set in pc. if yes x if not y. i tried these , variations of them: if exists %sign% runtest.exe --redirect -l %name% else runtest.exe -l %name% if "%sign%" == "" runtest.exe --redirect -l %name% else runtest.exe -l %name% none of them work in both cases (when environment variable sign exists , when doesn't exist).sometimes in 1 case... please can help? thanks! if conditionally perform command if defined sign ( runtest.exe --redirect -l %name% ) else ( runtest.exe -l %name% ) or shortly if defined sign (runtest.exe --redirect -l %name%) else (runtest.exe -l %name%) valid syntax: all ) , else , ( must on line follows: ) else ( note : if defined return true if variable contains value (even if value space). according above predicate, if defined sign condition seems equivalent reformulated test if not "%sign%"=="" valid in batch only , %undefined_vari

rust - How do I automatically clear an attribute in a struct when it is moved? -

i have struct struct test { list: vec<u64> } and method in vector , erase list field empty vec fn get_list(&self) -> vec<u64> { let list = vec::new(); item in self.list.drain() { list.push(item); } list } it there approach doing it? autoreinit field on moving value, example: fn get_list(&self) -> ???<vec<u64>> { self.list } here solution, can test on rust playground (sadly share button doesn't work me atm). use std::mem; #[derive(debug)] struct test { list: vec<u64> } impl test { fn get_list(&mut self) -> vec<u64> { let repl = mem::replace(&mut self.list, vec::new()); repl } } fn main() { let mut r = test { list : vec![1,2,3] }; print!("r : {:?} ", r); print!("replace : {:?} ", r.get_list()); print!("r : {:?} ", r); } you need run mem::replace ( docs ) on mutable value , replace

java - delete persisted object in one to one relation -

i'm using openjpa mapping layer , have 2 models : user : @entity @table(name = "users") public class user { @id @generatedvalue(strategy = generationtype.sequence,generator = "user_id_gen") @sequencegenerator(name = "user_id_gen", sequencename = "manage.users_id", allocationsize=1) @column(name = "id", nullable = false) private int _id; @onetoone (cascade=cascadetype.all, fetch = fetchtype.eager) @joincolumn(name="fk_image_id", insertable=true, updatable=true, nullable = true) private image _image; and image @entity @table(name = "images") public class image { @id @generatedvalue(strategy = generationtype.sequence,generator = "images_id_gen") @sequencegenerator(name = "images_id_gen", sequencename = "manage.image_id", allocationsize=1) @column(name = "id") private int _id; it's unidirectional 1 one relatio

html5 - <picture> element doesn't work correctly - works partially on new devices -

i trying use <picture> element change size of logo if visits website mobile devices example. this code i'm using : <picture> <source srcset="http://www.pixelmedia.ro/ina/wp-content/themes/compass/ina/logo.jpg" media="(min-width: 1125px)"> <source srcset="http://www.pixelmedia.ro/ina/wp-content/themes/compass/images/logo-mobile.jpg" media="(min-width: 768px)"> <source srcset="http://www.pixelmedia.ro/ina/wp-content/themes/compass/images/logo-mobile.jpg" media="(max-width: 1123px)"> <img src="http://www.pixelmedia.ro/ina/wp-content/themes/compass/ina/logo.jpg" alt="alt text examplle!"> </picture> problem code works partially. example works on android cell phone latest version of chrome doesn't work on iphone 6. works on desktop , if resize de browser window change logo. however, not case on many new tablets. question problem ... ma