Posts

Showing posts from September, 2014

c# - Calling Soap web service over HTTP giving exception "Connection close" -

i calling third party web service on http failing connect in wpf application/console application. exception connection close. wondering why closed though same soap message works in soap ui. can give action urn copyed soap ui. please suggest wrong. since not using browser cros domain problem should not be. my c# code follows. using system; using system.collections.generic; using system.io; using system.linq; using system.net; using system.text; using system.windows; using system.windows.controls; using system.windows.data; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.imaging; using system.windows.navigation; using system.windows.shapes; using system.xml; namespace ctwpfapp { /// <summary> /// interaction logic mainwindow.xaml /// </summary> public partial class mainwindow : window { public mainwindow() { initializecomponent(); } priv

java - Paypal Sandbox payment state pending -

i using (java) rest api perform payments directly credit cards in sandbox. payments receive "pending" status, according docs ( https://developer.paypal.com/webapps/developer/docs/api/#create-a-payment ) not valid state returned payment create call. payment review disabled. i see process through , complete transaction. how do in sandbox? or should receive different state right away? under http://developer.paypal.com , application tab, find out email associated rest app. click on "sandbox accounts", click on rest app email, click on "profile" link. select "setting" tab, , turn off "payment review". shall "approved" payment , "completed" sale json object.

forms - Select option in PHP not echoing back correctly -

as precursor, worth mentioning new @ php. i've spent 3 hours working on seems should simple fix. using php echo form after choosing submit, drop-down menu echoing first name, regardless of 1 selected. here code: <form action="echo_form_email.php" method="get"> <p> <div id="cheddar">cashier: <input id="cashier" name="cashier" type="text"></div> </p> <p> <div id="q">did cashier front register?</div> <div id="radio1"><input type="checkbox" name="front_register" value="yes">yes</div> <div id="radio2"><input type="checkbox" name="front_register" value="no">no</div> <div id="radio3"><input type="checkbox" name="front_register" value="n/a">n/a</div> </p> <p> <div

plsql - Obtaining a value from 2 different case statements -

i have 2 tables. first, sales table: salesid amount productid monthid 20 10 1 201307 15 25 1 201301 40 20 5 201303 note: more 1000 rows. second, have product table: productid description product_elemid 1 aaa 24 2 bbb 57 5 ccc 23 1 aaa_ace 25 note: 100 rows. now, want display data these 2 tables. have: select p.description case ( when s.monthid between 201301 , 201307 sum(s.amount) else 0 end) case ( when s.monthid between 201303 , 201305 sum(s.amount) else 0 end) sales s, product p s.productid = p.productid , p.productid in ('1, '2', '5') group p.description i table 3 columns: p.description case 1 values case 2 values so far good. want have colum

git - How to add old zipped sources at the beggining of origin trunk? -

when started simple project didn't use repository store changes. created backups simple zip files. have many of them this: backup_1_added_feature_a.zip backup_2_added_feature_b.zip ... backup_n_added_feature_z.zip at point switched git. first commit made last zip sources, , have new commits done: origin/master: (c1)<-(c2)<-(c3) ... ( c1 == backup_n_added_feature_z.zip ) now add backup zip's in main trunk this: origin/master: (zip1)<-(zip2)<-(zip3) ... (zipn)<-(c1)<-(c2)<-(c3) ... is possible in git? there's manual way it. git checkout --orphan newroot git rm -rf . # unzip zip1 project directory git add . git commit -m 'zip1' # unzip zip2 project directory git add . git commit -m 'zip2' ... git rebase --onto newroot --root master git branch -d newroot you can replace manual unpacking/adding/commiting of zip folder bash loop, obviously. see https://stackoverflow.com/a/647451/2578489 explanation.

How to change height of iframe from px to percentile -

i working on wcag 2.0 ,one of requirement says use relative rather absolute units in html attributes. use percentages rather pixels sizing frames , tables . the actual problem iframe controls. when ichange width fine , height not changing when changed px %. the content of iframe cross domain. <div xmlns="http://www.w3.org/1999/xhtml"> <iframe id="led_frame" width="1000" height="900" frameborder="no" title="employment dynamics" src="http://lehd.did.census.gov/led/index.html" name="led_frame" style="margin- left:-35px"> .............. </iframe> </div> i tried 1. adding height container div. 2. adding height body tag. any suggestion helpful..............

grep - How to search a directory/directories in unix by excluding certain file extensions -

i've tried using find . | grep -v '(.ext1|.ext2)$' but still returns files ending extensions .ext1 , .ext2 . tried following: ls | grep -v ".ext1$" | grep -v ".ext2$" and works how want it. there way i'm looking ? want list files or directories not end in .ext1 or .ext2 . you have not escaped . try . work. remember . needs escaped. ls | grep -v '\.ext1$' | grep -v '\.ext2$' same find find . | grep -v '(\.ext1|\.ext2)$' hope helps :)

java - JFrame does not appear -

i'm using intelij idea platform. i have following code: package gui.test; import javax.swing.*; public class frame extends jframe{ frame(){} public void main (string[] args){ new frame(); } } i expected see jframe after compiling code, nothing appeared. kind of problem can be? frames not visible default--use the setvisible(true); method in order display frames. might want take @ other options such as setsize(int width, int height); method resize frame, setlocation(int xloc, int yloc); to move frame, and settitle(string title); to set title of component. aside, practice use variable hold components can manipulated when needed.

java - Can you sort and search on same field with Hibernate/Lucene? -

i have following annotated class trying sort results lucene/hibernate search query. have query working seems when implement necessary annotations (seen on jobstatus) sort column, makes impossible search column. basing off instructions found here on google . have been having issues figuring whole hibernate search , sort thing out, figured out how sort , search need able them together. @entity @table(name="jobreq") @indexed public class jobreq { @id @documentid @generatedvalue(strategy=generationtype.identity) private integer id; @field(index = index.yes) @column(name="jobid", nullable=false, unique=true) private string jobid; @field(index = index.yes) @column(name="jobtitle", nullable=false) private string jobtitle; @field(index = index.yes) @column(name="jobcontract", nullable=false) private string contract; @field(index = index.yes) @column(name="jobproject", nullable=true) private string project; @field(index = index.ye

javascript - Why doesn't backbone use module.exports? -

it looks uses plain exports instead of module.exports in line here . if (typeof exports !== 'undefined') { backbone = exports; however tutorial shows module.exports being used. why doesn't backbone use module.exports? because doesn't have to. exports , module.exports refer same object : in particular module.exports is same exports object. if can save couple of characters type, why not it? you doing same when use document.getelementbyid instead of window.document.getelementbyid . it's more type , doesn't add benefit. in tutorial using module.exports because want show difference between exporting symbol why exports , i.e. exports.foo = bar; and overwriting exports object module.exports = bar; for have to use module.exports ( exports = bar; not work).

javascript - Pass variables to handlebars helper call -

i'd pass template data "textfield" helper method have defined, this: {{textfield label="{{label}}" id="account_{{attributes.id}}" name="account[{{attributes.name}}]" class="some-class" required="true"}} (note {{label}} , {{attributes.id}} references inside {{textfield}} helper call) here set template: data = { "attributes": { "id": "name", "name": "name" }, "label": "name" } var templatehtml = 'markup here'; var template = handlebars.compile(templatehtml); var formhtml = template(data); here jsfiddle . when run this, still see {{placeholders}} in compiled markup. how can accomplish this? you're using incorrect syntax pass named parameters handlebars helper. want this: var data = { "attributes": { "name": "name" } }

javascript - Jquery Scrolling and Previous and Next Div Buttons -

so i'm trying have previous , next buttons on top of div, , when click on them takes me next , previous div it's supposed to. here's code: $('button.navbutton').on('click', function(e) { if ($(this).hasclass('next') && $('.selected').next('div.day').length > 0 ) { var $next = $('.selected').next('.day'); var top = $next.offset().top; $('.selected').removeclass('selected'); $('body').animate({ scrolltop: top }, function () { $next.addclass('selected'); }); } else if ($(this).hasclass('prev') && $('.selected').prev('div.day').length > 0 ) { var $prev = $('.selected').prev('.day'); var top = $prev.offset().top; $('.selected').removeclass('selected'); $('

eclipse - android target 16 needed when 18, 15, and 8 already downloaded? -

i have imported project these settings : <uses-sdk android:minsdkversion="11" android:targetsdkversion="15" /> and had downloaded packages 18 , 15 , 8. there error saying : "unable resolve target 16" , know why? there somewhere else option "api 16 needed" ? , isn't enough have 3 packages ? thanks there error saying : "unable resolve target 16" , know why? the build target of project (e.g., project > properties > android) set api level 16. eclipse should have automatically changed 18, given described setup (first available higher sdk).

The import com.google.android.vending cannot be resolved in an imported android project -

i have imported android project , when trying run it giving me error on following imports import com.google.android.vending.licensing.aesobfuscator; import com.google.android.vending.licensing.licensechecker; import com.google.android.vending.licensing.licensecheckercallback; import com.google.android.vending.licensing.servermanagedpolicy; any resolving appreciated. you may want review steps this link . goes through steps of adding android project, regardless of ide. eclipse work fine. these steps take time , effort, have done before.

ruby on rails - Checking a hash for the existence of a matching value -

i'm building school calendar lists classes ("sections") , displays semester , exam dates classes. calendar fed hash defined in section.rb model: def get_calendar calendar = {} calendar[:semesters] = semester.where(section_id: self.id) calendar[:exams] = exam.where(section_id: self.id) { :calendar => calendar } end the semester , exam objects have name , start_date , end_date . when looping through each day of calendar, how can check if there's semester or exam a start_date or end_date for day of loop? if there semester or exam either start_date or end_date matches calendar date, display name. the calendar dates , start_date , end_date fields use date class ( link ). i sincerely appreciate help. can clarify question if needed :) thank you! maybe should re-think hash, , use way: def get_calendar semesters = self.semesters exams = self.exams events = { } (semesters + exams).each |event| sta

mysql - django 1.5 multiple joins -

i have 3 tables wish show relate each other 4th table name pivot # manufacturer id | name # product id |name # part id| name # pivot id | part_name_fk | product_name_fk | manufacturer_name_fk ... , 5th table reference "pivot" # report id |pivot_record_fk|this_week_use is correct way "relate" 3 entities, if how display in admin showing related entries ? thanks. you should have structured so. class manufacturer(models.model): name = models.charfield() class product(models.model): name = models.charfield() manufacturer = models.foreignkey(manufacturer, related_name="products") class part(models.model): name = models.charfield() manufacturer = models.foreignkey(product, related_name="parts") class report(models.model): manufacturer = models.foreignkey(manufacturer, related_name="reports") this_week_use then in report can filter out based on part's name (if neede

python - How do I upload multiple libraries which my app needs to Google App Engine? -

i wrote script control reddit bot using praw, , decided wanted upload website execute automatically every ten or minutes. for chose google app engine (b/c free , google). unfortunately i'm not sure how upload dependencies. after googling around found out had place praw in src directory of app, did. the app threw error on running, saying not find module named requests- fix threw 6 in src dir, dependency of praw. next time ran, app engine log said script not find module "pkg_resources." to find started python , ran import pkg_resources print(pkg_resources) which linked .pyc placed app's src directory. unfortunately next time script ran failed again, saying not locate module pkg_resources. because of have 2 questions: one, can tell me i'm doing wrong in trying upload praw's dependencies app engine? and... two, while locating files needed, realized trying upload dependencies of package pain. there utuility generate list of folders need place in

git - How to remove committed files no longer in working directory -

i have repo lots of files no longer in working directory- files have been added , removed on months/years of repository. i make file list of these files stored in commit histories no longer required, including locations.. i.e. /web/scripts/index.php /sql/tables.sql ... then command runs through file , removes files referenced in commit history completely, git rm --cached list of files. short answer alias david underhill's script , run ( with caution ): $ git delete `git log --all --pretty=format: --name-only --diff-filter=d` explanation david underhill's command uses filter-branch modify history of repository, removing history of given file path. the script, in entirety ( source ): #!/bin/bash set -o errexit # author: david underhill # script permanently delete files/folders git repository. use # it, cd repository's root , run script list of paths # want delete, e.g., git-delete-history path1 path2 if [ $# -eq 0 ]; exit 0 fi # make

Is it possible to set up time limits for users I've shared files with on Google Drive to not have access during certain times? -

is possible set time limits users i've shared files not have access? want them have access during business hours. well once share them, have access time. google drive doesn't have ability control time of access. however, can control if can invite or share file more ppl or can let them see without ability modify contents.

android - MergeAdapter with Gridview -

libraries: https://github.com/commonsguy/cwac-merge https://github.com/maurycyw/staggeredgridview https://github.com/chrisbanes/android-pulltorefresh i'd add gridview adapter mergeadapter. 1st way, if set adapter: plv = (pulltorefreshlistview) layoutinflater.from(context).inflate( r.layout.layout_listview_in_viewpager, container, false); adapter = new mergeadapter(); sadapter = new staggeredadapter(basesampleactivity.this, r.id.imageview1, urls); adapter.addadapter(sadapter); plv.setadapter(adapter); then works list view. 2nd way, if build view: plv = (pulltorefreshlistview) layoutinflater.from(context).inflate( r.layout.layout_listview_in_viewpager, container, false); adapter = new mergeadapter(); adapter.addview(buildlabel3(context)); plv.setadapter(adapter); public view buildlabel3(context context) { // todo auto-generated method stub relativelayout v = (relativelayout)layoutinflater.from(context).in

How to use nested generics in scala -

edit simplified example. added more detail. what i'd compose class method. class has type parameter of form a[b], , b abstract types (generic parameters), , methods can work objects of types or b, or other types composed or b. example, class might have method takes a[b] type object parameter, , return b type object. this kind of pattern extremely common in say, c++ standard template library. is possible in scala? in example below, within listdoer, abstract type name listt , b abstract typename telement. later, try provide concrete types, listt[telement] = mylist[double] class listdoer[ listt[telement] ] { // processes abstract list type. def doit( list:listt[telement] ) : telement = { list.get(0) } // telement not found // attempt 2: type l=listt[telement] // telement not found def doit2( list:l ) : telement ={ list.get(0) } // telement not found } // more concrete list type class mylist[telement] { var none: telemen

django-autocomplete-light modelform ValidationError -

i have autocomplete fields in 2 diferent forms. one forms.form , works ok. other 1 modelform , doesn't work if try with: class facturaform(modelform): class meta: widgets = autocomplete_light.get_widgets_dict(factura) model = factura throws: validationerror @ /facturas/nuevo/1/ [u'type cannot validate [0]'] .... {{ form.as_table }} .... if try with: class facturaform(modelform): class meta: model = factura widgets = { 'cliente': autocomplete_light.choicewidget('clienteautocomplete'), } throws: validationerror @ /facturas/nuevo/1/ [u'clienteautocomplete cannot validate [0]'] and if try with: class facturaform(modelform): cliente = autocomplete_light.genericmodelchoicefield( widget=autocomplete_light.choicewidget( autocomplete='clienteautocomplete', autocomplete_js_attributes={'minimum_characters': 0,

c - How to improve performance of following loop -

i have simple loop in c convert magnitude , angle real , imaginary parts. have 2 versions of loop as. version 1 simple loop perform conversion using following code for(k = 0; k < n; k++){ xreal[k] = mag[k] * cos(angle[k]); ximag[k] = mag[k] * sin(angle[k]); } an version 2 intrinsics used vectorize loop. __m256d cosvec, sinvec; __m256d resultreal, resultimag; __m256d angvec, voltvec; for(k = 0; k < sysdata->totnumofbus; k+=4){ voltvec = _mm256_loadu_pd(volt + k); angvec = _mm256_loadu_pd(theta + k); sinvec = _mm256_sincos_pd(&cosvec, angvec); resultimag = _mm256_mul_pd(voltvec, sinvec); resultreal = _mm256_mul_pd(voltvec, cosvec); _mm256_store_pd(xreal+k, resultreal); _mm256_store_pd(ximag+k, resultimag); } on core i7 2600k @3.4ghz processor, these loops give following results: version 1: n = 18562320, time: 0.2sec version 2: n = 18562320, time: 0.16sec a simple calculations these values show in version 1 , e

Convert html tags to string php -

i have been trying following long time , haven't been able figure out. i have string in php contains html in follows example: $var = "<div style="display:inline">how</div> <div style="display:none">are</div> <div style="display:inline">you</div> ?"; and store in string $var2, "howyou?"; basically, i'd render html in php in sense. how go doing this? thanks try use ' instead of " inside string that: $var = "<div style='display:inline'>how</div> <div style='display:none'>are</div> <div style='display:inline'>you</div> ?"; it must work now

for loop - Can I send simultaneous (instead of sequential) Arduino outputs? -

i have 8 leds i'm fading in , out arduino. i'm controlling each individually following code. for(int fade1=0;fade1<=255;fade1+=1){ analogwrite(8,fade1); delay(10); } for(int fade1=255;fade1>=0;fade1-=1){ analogwrite(8,fade1); delay(10); } i want able assign separate fade time , delay each of 8 separate pins, 8 lights fading in , out simultaneously, , loop infinitely. however, can them kick off sequentially program. i've been playing different placement of loops, loops within loops, etc., can't seem make want. ideas or examples can refer me? instead of having 16 loops, reduce them two: for(int fade1=0;fade1<=255;fade1+=1){ analogwrite(8,fade1); analogwrite(9,fade1); // etc. delay(10); } for(int fade1=255;fade1>=0;fade1-=1){ analogwrite(8,fade1); analogwrite(9,fade1); // etc. delay(10); } you won't able observe difference in time when port 8 written when port 9 written. co

ios - I want UICollectionView grid that has no space on edge cells, only between cells -

i using uicollectionviewcontroller display grid of photos, , have no spacing on outer boundary of screen; between cells. so "edge" photos (far left, far right) right against respective edge of screen, there space between cells. i'm using standard flow layout this, implementing sizeforitematindexpath , insetforsectionatindex methods. i'm hoping don't have custom layouts.. how do this? in advance help.

ruby - How can I group by the difference of a column between rows in SQL? -

i have table of events created_at timestamp. want divide them groups of events n seconds apart, 130 seconds. each group, need know lowest timestamp , highest timestamp. here's sample data (ignore formatting of timestamp, it's datetime field): ------------------------ | id | created_at | ------------------------ | 1 | 2013-1-20-08:00 | | 2 | 2013-1-20-08:01 | | 3 | 2013-1-20-08:05 | | 4 | 2013-1-20-08:07 | | 5 | 2013-1-20-08:09 | | 6 | 2013-1-20-08:12 | | 7 | 2013-1-20-08:20 | ------------------------ and result is: ------------------------------------- | started_at | ended_at | ------------------------------------- | 2013-1-20-08:00 | 2013-1-20-08:01 | | 2013-1-20-08:05 | 2013-1-20-08:09 | | 2013-1-20-08:12 | 2013-1-20-08:12 | | 2013-1-20-08:20 | 2013-1-20-08:20 | ------------------------------------- i've googled , searched every possible way of phrasing question , experimented time, can't figure out. can in ruby, i'm trying

Class templates and constructors -

templates great add features class, there problem constructors: works when template ctor , class (passed parameter) ctor have default form. ( dpaste tester ) module main; class cinternalmandatoryclass{}; class cimplementsomestuffs(t): t if((is(t==class)/* & (haveadefaultctor!t) */)) { private: cinternalmandatoryclass fobj; public: void something1(){} this(){fobj = new cinternalmandatoryclass;} ~this(){delete fobj;} } class csource1 { int fa; this(){fa = 8;} } class csource2 { int fa; this(){} this(int a){fa = a;} } class csourcewithsomestuffs1: cimplementsomestuffs!csource1 { this() { assert(fobj !is null); // check cimplementsomestuffs ctor assert(fa == 8); // check csource1 ctor } } class csourcewithsomestuffs2: cimplementsomestuffs!csource2 { this(int a) { // need call csource2 ctor assert(fobj !is null); // check cimplementsomestuffs ctor assert(fa == 9); // check

background color - How to use CSS to retrieve a text input by a user -

i have input tags text field, wondering how take input text user entered , displayed in css this may see odd color background option (#ffffff) designer have access input own color , once hit save, added body background style. i managed have css pick uploaded image through liquid, don't know how retentive input text color code. i using .liquid through shopify my css: body { background:{% if settings.use_site_background %}url('site_background.jpg'){% endif %} no-repeat /////this need color code/////// fixed top right; } my settings: <tr> <td><label for="background_color">background color</label></td> <td><strong>#</strong><input name="background_color" value="" id="background_color" type="text" maxlength="6" /></td> </tr> if there easier way this, appreciate , appreciated! you'd value of text field follows:

Haskell random numbers suddenly start to "converge" after months of running -

i have server program randomly selects 10 group of network peers accomplish task. code generates random indices of peers follows: indices = let index = getstdrandom $ randomr (0, number_of_peers - 1) in sequence $ replicate 10 index the program has been running months, generating thousands of `indices' each day, , has been working fine until yesterday, when noticed has gone wrong: random numbers generated seem "converge" few repeating values (the result corresponding network peers heavily loaded). to see change, below server log few days ago: peers selected: [55,47,80,74,183,85,04,33,72,58] and log today's (as can see, peer 53, 37 , 195 repeatedly selected): peers selected: [53,53,37,37,37,37,195,195,195,21] the program running on x86_64 version of ubuntu 10.10. after investigation turns out embarrassing bug of own: root user on server has limit of maximum open files of 1024, unexpectedly low (but heard default on ubuntu). when s

python - appending text to a global variable -

i having problems global variables in python; have defined global variable in method , trying append text method. method1: def method1(): global v v="hi " print v method2: def method2(): print v # prints `hi` v +="go home" print v # doesn't append how call: method1() method2() expected output hi go home , not getting expected output. how can solve ? need append text in method2() , display it. declare v global: >>> def method1(): ... global v ... v="hi " ... >>> def method2(): ... global v ... v +="go home" ... >>> method1() >>> method2() >>> v 'hi go home'

ubuntu - Shell script, directory is writable strange behavior -

here -w option description test 's man page : -w file file exists , write permission granted and example better thousand words : $ ls -ld /home/maxime/.gvfs dr-x------ 2 maxime maxime 0 aug 5 22:53 /home/maxime/.gvfs $ [ -w /home/maxime/.gvfs ] && echo "is writable" writable $ touch /home/maxime/.gvfs/file touch: cannot touch `/home/maxime/.gvfs/file': no such file or directory as can see, directory shouldn't writable : r , x flags set. but, test says can write in it... first strange thing. other 1 happens when try create file in : no such file or directory . by way, i'm running above commands user "maxime", , i'm using dash ubuntu 12.04. well, i'm bit lost here, got explanation ? .gvfs special file, in fact virtual file system created gvfs-fuse-daemon . should not use directly.

php - How to get only the first instance of an array that is true of a condition -

i'm new php , i'm trying modify wordpress-based learning management theme (called academy on themeforest) able work out lesson in current course user to. in other words, want run check see lessons user has completed, getting id of first lesson in course hierarchy has not been completed. here's know: within loop of single post (in case "course"), how array of current course's lessons: <?php $lessons_array = themexcourse::sortlessons(themexcourse::$data['course']['lessons']); ?> this produces nested array: array ( [0] => wp_post object ([id] => 117 [menu_order]=>1) [1] => wp_post object ([id] => 124 [menu_order]=>2) [2] => wp_post object ([id] => 156 [menu_order]=>3)) i've truncated bit since 2 values, [id] , [menu_order], important: tell id of each lesson , hierarchy in course. but stuck: don't want of lesson ids, 1 user has yet complete. in order check if user has completed lesson o

html - linear-gradient (arrow/triangle) works only in google chrome -

Image
this have tried: http://codepen.io/helloworld/pen/dkgbf please use google chrome watch pen because in chrome v28 linear-gradient (white triangle/arrow) works works not in ie10 or ff22 or safari 5.1.7 on windows. this way looks in google chrome: why work in google chrome? <ul class="_7/5z" style="display: table; height: 100%; float: left; font-size: 7px;background:green;"> <li style="list-style: none;background:blue; display: table-row;"> <div style="height: 99%;padding-left:1%;padding-top:1%;"> <div style="background: red; width: 50%; height: 100%; float: left;"> <div style="height: 100%;" class="segmenttriangle"></div> </div> <div class="fontsize vertical-center" style="font-size:20px;height: 100%; ba

android - Create projects with Phonegap 3.0 -

i try create 3 project new new phonegap cordova 3.0 winrt / android / ios. didn't understand documentation , can't find tutorial. i installed nodejs , phonegap without error. then, try create android app first these lines: $ phonegap create my-app $ cd my-app $ phonegap run android i guess "run android" generate apk , it's not necessary have android eclipse project. command line stop @ "detecting android sdk environment" tried command: $ phonegap -v run android and detecting android sdk environment pass, block @ running "android list target". so tried create winrt app apparently have create our own winrt project first , "deploy" phonegap it. how code can synchronised android , ios project? if have complete tutorial phonegap 3.0 appreciate. have tried netbeans ? new beta version has support phonegap applications. here can start.

python - Pythonic way to store/record agent-specific values in agent-based models? -

i want keep track of agent-specific variables , i'm not sure pythonic way it. for example, have 400 households receive , spend money on time. each household unique id, household-specific variables (income, consumption) should callable , mutable. have keep track of specific variables because actual agent decisions depends on decisions in past (spending in time-step before example). so 1 variable create 400 lists (by typing them? no way), or create numpy array 400 columns (rows = values in time-step t) , column index corresponds household id, or could... , of course agent-specific variables should accesable math operations, sum or mean. any better suggestions?

android - Google map API and MD5? -

i'm trying use google map in android application. how can api key after having md5 code? necessary, or can take simple api developer site? use https://code.google.com/apis/console/ register , select google map android , turn on. then register sha1 finger print.as mentioned md5 finger print.you should not use md5. use sha1 finger print along package name , key.

how do "really" clear a global PHP array -

note : seems wrong happening, , there no issue using $a = array(); . since assignments arrays copy. (i had thought there accesses reference causing problems - typo. i've added details answer below. i've got php looks this: $myarray = array(); function usearray() { global $myarray; // ... myarray ... } function cleararray() { global $myarray; // ... somehow clear global array ... } i know sucks design viewpoint, it's required work around third-party code can't change... my question can put in cleararray function make work? the usual advice of using $myarray=array(); or unset($myarray); don't work since change local version, not global version. guess loop on keys in array , unset each in turn - this: function cleararray() { global $myarray; foreach($key in array_keys($myarray) ) { unset( $myarray[$key] ); } } but seems hacky , unclear. there better solution? the usual advice of using $myarray=array(); or unset($myarr

php - preg_match get div content with class -

i have code that <div class="x-ic test"><div class="abc">test</div><table>.......</table><p>....</p><div style="margin:5px;"></div></div> i tried few pattern didnt result want. and need result below <div class="abc">test</div><table>.......</table><p>....</p><div style="margin:5px;"></div> use domdocument - i've written code functions in case want perform similar operations again: function dominnerhtml(domnode $element) { $innerhtml = ""; $children = $element->childnodes; foreach ($children $child) { $innerhtml .= $element->ownerdocument->savehtml($child); } return $innerhtml; } function getelcontentsbytagclass($html,$tag,$class) { $doc = new domdocument(); $doc->loadhtml($html);//turn $html string dom document $els = $doc->getelements

class - Python print length OR getting the size of several variables at once -

in python, if print different data types separated commas, act according __str__ (or possibly __repr__ ) methods, , print out nice pretty string me. i have bunch of variables data1, data2... below, , love total approximate size. know that: not of variables have useful sys.getsizeof (i want know size stored, not size of container.) -thanks martijn pieters the length of each of printed variables enough size estimate purposes i'd avoid dealing different data types individually. there way leverage function print total length of data? find quite unlikely not built python. >>> obj.data1 = [1, 2, 3, 4, 5] >>> obj.data2 = {'a': 1, 'b':2, 'c':3} >>> obj.data3 = u'have seen crossbow?' >>> obj.data4 = 'trapped on surface of sphere' >>> obj.data5 = 42 >>> obj.data6 = <fake a.b instance @ 0x88888> >>> print obj.data1, obj.data2, obj.data3, obj.data4, obj.data5, obj.da

gwt - Build Path in eclipse -

after importing existing gwt project eclipse getting following error. project 'testui' missing required source folder: 'testmgr/nocache/js.gwt.xml'. please help. please post module gwt.xml. should ensure entry point classpath correct <!-- specify app entry point class. --> <entry-point class="com.me.myproject.client.testui" /> and check added appropriate packages module <!-- adding package gwt module --> <source path="client" /> <source path="shared" /> if fine module, more specific error happens ? when launching project ? in eclipse warnings ?

Java email - show multiple email recipients? -

is possible use java send email such can see multiple recipients in to/cc/bcc fields? in other words, this: from: foo@bar.com to: user1@lol.com; user2@lol.com; user3@lol.com; user4@lol.com cc: admin1@lol.com; admin2@lol.com i searched on google found no conclusive results, advice appreciated. yes is. how - depends on library you're using.

ruby - Join type in ActiveRecord has_one Relationship -

just getting started activerecord (in sinatra app). trying port existing queries ar getting little stuck. if have has_one relation users , profiles (using legacy tables unfortunately) class user < activerecord::base self.table_name = "systemusers" self.primary_key = "user_id" has_one :profile, class_name: 'profile', foreign_key: 'profile_user_id' end class profile < activerecord::base self.table_name = "systemuserprofiles" self.primary_key = "profile_id" belongs_to :user, class_name: "user", foreign_key: 'user_id' end if want query users profile using inner join user_age field profiles using 1 query can it? for example (just added .first reduce code looping through users profiles) user = user.all(:joins => :profile).first user.profile.user_age gives me correct data , uses inner join first query issues second query profile data it gives depreciated warni

sql server - Import large table to azure sql database -

i want transfer 1 table sql server instance database newly created database on azure. problem insert script 60 gb large. i know 1 approach create backup file , load storage , run import on azure. problem when try while importing on azure io have error: could not load package. file contains corrupted data. file contains corrupted data. second problem using approach cant copy 1 table, whole database has in backup file. so there other way perform such operation? best solution. , if backup best why error? you can use tools out there make easy (point , click). if it's 1 time thing, can use virtually tool ( red gate , bluesyntax ...). have bcp well. of these approaches allow backup or restore single table. if need more repeatable, should consider using backup api or code using sqlbulkcopy class.

node.js - Convert file from base64 and send to some external service as binary file -

i send file node.js server base64 string, need send external service binary file. possible without saving file file system? i'm trying file on node.js side in way: var filedata = req.body.value, filename = req.body.id, base64data = filedata.replace(/^data:image\/jpeg;base64,/,""); modules.fs.writefile( filename, base64data, 'base64', function(err) { if (err) { console.log(err); } else { //read file file system , send external service } }); write buffer: var buffer = new buffer(base64data, 'base64'); an alternative https://github.com/cjblomqvist/base64stream

jquery - How to validate Hidden field -

i using datatable(bind using json) listing enrolled currencies. here how call class data database: <script type="text/javascript"> function cancelbyredirect() { window.location = "pendingtransaction.aspx"; } function btnselect_click(id) { jquery('#<%= vid.clientid %>').val(id); } jquery(document).ready(function ($) { jquery("#dialog").dialog({ autoopen: false }); jquery("#indicator").hide(); jquery('#tblvirtualaccounts').datatable({ bprocessing: true, bserverside: true, bfilter: false, sajaxsource: '<%= resolveurl("~/merchant/virtualaccount/tablehelpercheque.aspx")%>', olanguage: { "szerorecords": "no records found", "sprocessing": 'fetching records..<img height="32px" width="32px&q

Enable and Disable Airplane Mode successively Android -

i starter in android. have android code has button. on click of button, should invoke airplane mode , again normal mode. here code : public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // load controls tvstatus = (textview)findviewbyid(r.id.tvstatus); togstate = (button)findviewbyid(r.id.togstate); // set click event button togstate.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // check current state first boolean state = isairplanemode(); // toggle state toggleairplanemode(state); state = isairplanemode(); // toggle state toggleairplanemode(state); } }); }

jquery - twitter bootstrap tooltip not working in js template -

i ma using twitter bootstrap tooltip functionality works fine in gsp header texts. want add bootstrap tooltip on id="tooltipcheck". if write title="{{data}}" see tooltip bootstrap tooltip not seem work here. there issue js template or there else? <script id="mytemplate" type="text/x-handlebars-template"> <div class="row"> <div class="span4" id="tooltipcheck" data-placement="bottom" data-toggle="tooltip" data-original-title="{{data}}">{{data}} </div> </div> i calling tooltip this. <script> jquery(function ($) { $("#tooltipcheck").tooltip('show'); }); you can't set id of element in template because id's need unique. try changing tooltipcheck class instead: <div class="span4 tooltipcheck" data-placement="bottom" data-toggle="tooltip" data-original-title=

How do I use AIDL or talk to Android Services from codenameone? -

i building android pos application using codenameone. want use cmsoft bt-printer sdk here http://www.cm-soft.com/androidprintersdk.htm . uses aidl interface. how access codenameone project? 1)create in project regular interface extends nativeinterface communicate printer service. 2) interface printerinterface extends nativeinterface{ public void bindservice(); public void startscan(); public void stopscan(); } 3)right click on interface , select "generate native access" - create implementation files under native directory in project. 4)under native/android dir printerinterfaceimpl class make sure issupported() method returns true , implement android code in class. use androidnativeutil.getactivity() gain access activity. example: androidnativeutil.getactivity().registerreceiver(mreceiver, new intentfilter(receiver)); androidnativeutil.getactivity().unregisterreceiver(mreceiver); 5)in impl class can bind receiver: final class scannerrec

osx - I want to share my python app as dmg or package? -

i have developed first .app mac, written in python , share .app friends. i have converted python scripts via py2app. have 1 .app , compress .dmg file. i share .dmg file guys , one, working fine. (he has python installed) the other people can´t open .app file, error messages. after intensive search got it. have no python installed. now question: how can include "one click python installation" in .dmg file (or package?!) if create .dmg , can setup background image tells users move application /applications folder. if application needs no setup, preferred, or (mac os x created) .zip file it. the package option better if additional setup, or scripts checking python dependencies, required.

php - Get all the exceptions from one try catch block -

i wonder if it's posible exceptions throwed. public function test() { $arrayexceptions = array(); try { throw new exception('division zero.'); throw new exception('this never throwed'); } catch (exception $e) { $arrayexceptions[] = $e; } } i have huge try catch block want know errors, not first throwed. possible maybe more 1 try or or doing wrong? thank you you wrote yourself: "this never throwed" [sic]. because exception never thrown, cannot catch it. there 1 exception because after 1 exception thrown, whole block abandoned , no further code in executed. hence no second exception.

python - Shortcut OR-chain applied on list -

i'd this: x = f(a[0]) or f(a[1]) or f(a[2]) or f(a[3]) or … with given list a , given function f . unlike built-in any function need first value of list considered true; 0 or "foo" or 3.2 need "foo" , not true . of course, write small function like def returnfirst(f, a): in a: v = f(i) if v: return v return false x = returnfirst(f, a) but that's not nicest solution, reasons given in this question . mention other thread, of course use code based on solution given there, e.g. x = next((f(x) x in if f(x)), false) but don't see simple way circumvent doubled calling of f then. is there simple solution missing or don't know? an or((f(x) x in a)) maybe? i tried find other questions concerning this, searching keywords or bit problematic in so, maybe didn't find appropriate. this should work: next((x y in x in (f(y),) if x),false)

Enable android's phone speaker in program -

i wrote app handles incoming calls , answers them automatically. want set voice phone's loud speaker , works fine on android 4 not 4.1 , 4.2. code: audiomanager audiomanager = (audiomanager) context.getsystemservice(context.audio_service); audiomanager.setmode(audiomanager.mode_in_call); audiomanager.setspeakerphoneon(true); i have required permission in manifest: <uses-permission android:name="android.permission.modify_audio_settings" /> i getting silent exception in logcat says have not modify_phone_state permission have defined in manifest: java.lang.securityexception: neither user 10046 nor current process has android.permission.modify_phone_state. @ android.os.parcel.readexception(parcel.java:1425) @ android.os.parcel.readexception(parcel.java:1379) @ com.android.internal.telephony.itelephony$stub$proxy.silenceringer(itelephony.java:577) @ net.farayan.android.driveranswer.autoanswerintentservice.answerphoneaidl(autoanswerintentservice.java:155)

How does JavaScript .prototype work? -

i'm not dynamic programming languages, i've written fair share of javascript code. never got head around prototype-based programming, 1 know how works? var obj = new object(); // not functional object obj.prototype.test = function() { alert('hello?'); }; // wrong! function myobject() {} // first class functional object myobject.prototype.test = function() { alert('ok'); } // ok i remember lot discussion had people while (i'm not sure i'm doing) understand it, there's no concept of class. it's object, , instances of objects clones of original, right? but exact purpose of .prototype property in javascript? how relate instantiating objects? edit these slides helped lot understand topic. every javascript object has internal property called [[prototype]] . if property via obj.propname or obj['propname'] , object not have such property - can checked via obj.hasownproperty('propname') - runtime looks proper