Posts

Showing posts from April, 2012

javascript - how to make a function that returns sql result set with jQuery? -

i want make function return value of sql result set list (datalite).the problem is, can't read value of variable(datalite) outside db.transaction , return null value . new javascript , jquery hope can find answer here. here's part of function function functiona(){ var datalite=null; db.transaction(function (tx) { tx.executesql('select * tablea', [], function (tx, results) { var len = results.rows.length, i; msg = "<p>found rows: " + len + "</p>"; alert(msg); datalite=results.rows; }, null); }); alert(datalite+'>>>'); return datalite; } you can't return asynchronous code, data not yet available when function returns, come later. such situations (ajax requests, animations, etc.) have patterns. 1 callbacks: function functiona(callback) { db.transaction(function (tx) { tx.executesql('select * tablea', [], function (tx, res

javascript - Submit form while key press in Angular JS -

i have login form follows. login controller called when login button clicked , working fine. need same function called on "enter" key press after entering username , password. <form class="form-horizontal"> <fieldset> <div class="form-group"> <input type="text" class="form-control input-lg input-round text-center" placeholder="username" ng-model="uservals"> </div> <div class="form-group"> <input type="password" class="form-control input-lg input-round text-center" placeholder="password" ng-model="passvals"> </div> <div class="form-group"> <a href="#/" class="btn btn-primary btn-lg btn-round btn-block text-center" ng-click="log_me()">log in</a> </div> </fieldset>

regex - How to substitue a pattern with a whole array using sed? -

i have array, looks this: snakes=(python boa cornsnake milksnake) i wondering if it's possible substitute pattern whole array using sed. thinking this: sed -i "s/snakes like/& $(echo ${snakes[@]})/g" snakes.txt and have output here separated , : snakes python, boa, cornsnake, milksnake any ideas or suggestions appreciated. you expanding array correctly. suppose want edit file called languages (snakes gross): $ cat languages languages like. and array this: $ langs=(python perl ruby lua) you have to set ifs=, (internal field separator) convert elements of array single string ${langs[*]} prepend space before each 1 of them replacing beginning of each string ( # in bash, ^ in regex) space the final command one: $ ifs=, ; sed -i "s|languages like|&${langs[*]/#/ }|" languages (i used | in sed command clarity, / fine too, since shell converting ${langs[*]/#/ } final string before passing sed) the languages

google chrome app - How to use cca with standard webview? -

currently cca build android produce 2 apk's x86 , arm (reflecting 2 versions of crosswalk). i create third uses default webview, i.e., target api 19+ has chromium. how go this? should start? my first brutish instinct clone whole project , package cordova. voice in head wrong. to opt out of crosswalk webview simple, add "webview": "system" manifest.mobile.json . you can read more details in our using crosswalk in chrome apps mobile document. you want set "minsdkversion" cordova config.xml preference build, system webview not used pre-kitkat. actually, may want use crosswalk on kitkat, , system webview on android-l (21+), you. the combined flow use is: leave "webview": "system" off, , set "minsdkversion" 14 (ics). run cca build android --release , copy out 2 apks. finally, switch system webview , set min sdk 19/21, , copy out third apk. upload of play store , test! this isn't neede

iphone - How to use Image assets in iOS -

Image
i use launch images xcasset; i've tried ways can't works. i've standard launchimage asset, , image file called default[@2x,...] . using [uiimage imagenamed:@"launchimage"]; return nil. i've tried @"default" , no results. if want use compiled images separately in application: by-default launchimage asset generate following files: launchimage-700-landscape@2x~ipad.png launchimage-700-landscape~ipad.png launchimage-700-portrait@2x~ipad.png launchimage-700-portrait~ipad.png to find them use below: uiimage* image = [uiimage imagenamed:@"launchimage-700-portrait"]; note: 3 steps required setup assets mentioned below. missing ? my images: updating images in launch image source: drag , drop images in launchimage asset:

android - Uncaught Error: Error calling method on NPObject. at -

deviceready not working because of error. e/web console﹕ uncaught error: error calling method on npobject. @ file:///android_asset/www/cordova.js:924 line : var messages = nativeapiprovider.get().exec(service, action, callbackid, argsjson); i think have try change device or reinstall application in device might help.

class - In the following code why does the last line of execution give an error? -

in following code why last line of execution give error ? shouldn't dot operator in x.bf() pass on instance 'x' function bf ( x.af() ) ? class a: = 6 def af (self): return "hello-people" class b: b = 7 def bf (self): return "bye-people" >>> x = a() >>> b = b() >>> x.bf = b.bf >>> x.bf() traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: bf() missing 1 required positional argument: 'self' x.bf = b.bf error, because b class, not instance of object. you can't assign x.bf directly class. need assign x.bf instance 'b.bf' or instantiate class properly ie. either change line to: # instantiated class b , invoke bf via lazy loading (loading @ last possible minute) x.bf = b().bf or # use existing instance of b , call bf x.bf = b.bf more information: a , b classes. don't until instantiate

how to make command substitution in fish shell? -

in bash or zsh can write clang++ main.cpp -g -o bin/main `pkg-config --cflags --libs opencv` how can translate fish shell? fish uses parenthesis command substitutions. clang++ main.cpp -g -o bin/main (pkg-config --cflags --libs opencv) note parenthesis nest nicely, unlike backticks!

wordpress - How do I properly include bootstrap in a plugin? -

i working on plugin requires bootstrap. i not sure how include not conflict bootstrap mark-up in surrounding theme. i found thread below. no info there. in fact, appears end same question needed ask. so post on topic there's unfortunately no "no-conflict mode" css files. there's no guarantee you'll able detect whether or not bootstrap loaded. what could either keep relevant bootstrap parts plugin, prefix bootstrap selectors something, or (most common) include bootstrap plugin, allow user decide whether or not include (via custom meta value in admin).

javascript - Track Page Load Progress in percentage -

is possible show progress of loading page without ajax? i had come know this , possible. but how can in pure javascript or jquery? any ideas, views? right i'm using var pageloadstart=true,pageloaded=false; window.onload=function(){ pageloaded=true; pageloadstart=false; } but cant give progress in percentage. possible? how?

android - Exception in AnimationUtils.loadAnimation() (sometimes) -

i getting null pointer exception in line given in code below. problem is, exception occurs randomly. many times works throws exception (say 5% of times). appreciated. handler handler = new handler(); handler.postdelayed(new runnable() { public void run() { animation animation = animationutils.loadanimation(getactivity().getapplicationcontext(), r.anim.dialog_main_show_amination); //exception in line fabadddeliveryboy.startanimation(animation); fabadddeliveryboy.setvisibility(view.visible); } }, 500); the problem handler not tied fragment lifecycle. handler messages can fire after fragment detached activity, , getactivity() return null. as quick fix, can put runnable in variable , clear handler in e.g. ondestroyview() : handler.removecallbacks(runnable); for more elegant solution, consider making delay part of animation itself.

php - Remove string from string contain specific -

i need this: string = 'wednesday dynamic date'; remove word contain day means remove sunday , monday , tuesday , wednesday . output need dynamic date. use preg_replace that: echo preg_replace("/\b[a-z]*day\b/i", '', "wednesday dynamic date"); // output: dynamic date

python - opencv backgroundsubtractor not updating -

i'm using python 2.7.9 , opencv version 2.4.8. i'm trying detect moving cars movie. first frame in movie has car , once car leaves, contour stays there. tried playing backgroundsubtractormog params seemed ignored. setting history 10 nothing , 200 frames movie still have original contour. thanks reading in reading opencv tickets found sebastian ramirez found problem source , solution. the problem method "apply" has learningrate set 0 default. solve problem calling this: history = 10 # or whatever appropriate you fgmask = fgbg.apply(frame, learningrate = 1.0/history)

object - C# cannot override inherited member -

i'm learning c# book named chegwidden gladdis. i'm making same program , same code written in book. there problem. can't override method parent class. had readed book start of chapter, 5 times, everyhing same can't figure out why can't can't override method parent class. here's code base class passfailactivity.cs using system; namespace protectedmembers { public class passfailactivity : gradedactivity2 { private double minpassingscore; // minimum passing score /// <summary> /// constructor sets minimum passing score /// </summary> /// <param name="mps">the minimum passing score.</param> public passfailactivity(double mps) { minpassingscore = mps; } /// <summary> /// getgrade method returns letter grade determined /// score field. methos overrides base class method. /// </summary> ///

json - C# RESTful WCF WebService error -

i created restful/json web service i can consume browser not adding service reference project: fails endpointnotfoundexception: no endpoint listening on /.../getdevicses, inner exception: remote server not found (404). one thing think important notice in browser call uri .../devices whereas endpointnotfoundexception seems .../getdevices. my service exposes 1 method: [operationcontract] [webget( requestformat = webmessageformat.json, uritemplate = "/devices" )] deviceinforecord[] getdevices(); firewalls disabled , since can consume browser think service configuration ok, i'm not sure client configuration. here client configuration: <behaviors> <endpointbehaviors> <behavior name="web"> <webhttp defaultoutgoingresponseformat="json"/> </behavior> </endpointbehaviors> </behaviors> <client> <endpoint address="http://local

wpf - Set DoubleAnimation with Binding to an external object -

i have following style contains animation used expand border : <style targettype="{x:type border}" x:key="borderanimations"> <setter property="flowdirection" value="righttoleft" /> <style.triggers> <eventtrigger routedevent="mouseenter"> <beginstoryboard> <storyboard > <doubleanimation storyboard.targetproperty="width" begintime="0:0:0" from="" to="420" duration="0:0:0.2" /> </storyboard> </beginstoryboard> </eventtrigger> <eventtrigger routedevent="mouseleave"> <beginstoryboard> <storyboard > <doubleanimation storyboard.targetproperty="wi

Observer pattern for Yammer api -

i using yammer api (java script sdk) integrating yammer platform our app. problem "when submitting post app, it's getting updated on yammer platform, when post yammer platform, app not getting updated". know whether there observer pattern yammer api in java script sdk. no. in app i'm issuing request messages refresh data on client side.

java - Jmeter writing the request details to CSV/XML from view result tree listener -

when write data of view result tree listener csv/xml , not write data parameters used in request csv. all details related response.how the request details in csv can have 1 one mapping of request , response , find out request has failed. you can set following properties true results file used see in view results tree listener jmeter.save.saveservice.output_format=xml jmeter.save.saveservice.response_data=true jmeter.save.saveservice.samplerdata=true jmeter.save.saveservice.requestheaders=true jmeter.save.saveservice.url=true jmeter.save.saveservice.responseheaders=true above properties can either set in jmeter.properties file or in user.properties file (both live under /bin folder of jmeter installation) or passed command-line arguments if run jmeter in non-gui mode jmeter -jjmeter.save.saveservice.output_format=xml -jjmeter.save.saveservice.response_data=true -jjmeter.save.saveservice.samplerdata=true -jjmeter.save.saveservice.requestheaders=true -jjmeter.save

Php curl automatically set body in HTTP GET request -

here issue. have 3 environments (apache + mysql + mongodb) : continuous integration, uat , prod. all 3 environments on different vm hosted on same proxmox , accessible through nginx server. i use php curl download csv files. particular csv file provider, php curl not achieve download file on continuous intergration environment while on uat , prod. after hours of investigation, closest came problem, guess, outputting request header. as can see below, on continuous integration environment, php curl set "content-length" header suggest sending body within request. have not been able debug request body now. i don't understand why php curl add request body on ci environment when not in uat , prod env. i joined php curl setup code. any appreciated :) (request header in continuous integration env) ------------------------------------------ http/1.1 413 request entity large date: mon, 15 dec 2014 21:01:22 gmt server: apache content-length: 341 connection: close c

sql - Temp table of numbers that do not exist in another table -

i have table called usednumbers usednumbers contains number in range of 1 , 9999 . numbers can anywhere in range. i want create temp table #unusednumbers . so far found code create range of numbers 1 9999. i'm not entirely sure how insert temp table , extract numbers not exist in usednumbers . ;with x ( select top (224) [object_id] sys.all_objects ) select top (9999) n = row_number() on (order x.[object_id]) x cross join x y order n; i love understand more if help. you try like: ;with x ( select top (224) [object_id] sys.all_objects ) select top (9999) n = row_number() on (order x.[object_id]) x cross join x y except select num usednumbers order n

grails app terminates after some idle time – what triggers unexpected shutdown? -

i've got grails 2.4.3 app internal use in company. problem is, after time when had running ( grails dev run-app ), terminates listening without prior notice: info [thread-3]: pausing protocolhandler ["http-bio-8080"] info [thread-3]: stopping service tomcat ### shutting down. info [thread-3]: stopping protocolhandler ["http-bio-8080"] info [thread-3]: destroying protocolhandler ["http-bio-8080"] (the 3rd line destroy() method in bootstrap.groovy) for datasource connections, there keepalive strategies pooled connections. i'd grails app stay online, too. how can investigate on causes server stop listening? common issue , can solved config? edit: the root logger shows following on debug level: debug [http-bio-8080-exec-4]: counting down[http-bio-8080-exec-4] latch=2 debug [http-bio-8080-exec-1]: error parsing http request header java.net.sockettimeoutexception: read timed out @ java.net.socketinputstream.socketread0(nativ

ios7 - Push notifications not coming when we download the build from testflight or diawi iOS -

Image
i have created .pem , .p12 file http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 tutorial. using java server exported .p12 key using link there error of directly exporting .p12 file cannot send push notifications using javapns/javaapns ssl handshake failure . everything working great in debug mode. whenever install build xcode receive push notifications everytime. after archiving , uploading build on testflight or diawi , installing on device didn't push notifications. getting device token apns server. on debugging @ server side found device token receive , send notifications invalid. response sent apns server our java server. . using xcode 6.0 or later , app compatible ios7.0 or later. , yes have made checks in registering remote notifications ios 8 , 7.has has faced issue because earlier in xcode 5 series hasn't happen. please help any appreciated. thanks if followed ray wenderlich's tutorial , made work in

Cookie Law, does the user need to opt in, or is a link to cookie information enough -

struggling find information on this... do have have e.g pop / information bar says cookie message , has opt in button. or can have link in footer says cookie , data information etc. some people later , if thats allowed makes no sense else... implied consent absolutely fine, unless you're dealing sensitive data, means have display information regarding cookie use user doesn't have click on accept before can carry on. uk information commissioners office has information: https://ico.org.uk/for-organisations/guide-to-pecr/cookies . i'm not sure you're based law europe wide advice same regardless. the uk government site uses implied consent if they're doing can assume you'll ok. as sites explicit consent, remember when ruling first made , there assumption explicit consent required sites implemented rules early. honest, can't remember visiting site required me agree cookie use before continuing, buttons there rid of annoying messages. si

Bayesian Correlation using PyMC -

Image
i'm pretty new pymc, , i'm trying implement simple bayesian correlation model, defined in chapter 5 of "bayesian cognitive modeling: practical course" , defined below: i've put code in ipython notebook here , code snippet follows: mu1 = normal('mu1', 0, 0.001) mu2 = normal('mu2', 0, 0.001) lambda1 = gamma('lambda1', 0.001, 0.001) lambda2 = gamma('lambda2', 0.001, 0.001) rho = uniform('r', -1, 1) @pymc.deterministic def mean(mu1=mu1, mu2=mu2): return np.array([mu1, mu2]) @pymc.deterministic def precision(lambda1=lambda1, lambda2=lambda2, rho=rho): sigma1 = 1 / sqrt(lambda1) sigma2 = 1 / sqrt(lambda2) ss1 = sigma1 * sigma2 ss2 = sigma2 * sigma2 rss = rho * sigma1 * sigma2 return np.power(np.mat([[ss1, rss], [rss, ss2]]), -1) xy = mvnormal('xy', mu=mean, tau=precision, value=data, observed=true) m = pymc.mcmc(locals()) m.sample(10000, 5000) the error "error: failed in con

extjs - Sencha Touch and MathJax -

i trying display math-equations in sencha view component (extends: ext.container), using ext.label component , mathjax js. (as suggested answering other question: display math symbols in ext.js / sencha touch ) this initialization of view component: ext.define('tiquiz3.view.question', { extend: 'ext.container', ... requires: ['ext.label', ...], config: { fullscreen: true, ... layout: { type: 'vbox', align: 'stretch' } }, initialize: function() { this.callparent(); ... var questionlabel = { xtype: 'label', style: { 'border':'1px solid black', 'background':'white' }, margin: 10, padding: 10, html: "<div>es sei $l = \{011, 01, 11, 100\}$ \"uber dem alphabet $\sigma = \{0,1\}$.</div>", flex: 1 }; ... this.add([...,questionlabel,...]); }

java - Using findBy in transactional context -

given: controller personcontroller @transactional action save service personservice method populateproperties(personinstance) being called controller action i'd populate personinstance properties based on data persisted in database, this: def personlookupdata = personlookupdata.findbyusername(personinstance.username) personinstance.firstname = personlookupdata.firstname the findbyusername method flushes hibernate session , in order avoid (because has been giving me problems described here ), this: def personlookupdata = personlookupdata.withnewsession { personlookupdata.findbyusername(personinstance.username) } personinstance.firstname = personlookupdata.firstname this want (lets me use findby without flushing session), , fine when there couple of findby s use, given deeper call stack (in terms of services) , more database lookups in different places, using withnewsession everywhere becomes bit ugly. apart making personlookupservice collect required da

django - Foursquare API giving local names -

i using foursquare's venue explore option city nearest user. https://api.foursquare.com/v2/venues/explore?client_id=client_id&client_secret=client_secret&v=20141215&m=foursquare&ll=70.1234,28.234324&limit=2 when try query in postman country norway when run through terminal norwegian name norge am missing here? how international name norway foursquare so giving parameter locale specifying en solved case. https://developer.foursquare.com/overview/versioning#internationalization

Heroku timezone difference rails -

i have problem heroku timezone heroku: time.zone.now => tue, 16 dec 2014 14:41:57 msk +04:00 but on localhost is time.zone.now => tue, 16 dec 2014 13:41:01 msk +03:00 where problem? im did heroku config:add tz="my tz" in application.rb class application < rails::application config.generators |g| config.time_zone = 'moscow' g.orm :mongo_mapper end there no such tz name moscow should europe/moscow heroku config:add tz = "europe/moscow" please refer link available time zone http://en.wikipedia.org/wiki/list_of_tz_database_time_zones also more details https://coderwall.com/p/j9_e8a/set-timezone-for-your-heroku-app

chunked - Malsup jQuery form upload in chunks -

i use malsup jquery form upload. works php. http://malsup.com/jquery/form/ is there nice way add chunked uploads using malsup? suggestions? var xhr = new xmlhttprequest(); var percent = $('.percent'); var bar = $('.bar'); /* submit form ajax request */ $('form').ajaxform({ datatype: 'json', beforesend: function() { bar.width('0%'); percent.html('0%'); }, uploadprogress: function(event, position, total, percentcomplete) { var pvel = percentcomplete + '%'; bar.width(pvel); percent.html(pvel); }, success: function(xhr) { var percentval = '100%'; bar.width(percentval) percent.html(percentval); }, complete: function(xhr) { var url = window.location.origin = window.location.protocol+"//"+window.location.host+"/t

nginx rewrite url with dates in and change the format -

i'm moving blog on ghost , ok except around 50% of blog posts broken due date not being 0 padded i.e. old site format: http://www.example.com/blog/index.cfm/2013/8/9/my-slug new site format: http://www.example.com/2013/08/09/my-slug removing /blog/index.cfm easy via location /blog/index.cfm { rewrite ^/blog/index.cfm(/.*)$ $1 last; } but cannot think of way 0 pad dates (and there around 700 posts). put several rewrites. location /blog/index.cfm { # 2013/1/1 rewrite ^/blog/index.cfm(/\d+)/(\d)/(\d)(/.*)?$ $1/0$2/0$3$4 last; # 2013/1/11 rewrite ^/blog/index.cfm(/\d+)/(\d)/(\d\d)(/.*)?$ $1/0$2/$3$4 last; # 2013/11/1 rewrite ^/blog/index.cfm(/\d+)/(\d\d)/(\d)(/.*)?$ $1/$2/0$3$4 last; # other rewrite ^/blog/index.cfm(/.*)$ $1 last; }

html - Aspect ratio for background-image, when data is image/jpeg;base64 -

i have div background-image set data:image/jpeg;base64 format: <div style="background-image: url(data:image/jpeg;base64,/9j/4aaq... i show full image respecting aspect ratio, using available space. use: width: 90vw; height: 100vh; background-size: contain; background-repeat: no-repeat; background-position: center; in case image stretched using full div size. suggestions? update: div data: http://jsfiddle.net/witepo/bksmhtwc/ update 2: expected result: http://1drv.ms/1utj8nd div: http://codepen.io/anon/pen/lezpjj try this background-size: cover; background-repeat: no-repeat; background-position: center center;

Replace $ in Stata variable labels with \textdollar -

i have variables dollar signs (i.e., $ ) in variable labels. causes problems downstream in code (i later modify these labels , dollar signs deregister empty global macros). replace these dollar signs latex's \textdollar using stata's subinstr() function. but can't figure out. possible? or should resign doing more manually? or looking other characters near or around $ in variable labels? clear set obs 10 generate x = runiform() label variable x "label $mil" generate y = runiform() label variable y "another label $mil" describe foreach v of varlist * { local name : variable label `v' local name `=subinstr("`name'", "$mil", "\textdollar", .)' label variable `v' "`name'" } describe this removes label altogether. (the problem has changed, why give separate answer.) having $something in variable label problematic because stata treat macro , therefore dereference

android - libstreaming - videoQuality not being set -

i developing app stream live video android device via rtsp using libstreaming library. i trying change video quality using following code: private void initrtspclient() { msession = sessionbuilder.getinstance() .setcontext(getapplicationcontext()) .setaudioencoder(sessionbuilder.audio_none) .setvideoencoder(sessionbuilder.video_h264) .setvideoquality(new videoquality(480, 360, 30, 500)) .setsurfaceview(msurfaceview).setprevieworientation(0) .setcallback(this).build(); but when app running on device getting following error in logs: 12-16 12:03:32.601 4596-4609/com.example.glassapp e/encoderdebugger﹕ no usable encoder found on phone resolution 480x360 12-16 12:03:32.601 4596-4609/com.example.glassapp e/h264stream﹕ resolution not supported mediacodec api, fallback on old streamign method. but resolution stated in suppored media format doc (enoding in h.264) http://developer.android.com/guide/appendix/media-formats.

c# - The type or namespace name does not exist in the namespace ''are you missing an assembly reference ?" -

i have solution worked fine until last couple of days contains around 15 projects dlls or webforms applications. use resharper peculiarity related solution. there naturally projects referencing other ones within solution , 1 compile independently , run ok except 1 webforms app (a) refers namespaces within webforms app(b) dll. (a) has 7 exceptions when try debug along lines of "the type or namespace name [myclass] not exist in namespace '[(b) namespace]' (are missing assembly reference?)" all projects target same .net version 3.5 target same processor cpu architecture, have cleaned solution, recreated reference (b) (a), can see namespace in object explorer when looking @ (a)\bin it's there... still (a) @ build has these errors above , on day cannot life of me work out why... can help? if run webform app (b), builds , runs without problem... the mention of resharper due not working solution anymore (but work others solutions), behaviour of resharper so

node.js - Forever monitor and sqlite3 -

my node app returning error: sqlite_cantopen: unable open database file my app has following structure: .controllers/ |--getter.js |--setter.js .system.js .slave.js system.js var forever = require('forever-monitor'); var path = require('path'); var relativedir = path.dirname(module.filename); var childworker = new(forever.monitor)(path.join(relativedir,'slave.js'), { max: 3, silent: true, options: [] }); slave.js ... var getter = require('./controllers/getter.js'); var setter = require('./controllers/setter.js'); ... getter.js/setter.js var fs = require('fs'); var sqlite3 = require('sqlite3').verbose(); var dbpath = '/absolutepath/db'; if (fs.existssync(dbpath)) { console.log("[getter] db file found"); var db = new sqlite3.database(dbpath, sqlite3.open_readonly); } else { console.log("[getter] cannot find db file"); } i've tried changing absolute paths relative p

c# - What is a NullReferenceException, and how do I fix it? -

i have code , when executes, throws nullreferenceexception , saying: object reference not set instance of object. what mean, , can fix error? what cause? bottom line you trying use null (or nothing in vb.net). means either set null , or never set @ all. like else, null gets passed around. if null in method "a", method "b" passed null to method "a". the rest of article goes more detail , shows mistakes many programmers make can lead nullreferenceexception . more specifically the runtime throwing nullreferenceexception always means same thing: trying use reference, , reference not initialized (or once initialized, no longer initialized). this means reference null , , cannot access members (such methods) through null reference. simplest case: string foo = null; foo.toupper(); this throw nullreferenceexception @ second line because can't call instance method toupper() on string reference pointing null .

vb.net - Event from other class -

i have "catch" event class can't. project contains 2 forms: form1 , form2 , class params. form 1 contain 1 button have change property value in class props. , form2 have know when props raises event. here situation: ''form1 code public class form1 dim p new params private sub form1_load(byval sender object, byval e system.eventargs) handles me.load form2.show() end sub private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click p.demo = "mytry" end sub end class ''form2 code public class form2 private withevents p params private sub pchanged(byval propertyname string) handles p.propchanged messagebox.show(propertyname) end sub end class ''class params code public class params public event propchanged(byval propname string) private _demo string public property demo() string return _demo end set(byval value string) _demo = value

C# - Modify File Permission ASP.NET MVC -

i want modify file's permission, , talking permission 666 / 777 etc. in other words how tio change permission of file 666. goal changing permission of uploaded file on asp.net mvc web app. public string uploadfile(httprequestbase currentrequest) { string filename = ""; (int = 0; < currentrequest.files.count; i++) { if (currentrequest.files[i].contentlength > 0) { string strfilename = guid.newguid().tostring() + path.getextension(currentrequest.files[i].filename); currentrequest.files[i].saveas(httpcontext.current.server.mappath("/upload/task/" + strfilename)); filename = strfilename; } } return filename; } } you should @ file.setaccesscontrol method public static void setaccesscontrol( string path, filesecurity filesecurity ) for example how filesecurity 

c# - Request parameter in Windows Mobile for REST API's -

i have 1 windows handheld device application on .net framework 3.5 has requirement of accessing rest api. rest api gives me json output going process later. have following code that:- httpwebrequest webrequest; string result = string.empty; try { webrequest = (httpwebrequest)webrequest.create(url); webrequest.method = "post"; webrequest.keepalive = false; webrequest.contenttype = "application/x-www-form-urlencoded"; using (webresponse response = webrequest.getresponse()) { using (streamreader streamreader = new streamreader(response.getresponsestream())) { result = streamreader.readtoend(); } } } catch (exception ex) { result = ex.message; } the url variable holding url api query parameters in it. example " http://www.something.c

php - How to change code on the front page of a Magento store? -

Image
i helping out magento store configured developer gone company, , have no experience using magento @ all. instead of using built-in newsletter tools, created html form points different server (which owns) , no longer notifications when customer signs it. somehow, embedded html front page of store's website. spent hours looking html , did find it, in page called "subscribe.phtml". got happy, changed code inside page want be, uploaded server and... nothing. no change @ site. flushed cache did not help. the page not appear have code in it. in cms->pages->content, shows this: {{block type="featuredproductslider/featuredproductslider" name="featuredproductslider" template="magentothem/featuredproductslider/featuredproductslider.phtml"}}{{block type="newproduct/newproduct" name="newproduct" template="magentothem/newproduct/newproduct.phtml"}} under design, shows layout "3 columns". the

c# - What's the System.Linq.Expressions.ExpressionVisitor.VisitExtension and the System.Linq.Expressions.ExpressionType.Extension for? -

the system.linq.expressions.expressionvisitor has method named visitextension seems nothing other call visitchildren method on expression being visited. protected internal virtual expression visitextension(expression node) { return node.visitchildren(this); } i understand visitchildren does. understand virtual implementation can , perhaps meant overriden. gather documentation of method on msdn , sparing in words , briefly remarks: visits children of extension expression. can overridden visit or rewrite specific extension nodes. if not overridden, method call visitchildren, gives node chance walk children. default, visitchildren try reduce node. i not find explanation helpful. specifically, phrase jets me out of abilities of comprehension "or rewrite specific extension nodes." i understand rest of it, pertains reduction or breaking down of expression sub-expressions. also in same namespace enumeration named expressiontype , purpose of understand well.

javascript - generate two arrays of randoms between an interval -

i'd use function generate 2 arrays of same length values of first , second array shouldnt duplicates , neither values in first array shall not in second one. what i've tried far: function generatesiruri(width){ var exists = false; for(var = 0; < width; i++){ var randomnumber = math.floor(math.random()*101); var secondrandomnumber = math.floor(math.random()*101); if(sir1[i] == randomnumber && sir2[i] == secondrandomnumber && randomnumber == secondrandomnumber && sir1[i] == secondrandomnumber){ exists = true; return; } if(!exists){ sir1.push(randomnumber); sir2.push(secondrandomnumber); } } sortascending(sir1); sortascending(sir2); } function sortascending(array){ var sort; for(i = 0; < array.length; i++){ for(var j = 0; j < array.length; j++){

Python palindrome programming -

the code bit messy, point divide different functions. i understand can test palindrome how use boolean variable, instead of stating straight away print function. def trial(): palindrome = true c = str(input("hey: ")) in range(len(c)): = c[i] s = c[-(i+1)] if (a == s): return break else: print ("no, not plaindrome") break return palindrom def output(): print true trial() output() you can use return value within function def ispalindrome(s): return s == s[::-1] def output(s): if ispalindrome(s): # use return value of above function print('it palindrome') else: print('not palindrome') for example >>> output('hello') not palindrome >>> output('abcba') palindrome

mapreduce - Piping data into jobs in Hadoop MR/Pig -

i have 3 different type of jobs running on data in hdfs. these 3 jobs have run separately in current scenario. now, we want run 3 jobs piping output data of 1 job other job without writing data in hdfs improve architecture , overall performance. any suggestions welcome scenario. ps : oozie not fitting workflow.cascading framework ruled out because of scalability issues. thanks hadoop inherently writes storage (e.g. hdfs) after m/r steps. if want in memory, maybe need spark.

excel - Make two values in a cell sortable -

Image
can make 2 values in cell sortable? i need in same cell. possible write such. "value1"; "value2" or value1 | value2? i want list be: a b c d e f ... and not ab c d e f ... see picture. i believe excel treats data in cell 1 data. not recognize whitespace separation of data. your best bet split , b 2 cells vertically merge cells right, column-by-column. example