Posts

Showing posts from August, 2011

javascript - How to compare (contents of) color objects retrieved from HTML5 canvas via ctx.getImageData() -

i'd compare (a limited number of) color values retrieved html5 canvas. retrieve , store i'm interested in ctx.getimagedata(x, y, 1, 1).data; i tried use array.prototype.compare from: how compare arrays in javascript? by: // add same compare method uint8clampedarray uint8clampedarray.prototype.compare=array.prototype.compare; that works fine on recent firefox , chrome found not browsers return object of type uint8clampedarray. ie seems use object of canvaspixelarray , safari seems use simple 4-value array do have deal differences myself or there reliable generelized method (plain js or jquery) compare 2 such values retieved ctx.getimagedata() works on browsers? you can (probably?) use array compare method this: var comparisonresult = [].compare.call(yourpixels, colors); that code finds "compare" method array instance , invokes pixel array this value , other array (your colors) first parameter. this same thing: var comparisonresult =

ios - How can I verify that I am running on a given GCD queue without using dispatch_get_current_queue()? -

recently, had need function use guarantee synchronous execution of given block on particular serial dispatch queue. there possibility shared function called running on queue, needed check case in order prevent deadlock synchronous dispatch same queue. i used code following this: void runsynchronouslyonvideoprocessingqueue(void (^block)(void)) { dispatch_queue_t videoprocessingqueue = [gpuimageopenglescontext sharedopenglesqueue]; if (dispatch_get_current_queue() == videoprocessingqueue) { block(); } else { dispatch_sync(videoprocessingqueue, block); } } this function relies on use of dispatch_get_current_queue() determine identity of queue function running on , compares against target queue. if there's match, knows run block inline without dispatch queue, because function running on it. i've heard conflicting things whether or not proper use dispatch_get_current_queue() comparisons this, , see wording in headers: r

Snap binary files upload -

i need understand file uploading process snap. given form: <form id="form" action="/files/upload" method="post" enctype="multipart/form-data"> <input type="file" id="files" name="files[]" multiple /> <button type="submit" onclick="handlefiles(e)">upload</button> </form> do use same functions getpostparams process binary files or use functions snap.util.fileuploads? i need upload , save binary files pdf in database. database driver accept bytestring store binary file. i went through snap.util.fileuploads not need. not sure how process in handler? thanks. edit with irc managed come below construct. think should close correct?? well, compiles , dumps file mongodb. can read back. although don't quite understand enumerators , iteratee stuff ... handlefiles :: apphandler () handlefiles = [file] <- handlemultipart defaultuploadpolicy $ \p

gps - Why do I have to use cartesian coordinates in a perspective projection? -

in tutorial written, cartesian coordinates necessary perspective projection. let's have position of camera , object in spherical coordinates (longitude, latitude, altitude). why have transform them cartesian coordinates? possible calculate projection spherical coordinates? thanks

php - MySQL Query adding another condition -

Image
here query: select photos.* photos inner join follows on photos.userid=follows.followingid follows.followerid = $myid order photos.id desc limit 10 how add condition correctly can check photos user's id (using $myid variable)? update: added conditional in syntax provided in answer, shows images users you're following not own photos though. update 2: table structures: from question difficult gather how tables set up, may you're looking for: select photos.* photos left outer join follows on photos.userid=follows.followingid follows.followerid = $myid or photos.userid = $myid order photos.id desc limit 10 edit: see you're trying do, need left outer join include every result photos table, should work.

python - Numpy: Is it possible to display numbers in comma-separated form, like 1,000,000? -

this question has answer here: how print number commas thousands separators? 23 answers i have numpy array this: [ 1024 303 392 4847 7628 6303 8898 10546 11290 12489 19262 18710 20735 24553 24577 28010 31608 32196 32500 32809 37077 37647 44153 46045 47562 48642 50134 50030 52700 52628 51720 53844 56640 56856 57945 58639 57997 63326 64145 65734 67148 68086 68779 68697 70132 71014 72830 77288 77502 77537 78042 79623 81151 81584 81426 84030 86879 86171 89771 88367 90440 92640 93369 93818 97085 98787 98867 100471 101473 101788 102828 104558 105144 107242 107970 109785 111856 111643 113011 113454 116367 117602 117507 120910 121167 122150 123385 123079 125537 124702 130226 130943 133885 134308

upload - Laravel 4 get image from url -

ok when want upload image. like: $file = input::file('image'); $destinationpath = 'whereever'; $filename = $file->getclientoriginalname(); $uploadsuccess = input::file('image')->move($destinationpath, $filename); if( $uploadsuccess ) { // save url } this works fine when user uploads image. how save image url??? if try like: $url = 'http://www.whereever.com/some/image'; $file = file_get_contents($url); and then: $filename = $file->getclientoriginalname(); $uploadsuccess = input::file('image')->move($destinationpath, $filename); i following error: call member function move() on non-object so, how upload image url laravel 4?? amy appreciated. i don't know if lot might want @ intervention library . it's intended used image manipulation library provides saving image url: $image = image::make('http://someurl.com/image.jpg')->save('/path/saveasimagename.jpg');

formatting - Scala formatter - show named parameter -

i have relatively large scala code base not use named parameters function/class calls. rather going in , manually entering it, tedious process, looking @ formatter job. best found scalariform , i'm not sure whether can write rule complex. i'm curious if has ran similar problem , found powerful formatter. the scala refactoring library might use. need knowledge of scala's abstract syntax tree representation. why want use named parameters throughout code base? intellij's default suggest name boolean arguments (only).

osx - Is there a way to make Android Studio not copy .DS_Store files into APK? -

when build apk, android studio copies these redundant osx file system files ".ds_store". there way filter them apk bundle? i've tried adding !.ds_store compiler/resource patterns fields didn't help. try add .ds_store compiler > excludes rather resource patterns field.

html - Prevent Orphan Lines in ePub export through Pages -

i've been editing book in pages , when export epub document line breaks have inserted document seem ignored. i've resigned messing formatting in pages , have started editing epub sigil. parameters need edit prevent orphan lines or insert page breaks epub document? after researching ibook documentation found inserting css tag: page-break-before:always; specifically, i'm working on cookbook , wanted have each recipe on own page. using iwork not able achieve effect without little tinkering. opened exported epub document calibre (sigil seemed mess books formatting) after first creating header tag first recipe , separate header tag other recipes in chapter. located tag generated iwork , added h1.s4 { page-break-before:always; } css file. do mean "line breaks", not "page breaks"? the reliable way enforce page breaks prepare separate xhtml files. beyond that, you're on own. you've entered "ios new ie6" hell. you'll

javascript - Why can't my CasperJS script login to Quora? -

Image
this code: var casper = require('casper').create({ verbose: true, loglevel: 'debug' }); casper.start('http://www.quora.com', function() { this.click('input.submit_button'); this.echo("page loaded"); this.test.assertexists('form.inline_login_form', 'form found'); this.fill('form.inline_login_form',{email:'xxxxxx@gmail.com',password:'xxxx'},false); } ); casper.then(function(){ this.click('input.submit_button'); }); casper.then(function(){ this.capture('google.png', { top: 0, left: 0, width:0, height:0 }); this.echo("page title " + this.gettitle()); }); casper.run(); this image capture method produces: why doesn't login? id , password correct. try this, must work : var casper = require('casper').create({

php - How can I let this div expand and overflow it's container in IE8? -

i found nice css3 dropdown script, can't abandon ie8 users because last read still 10% of visits. so, tried this: <div id="containerdiv" style="height: 35px; overflow: visible;" > <a href="#"><img src="images/1.jpg"></a> <a href="#"><img src="images/2.jpg" onmouseenter="document.getelementbyid('navdd1').style.display = ''"></a> <div id="navdd1" style=" display: none; margin-left: 100px; background-image:url('images/blank_dropdown.jpg'); line-height: 35px; width: 100px;" onmouseleave="document.getelementbyid('navdd1').style.display = 'none'"> <a href="#">link 1</a><br> <a href="#">link 2</a><br> </div> </div> the mouseenter , mouseleave seem want, un-hidden di

php - grouping array data using a field value -

i have array newsfeed containing last followers of current user, follows: $newsfeed=array( 1 => array( 'follower'=>'1', 'following'=>'5', 'datecreation'=>'2013-07-12 15:10:34' ), 2=>array( 'follower'=>'6', 'following'=>'5', 'datecreation'=>'2013-07-12 12:30:56' ), 3=>array( 'follower'=>'7', 'following'=>'5', 'datecreation'=>'2013-05-12 19:08:00' ) ); what want do, shorten news feed, puting items of same day in 1 array , item 1 , 2 in previous table. follows: $newsfeed=array( 1 => array( 'follower'=>array('1','6'), 'following'=>'5', 'datecreation'=>'2013-07-12' ), 3=>array( 'follower'=>'7', 'following'=>'5', 'datecreation'=>'2013-05-12 19:08:

java - Web app with JPA doesn't work on extenal Tomcat server -

i've problems publishing dynamic web application in tomcat, on vps server. i developed application contains servlet( creating entity manager , doing operations on database), , jar files - entity components packed in jar file. application uses eclipselink , postgresql. on tomcat 7 server installed witch eclipse, works fine, when try deploy tomcat 7 server on vps i'm getting exception: javax.servlet.servletexception: error instantiating servlet class pl.marekbury.controller.storeserver and root cause javax.naming.namenotfoundexception: name [pl.marekbury.controller.storeserver/persistence_unit_name] not bound in context. unable find [pl.marekbury.controller.storeserver]. i had same error on localhost eclipse-integrated server, found solution (somwere here, on stack) chcange eclipselink version, after did id, error's gone. i'm deploying app in these way: - export war eclispe - deploy trough tomcat web manager i tried: - change server tomee - place jar

Python 3 Syntax Error -

method = input("is raining? ") if method=="yes" : print("you should take bus.") else: distance = input("how far in km want travel? ") if distance == > 2: print("you should walk.") elif distance == < 10 : print("you should take bus.") else: print("you should ride bike.") nvm, fixed it..for have same problem , on grok learning indention issue , forgot write int... so since added second question, i'll add second answer :) in python 3, input() function returns string, , cannot compare strings , integers without converting things first (python 2 had different semantics here). >>> distance = input() 10 >>> distance '10' <- note quotes here >>> distance < 10 traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: unorderable types: str() < int() to convert string integer value, use int(

php - How can I display form validation messages on the same page as the form itself? -

i have simple html form single field submits download.php validates form , sends me email user input. far, works great - error messages , thank message display inside original html form, not on new page (as happening now). can tell me how keep myform.html visible after submit button clicked, , load error , thank messages inside "notification" div? btw, in case it's relevant, myform.html dynamically displayed inside on index.html using jquery .load(). thanks help! myform.html <html> <head>...</head> <body> <div id="notification"></div> <!-- want load errors , thank you, here --> <form id="downloadform" method="post" action="_php/download.php"> <label for="biz_email">business email:</label><input type="text" name="biz_email"> <div id="submit" class="submit_button"></di

Lua / Corona - How do I pass a function as a parameter and then call that function -

i trying pass function parameter in function. high level have code creates popup window. when update popup window new text, want update action happens when user clicks on popup window. example first time update popup window, might change action to show popup window again new text. when user clicks on second here sample code illustrate concept function dosomething() print("this sample function") end function createpopup() local popup = display.newrect ... create display object function popup:close() popup.isvisible = false end function popup:update(options) if options.action function dg:touch(e) -- action passed options.action end end end popup:addeventlistener("touch",popup) return popup end local mypopup = createpopup() mypopup:update({action = dosomething()}) you can call this function dosomething() print("this sample function&quo

c# - Accessing Gridview Template field from Panel -

im having problem days. here situation: i have gridview template field imagebutton . when imagebutton clicked, modal pop panel opens. inside panel button cancel. what want when user clicks cancel button. set imagebutton.visible = true; but can't seem because of error unable cast object of type webcontrols.contentplaceholder type webcontrols.gridviewrow protected void button1_click1(object sender, eventargs e) { button button = sender button; gridviewrow gridviewrow = (gridviewrow)button.namingcontainer; gridviewrow.findcontrol("stopimagebutton").visible = true; this.stoptimenotespanel_modalpopupextender.hide(); } please help i guess method define itemtemplate may not technically correct.please follow simple structure defined msdn solve problem. http://msdn.microsoft.com/en-us/library/bb907626(v=vs.100).aspx

ruby on rails - Database not getting set up with :js => true -

with code below browser fires test. can see rendered page. items missing on page supposed in database. why isn't database getting populated? when rid of ":js =>true" database set up.. test fails because need javascript click on table row. require 'spec_helper' feature "[user can add analysis line]", :js => true context "[user signed in]" scenario "[user can visit home page click on line , add analysis]" puts "** add analysis feature spec not working **" jim = fabricate(:user) sign_in(jim) nfl = fabricate(:league, name: "nflxx") nba = fabricate(:league, name: "nba") nhl = fabricate(:league, name: "nhl") mlb = fabricate(:league, name: "mlb") nfl_event1 = fabricate(:event, league: nfl, home_team: "eagles") nfl_event2 = fabricate(:event, league: nfl, home_team: "jets") nba_event = fabr

php - displaying the most popular pages on my site -

on homepage want display 30 popular pages on site. thought best way have hit counter each individual page, column in table called hit_counter. whenever page viewed hit_counter incremented 1. however site has many different tables, e.g. hotels, restaurants, entertainment. want them mixed in results, not sure query pull these database. i imagine sort of join. want take name, description , url of each row, have named columns in generic manor, e.g. hotel_name, hotel_description, hotel_url, restaurant_name, restaurant_description, etc. then query order hit_counter desc. so query such join, tables called restaurants, hotels , entertainment. if i'm not mistaken, creating new table each category page. in opinion best approach if created 1 table pages, 1 categories , 1 hits. can have hotels table, restaurant table, etc., there's difference between hotels table , pages table.....hotels should store info each hotel , pages should store info each page. anyways, categ

What framework to use for touch input tracking for Windows Store app using C#, XAML -

i using c# xaml in visual studio 2012, , programming "windows store" app. looking right framework capture , track touch inputs. in particular, when user draws lines on screen, looking track trajectories, capturing position of user's finger on time. example, find (x,y) location every half second or so. need find out when user "touch down" event , when user "touch up" event. i don't need multi-touch in case. which framework should using achieve these requirements? thanks. you can use pointer events, support both mouse , touch pointerpressed , pointerreleased events you can check more here : quick start: touch inputs

ios - Pulling the raw html string from an htm file stored locally in Xcode -

i have locally stored .htm file , want pull raw html string , display textview. know how display strings in textviews , else, need know how inner strong locally stored .htm file. right can pull path. first, you'll have add file project , include in application bundle: add file project select target go build phases tab expand copy bundle resources section add file list this makes sure file available when application runs on device. to read content of file when application runs, file path: nsstring *path = [[nsbundle mainbundle] pathforresource:@"your_file" oftype:@"htm"]; and load file nserror *error; nsstring *content = [nsstring stringwithcontentsoffile:path encoding:nsutf8stringencoding error:&error]; things watch out for: check error value after reading if file large, might want read asynchronously

tinymce - resize/scale handelers are not in the same place as resize object -

Image
tinymce re-size/scale handlers not appearing in same place re-sizable/scalable object are, far below object. i using inline feature, issue happening re-sizable, table, image etc. here screenshot of issue: i got solution, position of parent of re-sizable object need relative

Javascript Object Event Handler Scope, best practice(s)? -

i'm writing javascript module provides form submit. while writing it, ran seems classic scope problem. i want submit() method make ajax call , use object method handle success , fail of call. since submit() event handler, this no longer set flagbox object. thus, no longer have access flagbox.showsuccess() or flagbox.showfail() . at first, looking way set object-wide self reference, call self.showsuccess() . for now, i'm using jquery.proxy() set context of handler. i thought implementing pub/sub pattern or attaching method event.data . i'm curious other solutions out there, , if there 'best practices' haven't found. (function( $ ) { var flagbox = function() {}; flagbox.prototype = { constructor: flagbox, init: function() { $('.flag-content-box') .on('submit', $.proxy(this.submit, this)); }, ... showsuccess: function() { console.log(

javascript - IPN(notify url) page is not being called -

i working on paypal sandbox. transaction working , return url being called , but ipn(notify url) page not being called . i have enabled notify url account also. both caller , listener pages uploaded on server. uploaded listener page's url set in code following. notify url not being called.plz 1 can me. <script data-env="sandbox" data-callback="http://mysite.com/ipnpage.aspx" data-tax="2" data-shipping="5" data-currency="usd" data-amount="<%= session["final_total"]%>" data-quantity="1" data-name="fees" data-number="123" data-custom="<%= session["sb"]%>" data-return="http://mysite.com/ipnpage.aspx" ....></script> i wandering since last 3 days, not solution. plz idea. check ipn history of account should sending ipn's. here can confirm or deny paypal indeed sending ipn's. can see result see whet

How can I use EditText Number Format in Math (Android)? -

edittext "number decimal." thought integer use numa square shows me error "change type of "numa" 'double'. any great appreciated. edittext numa, numb, numc; numa = (edittext) findviewbyid(r.id.numa); numb = (edittext) findviewbyid(r.id.numb); numc = (edittext) findviewbyid(r.id.numc); double sqrt = (double) (math.pow(numa, 2)); hi please try that- package com.example.hello; import android.app.activity; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; public class mainactivity extends activity { edittext editpsw; button btncheckbox; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); editpsw=(edittext)findviewbyid(r.id.edittext1); btncheckbox=(button)findviewbyid(r.id.button1); btnchec

PayPal how to set credentials programmatically in java sdk (express checkout) -

i'm using paypal express checkout make reference payments. right now, sdk loads paypal credentials (user id, password, signature) resource file (sdk_config.properties) - there way set credentials (user id, password, signature) code? i'm not familiar sdk should able update values of constants or whatever types of variables they're using own dynamic values. alternatively, might want permissions api sounds you're attempting make calls on behalf of 3rd party users..??

Getting response by invoking a Servlet from a linux shell script -

there requirement invoking servlet shell script using wget command. servlet performs job of generating report , sends email list of users. as planning schedule job, find out if servlet completed or not. if there exceptions thrown servlet, find out shell script , thereby mark job success or failure. can provide solution this...? the servlet should reply 500 internal server error status code if there unhandled exception. check if wget permits identifying http response status code in way.

android - Sherlock actionbar tab not shown when increase the actionbar size -

Image
i want customize sherlock actionbar , tab. as have show app icon image in approximate 100-150dp size , bottom app icon have display tab. just way so tried code in styles <style name="theme.style.login" parent="@style/theme.sherlock.light"> <!-- api level <11---> <item name="actionbarstyle">@style/theme.white_style</item> <item name="actionbartabstyle">@style/customloginactionbartabstyle</item> <item name="actionbartabbarstyle">@style/customloginactionbartabdividerstyle</item> <!-- api level <11---> <!-- api level >=11---> <item name="android:actionbartabbarstyle">@style/customloginactionbartabstyle</item> <item name="android:actionbarstyle">@style/theme.white_style</item> <item name="android:actionbartabbarstyle">@style/customloginactionbartabdividerstyle</item>

Value of i for (i == -i && i != 0) to return true in Java -

i have following if condition. if (i == -i && != 0) what value of i return true condition in java? i unable think of such value of i considering two's complement notation in java. i love have algebraic proof of whatever answer condition has (in context java)? the int value works integer.min_value . it's because integers negated using two's complement way . using system.out.println(integer.tobinarystring(integer.min_value)); you see integer.min_value is 10000000000000000000000000000000 taking negative value done first swapping 0 , 1 , gives 01111111111111111111111111111111 and adding 1 , gives 10000000000000000000000000000000 as can see in link gave, wikipedia mentions problem negative numbers , specifies it's sole exception : the negative number in two's complement called "the weird number," because exception. of course have same phenomenon long.min_value if store in long variable. not

Android Google Map routing -

hi first time using map in android after changing in google map api . now wants draw route on map between 2 addresses endered me api v2 . don't know how this. tried lot this. please me. thanks. my code is: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.start_trip_view); try { arraylist<string> location = new arraylist<string>(); intent ii = getintent(); location2 = (ii.getstringextra("place")); string location3 = (ii.getstringextra("start")); gps = new gpstracker(getapplicationcontext()); latitude = gps.getlatitude(); longitude = gps.getlongitude(); balvinder = new latlng(latitude, longitude); markerpoints = new arraylist<latlng>(); map = ((mapfragment) getfragmentmanager() .findfragmentbyid(r.id.map)).getm

java - How to set Min text(Mandatory) and Max text in edittext -

in edit text box,i want give min text mandatory , max text having limitation want give in edittext box,is way there give in edittext value. if type text count of numeric has decrease that.how one. <edittext android:id="@+id/edittext1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_below="@+id/textview1" android:layout_margintop="24dp" android:maxlength="175" android:ems="10" /> this adding activity.java @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.home_layout); system.out.println(prayer_category.length); tvprayer = (textview) findviewbyid(r.id.mystate); spinnerprayers = (spinner) findviewbyid(r.id.spinnerstate); arrayadapter<string> adapter_state = new arrayadapter<string>(t

web services - java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader -

i getting following error , while running following code: java.lang.classnotfoundexception: org.apache.commons.lang.stringutils baseclassloader @ org.jboss.classloader.spi.base.baseclassloader.loadclass(baseclassloader.java:448) @ java.lang.classloader.loadclass(classloader.java:247) @ org.dozer.util.resourceloader.getresource(resourceloader.java:53) @ org.dozer.util.defaultclassloader.loadresource(defaultclassloader.java:44) @ org.dozer.config.globalsettings.loadglobalsettings(globalsettings.java:116) @ org.dozer.config.globalsettings.<init>(globalsettings.java:67) @ org.dozer.config.globalsettings.<clinit>(globalsettings.java:46) @ org.dozer.stats.statisticsmanagerimpl.<init>(statisticsmanagerimpl.java:39) @ org.dozer.stats.globalstatistics.<init>(globalstatistics.java:29) @ org.dozer.stats.globalstatistics.<clinit>(globalstatistics.java:24) @ org.dozer.dozerbeanmapper.<clinit>(dozerbeanmapper.java:59) kindly, guide me fix problems. rega

java - Android - MediaPlayer's on Prepare Called even before the stream is prepared on Android 4.0+ -

i facing issue whenever stream played app on android 4.0+ onprepare method mediaplayer.onpreparedlistener called before stream loaded , unable indicated user stream downloading/buffering in process. i have found question of same kind not answered here doing. @override public void oncreate(final bundle savedinstancestate) { super.oncreate(savedinstancestate); playvideo(somertspurl); } private void playvideo(string url) { // if app running on google tv change rtsp link hls if (url.contains("rtsp")) { // split rtsp url , make hls string videourlparts[] = url.split("\\?"); url = videourlparts[0].replace("rtsp", "http") + "/playlist.m3u8"; if (videourlparts.length > 1) url += "?" + videourlparts[1]; } mvideoview.setvideouri(uri.parse(url)); mvideoview.requestfocus(); mvideoview.se

python - 128 bit Integer hash function -

looking string integer hash function values in range of mysql bigint unsigned datatype ( 0 <= n <= 18446744073709551615 ). converting md5/sha1 integer base of 16 not fit requirement. java uses rolling hash should work you from java.lang.string : public int hashcode() { int h = hash; if (h == 0 && count > 0) { int off = offset; char val[] = value; int len = count; (int = 0; < len; i++) { h = 31*h + val[off++]; } hash = h; } return h; } the idea calculate hash : s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] to deal overflow, can add step hash checked against 18446744073709551615 , if larger take mod of hash , 18446744073709551615 .

R looping with bp function -

i have 1 dataset containing 3 columns: country, year , tdvalue. make loop country create dummy variable ( sd ) having 1 or 0 if year breakpoint using r breakpoint function. when make code work sd variable equal 0, while know case years? thanks lot help! library(zoo) library(sandwich) library(strucchange) library(segmented) library(tree) tabo<-read.table("boucle.txt", header=t, sep="\t") fonction.bp<-function(b) bp.inf <- breakpoints(tabo$year ~ tabo$tradevaluein1000usd , tabo = tabo[b,], h = 8) t<-breakdates(confint(bp.inf)) (i in 1:nrow(t)) { res <- ifelse(tabo$year[b] == t[i,1] , 1, 0) return(res) } } numero<-1:nrow(tabo) tabo$sd<-lapply(tabo$code_o,fonction.bp) data sample: code_o -origin -year -tradevaluein1000usd abw aruba 1988 375.059 abw aruba 1989 3458.656 abw aruba 1990 2924.484 abw aruba 1991 140509.4 etc several countries dput(tabo): structure(list(code_o = structure(c

c# - MVC controller, take parameters in as class -

i using jquery post data via ajax, , in chrome tools showing data being sent this: permssionarray[0][permitted]:false permssionarray[0][id]:2 permssionarray[1][permitted]:true permssionarray[1][id]:3 permssionarray[2][permitted]:true permssionarray[2][id]:4 my controller this: public actionresult updatepermissions(permset[] permssionarray) and permset class this: public class permset { public int id { get; set; } public bool permitted { get; set; } } if breakpoint in controller, has 3 items in permssionarray array, values id = 0, permitted = false. what need change fix this? lists odd in asp.net mvc, , have options data server. use default model binding in asp.net mvc. requires change model post format. check out phil haack's post on this. works can hairy if have lot of lists. http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx second option use jquery circumvent post , serialize form json d

http - Merging django url patterns with numeric id or name -

i'm implementing web service (no html, no templates, json) django , i'd able merge url patterns code doesn't repeat itself. this urls need supported: host/players/12/ returns player's 12 info host/players/me/ returns logged player info the 2 return same if logged player has id 12. need support more urls like: host/players/12/other-stuff/ host/players/me/other-stuff/ how avoid having 2 different view methods /other-stuff/? this have far: instance_url_patterns = patterns('', url(r'^$', instance_with_id), url(r'^other_stuff$', other_stuff_with_id), # more suff goes in here ) current_instance_url_patterns = patterns('', url(r'^$', instance_without_id), url(r'^other_stuff$', other_stuff_without_id), # more suff goes in here ) players_url_patterns = patterns('', url(r'^$', show_list), url(r'^(?p<pk>\d+)', include

Correct way to implement session in G-WAN's Ruby -

what correct way implement session on g-wan's ruby, idea: send random cookie if not exists, or guid cookie fine? how read , write cookie on g-wan's ruby? documentation shows examples on c create file if not exists on /tmp/rubysessid-#{cookie_guid} php did read content on every request, , rewrite when changed but problem be: 2 requests same source on same time rewrite cookie file content @ same time making possible data corruption or inconsistency is there better way implement session on g-wan's ruby? web frameworks use databases or key-value stores (sometimes called dictionaries) keep track of sessions. i not ruby developer guess such features available. and g-wan lets access http request headers ruby (like other of 15 programming languages), there's no problem access http cookies. the "documentation shows examples in c" because g-wan written in c c scripts. there, made sense fill gap g-wan api made c/c++, etc. that gap not e

scipy - Constraints on fitting parameters with Python and ODRPACK -

i'm using odrpack library in python fit 1d data. works quite well, have 1 question: there possibility make constraints on fitting parameters? example if have model y = * x + b , physical reasons parameter can in range (-1, 1). i've found such constraints can done in original fortran implementation of odrpack95 library, can't find how in python. of course, can implement functions such return big values, if fitting parameters out of bounds , chi squared big too, wonder if there right way that. i'm afraid older fortran-77 version of odrpack wrapped scipy.odr not incorporate constraints. odrpack95 later extension of original odrpack library predates scipy.odr wrappers, , unclear legally include in scipy. there no explicit licensing information odrpack95, general acm toms non-commercial license.

html5 - Progressive swipe on jQuery Mobile panel -

i'm developing application phonegap & jquery mobile, , should have menu panel can opened swipe gesture. implemented code open on swipe, progressive, such on native apps (facebook, g+ , others...). does know how ? thanks :) you can try plugin : https://github.com/jakiestfu/snap.js used plugin on 1 of our projects, works on ios phonegap app, on android there lags.

r - Solution. How to install_github when there is a proxy -

when try install package of r github's repository install_github('rwbclimate', 'ropensci') if have following error: installing github repo(s) rwbclimate/master ropensci downloading rwbclimate.zip https://github.com/ropensci/rwbclimate/archive/master.zip error in function (type, msg, aserror = true) : not resolve host: github.com; host not found, try again this error displayed because r trying access on intenet through proxy. solution step 1. install devtools packages if (!require("devtools")) install.packages("devtools") library(devtools) step 2. set configuration our proxy (please update information proxy) library(httr) set_config( use_proxy(url="18.91.12.23", port=8080, username="user",password="password") ) install_github('rwbclimate', 'ropensci')

html - href="javascript:func()" vs href="#" onclick="javascript:func()" -

<a href="javascript:expand()"> , <a href="#" onclick="javascript:expand()"> what's difference? i know href="#" more standard way nowadays it. problem have standard dropdown menu expands/collapses when user clicks on toggle. if href="#" code below, whenever clicks on expand page scroll right top isn't acceptable user friendly point. if use href="javascript:expand()" when user clicks expand, page doesn't move , ok. so there problems if use href="javascript:expand()" instead? or how fix href="#" page doesn't scroll top whenever user clicks expand. thanks. edit: know question may have been asked before, i'm looking @ point of view. im asking suggestion rather explanation. if javascript onclick event handler returns false , scrolling won't occur. can this: <a href="#" onclick="expand(); return false;"> if oncl

asp.net - Using MultiView and View in .net giving following error -

i testing multiview , view in application , getting error: compiler error message: cs1061: 'asp.default_aspx' not contain definition 'nextview' , no extension method 'nextview' accepting first argument of type 'asp.default_aspx' found (are missing using directive or assembly reference?) source error: line 24: view 1 . have ! cool because of c#.<br /> line 25: <br /> line 26: <asp:button id="button1" runat="server" text="next" onclick="nextview" /> line 27: <br /> line 28: <br /> source file: c:\users\xxxxx\documents\visual studio 2012\projects\windowsazure2\testcrole\default.aspx line: 26 show detailed compiler output: c:\program files\iis express> "c:\windows\microsoft.net\framework64\v4.0.30319\csc.exe" /t:library /utf8output /r:"c:\windows\microsoft.net\assemb