Posts

Showing posts from August, 2010

java - No empty constructor: android class -

my problem is, transferring 2 arrays between activities. return 1 activity. there getting these 2 activities constructor( think ). correct? why getting error: no empty constructor? here class activites coming from: public planoutputactivity fetchallroutes(string startstop, string endstop, string time) { . . . return new planoutputactivity(convertarray(),routenarray); here activity wanna these 2 arrays: public class planoutputactivity extends activity { intent intent; object[][] routenarray; string[][] itemsarray; databasehelperactivity mdbh; public int result_ok = 123; public int request_ok = 456; public planoutputactivity(string[][] itemsarray, string[][] routenarray){ setcontentview(r.layout.planoutputlayout); this.routenarray = routenarray; this.itemsarray = itemsarray; } @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated constructor stub super.oncreate(s

ejb - Firing CDI event from interceptor class -

is possible fire cdi events within interceptor ? (using jboss 7.1.1) for example, if have interceptor performanceloginterceptor @interceptors({performanceloginterceptor.class}) public class processhandler extends handlerbase { . . . could fire event such: public class performanceloginterceptor { private logger log = loggerfactory.getlogger("performancelog"); @ejb performancemonitor performancemonitor; @inject event<exceptionevent> exceptionevent; @aroundinvoke @aroundtimeout public object performancelog( invocationcontext invocationcontext ) throws exception { string methodname = invocationcontext.getmethod().tostring(); long start = system.currenttimemillis(); try { return invocationcontext.proceed(); } catch( exception e ) { log.warn( "during invocation of: {} exception occured: {}", methodname, throwables.getrootcause(e).getmessage() ); per

ios - Create perpendicular line to CGPathRef -

i using skshapenodes dynamically draw lines updating path property user touches screen. once line complete, append new fixed length perpendicular line end of path. i have looked cgaffinetransform rotate new line based on end point of path, far haven't had luck. tips or insight appreciated. some of current code reference looks like: - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event { uitouch* touch = [touches anyobject]; cgpoint positioninscene = [touch locationinnode:self]; //add line new coordinates user moved cgpathaddlinetopoint(pathtodraw, null, positioninscene.x, positioninscene.y); } -(void)touchesended:(nsset *)touches withevent:(uievent *)event { //create local copy of path cgpathref mypath_ = pathtodraw; cgpoint mypoint = cgpathgetcurrentpoint(pathtodraw); //create rectangle append end of line cgrect newrect = cgrectmake(mypoint.x, mypoint.y, 25, 3); cgpathref newpath = cgpathcreatewith

z3 - Why the unstable branch is not able to prove a theorem but the master branch is able? -

i trying prove theorem in group theory using following z3 smt-lib code (declare-sort s) (declare-fun identity () s) (declare-fun product (s s s) bool) (declare-fun inverse (s) s) (declare-fun multiply (s s) s) (assert (forall ((x s)) (product identity x x) )) (assert (forall ((x s)) (product x identity x) )) (assert (forall ((x s)) (product (inverse x) x identity) )) (assert (forall ((x s)) (product x (inverse x) identity) )) (assert (forall ((x s) (y s)) (product x y (multiply x y)) )) ;;(assert (forall ((x s) (y s) (z s) (w s)) (or (not (product x y z)) ;; (not (product x y w)) ;; (= z w)))) (assert (forall ((x s) (y s) (z s) (u s) (v s) (w s)) (or (not (product x y u)) (not (product y z v)) (not (product u z w) ) (product x v w)))) (assert (foral

ruby open pathname with specified encoding -

i trying open files telling ruby 1.9.3 treat them utf-8 encoding. require 'pathname' pathname.glob("/users/wes/desktop/uf2/*.ics").each { |f| puts f.read(["encoding:utf-8"]) } the class documentation goes through several levels of indirection, not sure specifying encoding properly. when try it, however, error message ics_scanner_strucdoc.rb:4:in read': can't convert array integer (typeerror) ics_scanner_strucdoc.rb:4:in read' ics_scanner_strucdoc.rb:4:in block in <main>' ics_scanner_strucdoc.rb:3:in each' ics_scanner_strucdoc.rb:3:in `' this error message leads me believe read trying interpret open_args optional leading argument, length of read. if put optional parameters in, in puts f.read(100000, 0, ["encoding:utf-8"]) error message says there many arguments. what appropriate way specify encoding? correct inconsistency between documentation , behavior of class? mac

c# - Reference shell32.dll in a programmatically compiled program? -

i need shell32 in program create shortcut. this code: var compiler = new csharpcodeprovider(); var params = new system.codedom.compiler.compilerparameters { generateexecutable = true, outputassembly = outputname, referencedassemblies = { "system.dll", "system.core.dll", "system.windows.forms.dll", "system.drawing.dll", @"c:\windows\system32\shell32.dll" } }; doing this, error: metadata file c:\windows\system32\shell32.dll not opened. attempt made load program incorrect format. found nothing while searching.. wasn't sure search :/ how go doing this? shell32.dll (windows file systems don't care case, "s" or "s" shouldn't matter) not .net assembly , can't treated such. if want call functions exported non-.net libraries, should use dllimportattribute .

html - Responsive diamond grid -

Image
i have selection of squares (squares turned 45° diamonds) want use make big diamond shape central red diamond. i having issues organising diamonds , href seems fail. how position responsive diamonds in regular grid ? her my code : body { background: black; color: #000000; font: 13px georgia, serif; line-height: 1.4; font-weight: lighter; text-rendering: optimizelegibility; } #diamond { width: 0; height: 0; border: 50px solid transparent; border-bottom-color: white; position: relative; top: -50px; } #diamond:after { content: ''; position: absolute; left: -50px; top: 50px; width: 0; height: 0; border: 50px solid transparent; border-top-color: white; } #diamond_red { width: 0; height: 0; border: 50px solid transparent; border-bottom-color: #aa1c08; position: relative; top: -50px; } #diamond_red:after { content: ''; position: absolute; left: -50px; top: 50px

ruby on rails - Discourse.js and "cooked" strings -

i have been reviewing source code discourse.js, discussion forum written in ember/rails/postgres. i'm researching best practices in avoiding xss vulnerabilitys in these kinds of apps. i notice discourse uses notion of "cooked" strings, partially pre-escaped strings used things bodies of posts, displays them in ember using triple mustaches ( {{{}}} ). in other cases, however, such post title, discourse sends , receives raw, unescaped strings such "this & tag", , displays them using double mustaches { {{}} ). i have following questions this: (1) seems discourse uses "cooking" fields in markdown supported, such post body. cooking merely way deal-with post-processed markdown fields, or intended address xss issues? (2) not considered xss vulnerability have raw strings, including things html tags or html tags, passed server client in json? xss sniffers apparently complain such things, , people appear recommending html entity escaping and/o

c++ - POSIX_SPAWN Faliure -

#include<iostream> #include<spawn.h> #include<stdlib.h> #include<sys/wait.h> using namespace std; int main(int argc,char *argv[],char *envp[]) { pid_t c1,c2; int ret1,ret2,val; ret1=posix_spawn(&c1,"t.cpp",null,null,argv,envp); ret2=posix_spawn(&c2,"t.cpp",null,null,argv,envp); wait(&val); wait(&val); cout<<"\n\nchild process 1: "<<c1; cout<<"\n\nchild process 2: "<<c2; cout<<"\n\n"<<ret1; cout<<"\n\n"<<ret2<<"\n"; } above code creates 2 child processes , each process in supposed execute t.cpp simple hello world code in c++. doesnt execute it. in fact code works without creating t.cpp. can explain why happening , how execute t1.cpp? this way of creating new process: posix_spawn(&pid,"my_exe",null,null,argv,envp); where my_exe executable file created after build program. in case t executable

php - CodeIgniter in Sub-directory gives 404 error, when CodeIgniter is installed in / root folder also -

i have site created using codeigniter, , application installed on web root (/). shared hosting environment on godaddy. creating development environment, copied same , created /development folder in / root. now, main site works well, when try use link on sub-directory (linked different domain name), giving me 404 error. i have tried solution given on stackoverflow, not work. duplicate of: codeigniter won't run in subdirectory so structure is: /system /application1 /index.php /.htaccess /development/application2 /development/index.php /development/.htaccess the top level .htaccess contains: <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{request_uri} ^system.* rewriterule ^(.*)$ index.php?/$1 [l] rewritecond %{request_uri} ^application.* rewriterule ^(.*)$ index.php/$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?/$1 [l] </ifmodule>

php - sub query needed I think -

i asked question yesterday , reposting simple version of make sure there no confusion attempting. adam toyota joe toyota rick mazda select * table name adam , return rows name not adam have same car adam. so search adam return rows: adam & joe. select * `table` `name` = 'adam' or car in ( select car `table` `name` = 'adam' ) the "name not adam but" part not making sense, since adams anyway.

javascript - How can I add content to a page after opening the link in a new window/tab? -

i'm trying add content page opened in new tab/window, , nothing seems happening. here of code: var newwindow = window.open('/window'); newwindow.document.body.innerhtml += '<div>this test</div>'; any ideas? as have tagged jquery: var w = window.open(); var html = '<div>this test</div>'; $(w.document.body).html(html); demo

objective c - Pan Gesture had ended location -

i'm trying have when pan gesture ends, checks see if end location within area, in case square. have following code, , more less works reason when pan ends in square, it's saying not. -(void)panhandler:(uipangesturerecognizer*)recognizer{ cgpoint translation = [recognizer translationinview:self.view]; switch (recognizer.state){ case uigesturerecognizerstatebegan: _stickimage.center = cgpointmake(_stickimage.center.x + translation.x, _stickimage.center.y + translation.y); break; case uigesturerecognizerstatechanged: _stickimage.center = cgpointmake(_stickimage.center.x + translation.x, _stickimage.center.y + translation.y); [recognizer settranslation:cgpointmake(0, 0) inview:self.view]; break; case uigesturerecognizerstateended: nslog(@"ended"); if(translation.x > _rectview.frame.origin.x && translation.x < (_rectview.frame.origin.x + _rectview.frame.size.width)){ if(tr

c++ - While loop behaving unexpectedly -

i not sure if problem compiler specific or not, i'll ask anyways. i'm using ccs (code composer studio), ide texas instruments program msp430 microcontroller. as usual, i'm making beginner program of making led blink, located in last bit of p1out register. here's code doesn't work (i've omitted of other declarations, irrelevant): while(1){ int i; p1out ^= 0x01; = 10000; while(i != 0){ i--; } } now, here's loop work: while(1){ int i; p1out ^= 0x01; = 0; while(i < 10000){ i++; } } the 2 statements should equivalent, in first instance, led stays on , doesn't blink, while in second, works planned. i'm thinking has optimization done compiler, have no idea may wrong. the code being optimised away dead-code. don't want spin anyway, it's terribly wasteful on cpu cycles. want call usleep , like: #include <unistd.h> int micros

node.js - Angular / Nodejs / Jade dynamically display partials -

i have single page display multiple partials, depending on database values. @ moment using show/hide display div proper angular way, have been having trouble though. my routes.js is exports.index = function(req, res){ res.render('index'); }; exports.partials = function (req, res) { var name = req.params.name; res.render('partials/' + name); }; my controller function appctrl($scope, $http, $q, socket, $location) { $scope.config = [[ return variables http call ]] if($scope.config.name =='video') $scope.mainpvideo ==true; else $scope.mainpvideo ==false; if($scope.config.name =='audio') $scope.mainpaudio ==true; else $scope.mainpaudio ==false; if($scope.config.embed =='qa') $scope.qa ==true; else $scope.qa ==false; index.jade #box-1-content.auth-form-body(ng-show="mainpaudio" ) include partials/audio ul.presenterlist li presenters: li(ng-repea

r - Annotation of summary statistic on ggplot above bars on barchart -

Image
i created function takes dataframe, x , y variables , group variable arguments outputs barchart levels of x variable , facet group variable. want place text label above bar represents average of y. function worked until function follows: xtabar<- function(ds,xcat,yvar,group,formet=percent,color1=orange,color2=blue,...){ library(ggplot2) library(dplyr) library(scales) localenv<-environment() gg<-data.frame(ds,x=ds[,xcat],y=ds[,yvar],z=ds[,group] ) gg = transform(summarise(group_by(gg, x), sumvar= mean(y))) g<-ggplot(gg,aes(x=factor(x),y=y, fill=factor(x)))+stat_summary(fun.y=mean,geom="bar")+facet_wrap(~z)+scale_y_continuous(labels = formet)+xlab(xcat)+ylab(yvar)+scale_fill_manual(values=c(color1,color2)) #h<-g+geom_text(data=gg,aes(label=sumvar,x=factor(x),y=y), position = position_dodge(width = 0.8), vjust=-.6) h<-g+stat_summary(fun.y = mean, geom="text", aes(label=sumvars), vjust = 0) #g+scale_fill_manual(values=c("

php - How could I filter duplicates? -

information: table = giveaway form 1 = id form 2 = username form 3 = userid form 4 = wish end of information i trying make filter through duplicate usernames , userids note: people enter userid , username (it giveaway) can post me code that? try one: select `username`,`userid` `giveaway` group `username` having count(`username`) > 1 union select `username`,`userid` `giveaway` group `userid` having count(`userid`) > 1

javascript - Regular expression not working with jquery form validation plugin -

i using form validation plugin , using regular expression validate uk post code. using this reference regular expression in author says can validate post code. when try submit form , every kind of string says invalid. have tried following (samples taken wikipedia here page w1a 1hq ec1a 1bb m1 1aa b33 8th here js code $(document).ready(function(){ $.validator.addmethod("regex", function(value, element, regexp) { var re = new regexp(regexp); console.debug(re.test(value)) return this.optional(element) || re.test(value); }, "post code not valid" ); $("#addpropertyform").validate({ rules : { postcode : { required : true, regex: "(gir 0aa)|((([a-z-[qvx]][0-9][0-9]?)|(([a-z-[qvx]][a-z-[ijz]][0-9][0-9]?)|(([a-z-[qvx]][0-9][a-hjkstuw])|([a-z-[qvx]][a-z-[ijz]][0-9][abehmnprvwxy])))) [0-9][a-z-[cikmov]]{2})" } }, messages : { pos

javascript - angularjs - controller inheritance calling parent -

i have parent controller inside first module , "child" controller inside second module. second module has dependancy first. want "child" controller inherit "parent" controller. problem how call "parent" controller method. for example: secondmodule.controller("childbrowsectrl", function($scope, $injector, $controller){ $injector.invoke(parentbrowsectrl, this, {$scope:$scope}); //this overrides onedit function parent $scope.onedit = function(){ console.log("from edit console"); //how make work? parentbrowsectrl.$scope.onedit(); }; }); the html structure: <html> <head></head> <body> <div ng-view></div> </body> <script src="coreapp.js"></script> <script src="mainapp.js"></script> <script> angular.bootstrap(document,["ma

java - Spring Hateoas - REST clients need have model classes + resource classes -

we have implemented restful web service using spring hateoas project . project makes easy convert domain classes resources provides "self" links etc. what find confusing approach return resources classes when using get, when comes post or put use domain model. means client using restful api need have access domain classes + resource classes (resulting in clients having add hateoas project dependency). approach can seen in this blog entry . what correct approach here? work resources classes (for posts , puts well)? not each domain class has matching resource. take case object graph more complicated , resource has list of child object: public class storeresource { public string name; public list<location> children; } the location object wouldn't have resource class. for looks need provide both domain classes + existing resource classes clients.

reflection - Java private method hiding public accessors -

i have class this: import java.util.list; import java.util.string; import javax.xml.bind.annotation.xmltype; @xmltype public class foo { private list<foo> compound; private string bar; // private method used internally know // if compound instance private boolean iscompound() { return compound != null && compound.size() != 0; } // public setter compound instance var public void setcompound(list<foo> compound) { this.compound = compound; } // public getter compound instance var public list<foo> getcompound() { return compound; } public void setbar(string bar) { this.bar = bar; } public string getbar() { return bar; } } in normal use, class behaves expect. methods getcompound , setcompound , set compound list. however, i'm using class object that's passed in web service built using jax-ws. when jax-ws compiler sees class, ignores setco

ksh: zero divisor error when declaring a variable -

update : weird. looked further, , realized there 2 *ksh packages in server: pdksh-5.2.14-37.el5_8.1.x86_64 mksh-39-7.el6_4.1.x86_64 and mksh set in /etc/alternatives : lrwxrwxrwx 1 root root 9 apr 23 10:39 /etc/alternatives/ksh -> /bin/mksh i pointed /bin/pdksh , tried script again, , worked. to replicate issue, changed /bin/mksh , time, script worked without error. in short, not replicate issue anymore. weird. i'm looking further. thanks. given korn shell script: #!/bin/ksh u=$1 with $1 passed abc/s0mething , how can work around error? ksh: abc/s0mething 0 divisor. ksh version: @(#)mirbsd ksh r39 2009/08/01 thanks. it's weird, if asking workaround, can be u=`printf '%q' $1` however, not able replicate problem on system understand it... if doesn't work, shall remove answer.

git - Gerrit - Gitlab Integration -

in order improve development process, our organization have decided introduce gerrit in development workflow. person responsible implementing gerrit server. user guides available in internet helpful in implementing gerrit our existing workflow. using jenkins , sonar non-interactive users verifying builds. while dealing repositories 1 question rises. of open sources using gerrit-replication plugin replicate latest code public code repository. these public repositories exposed using gitlab users can clone code. here doesn't need public repository code maintained in house. is choice point both gitlab , gerrit common git repository location? any appreciated. you can use gerrit in front of gitlab via replication feature. replication feature not git clone/fetch, pushs (approved) changes remote repository. you have import repositories via e.g. 'git push origin master' requires permissions (or need admin). not big deal unless forget remove these permissions. if

push notifications iOS add device -

i new iphone , when tried test xcode project push notifications , doesn't token , failed token , think because when creating certificate didn't mark on device , want add device testing , token should ?? - (void)application:(uiapplication*)application didregisterforremotenotificationswithdevicetoken:(nsdata*)devicetoken { nslog(@"my token is: %@", devicetoken); } - (void)application:(uiapplication*)application didfailtoregisterforremotenotificationswitherror:(nserror*)error { nslog(@"failed token, error: %@", error); } for should first set provisioning profile in have added device udid. add below code register pushnotification in device. when run app first time ask permission . //push noti [[uiapplication sharedapplication]registerforremotenotificationtypes:(uiremotenotificationtypealert|uiremotenotificationtypebadge|uiremotenotificationtypesound)]; if allow below delegate called. , give device token. -(void)application:(uiappl

php - Symfony2 : Redirect user to index page when page not found or 404 errors thrown -

i want redirect user particular page when page not found error comes in symfony2. for customization of error page message created app\resources\twigbundle\views\exception\error404.html.twing but want redirect user particular page. how can that? thanks you want create event listener listens kernel.exception event kernel dispatches when encounters exception. then, check inside listener if exception instance of notfoundhttpexception , , if is, redirect page of choice. here's exemple: <?php // src/acme/demobundle/eventlistener/acmeexceptionlistener.php namespace acme\demobundle\eventlistener; use symfony\component\httpkernel\event\getresponseforexceptionevent; use symfony\component\httpfoundation\redirectresponse; use symfony\component\httpkernel\exception\notfoundhttpexception; class acmeexceptionlistener { public function onkernelexception(getresponseforexceptionevent $event) { // exception object received event $exception = $

html - How to lock JavaScript element on page? -

i made new element in javascript , appendchild ed parentnode of html element, seems great, see , can put data in it, when i'm trying change size of browser, or scroll element "following me". how can "lock" it, won't move place put in? thank answering. made it! :) used method wrote @abhishek verma. you can create element , apply following css class. .staticelement { position: static; top: 0: left: 250; } you can change position of div changing value of top left element in css.

Java Syntax expression.new MyClass -

having function public parametermethodparameterbuilder withparameter() { methodparameter parameter = new methodparameter(); return withparameter(parameter).new parametermethodparameterbuilder(parameter); } what mean of experession below withparameter(parameter).new parametermethodparameterbuilder(parameter) the syntax obj.new inner() creates , returns instance of inner class(*) inner linked instance obj of encapsulating class. when inner class declared, need instance of encapsulating class instantiate inner class. syntax confronted purpose. here simplest example this: public class mainclass { public class innerclass { } } you instantiate innerclass way: mainclass mc = new mainclass(); mc.new innerclass(); (*) inner class = non-static nested class

xmlhttprequest - Flash crossdomain multipart POST not working? -

i'm using moxie xhr2 polyfill issue crossdomain post file upload, using formdata construct multipart request containing file object fileinput . using html5 runtime, request successful , file uploaded. however, when using flash runtime, crossdomain.xml requested, request hits readystate 4 status of 0, suggesting request cancelled because invalid cross-domain request. the crossdomain.xml spec mentions nothing request methods. quick search on moxie github turns this issue , seems have been resolved, although issue still open. unlike in issue, i'm not seeing any request go through after crossdomain.xml . the code send request: var xhr = new moxie.xmlhttprequest(); xhr.open('post', url, true); xhr.bind('load', function() { if(this.status === 200) { // yay! } else { // boo! } }); var form = new moxie.formdata(); form.append('file', file); // file moxie.file fileinput xhr.send(form); my crossdomain.xml following: <?x

multithreading - What happens during an ioctl/syscall done in thread while another thread is forking? -

i've read a lot can happen when mixing threads , forking , should better avoided. i'm finding myself in situation don't have choice , receive kernel-crash of kernel-module. my reduced test-case has 2 threads. 1 of doing ioctls open device-node in loop. other 1 doing 1 fork, waits child exit, immediately. if use pthread_atfork synchronized thread fork-call working. where can @ find out more on happens during fork on open file-descriptors executing ioctl ? kind of corruption can happen? edit : andreas made me change test case. instead of having child exiting immediatly i'm not waiting 10 seconds before exiting. i'm collecting pid in parent-process later waitpid. i'm forking 100 times. if makes crash after 2 or 3 forks. there should no problem caused threading in regard. there should no kernel crashes. from description sounds writing own kernel module handles file descriptor in question. note forked process gets copies of open file descriptor

winforms - Multiple child and parent form in C# -

i have 6 forms (let f1,f2,f2a,f2b,f2c,f2d) i'm trying make f2a - f2d childs of f2 while f2 parentform f1 , f1 child form f2 what i've tried f1 private void button1_click(object sender, eventargs e) { f2 nx = new f2(this); this.visible = false; nx.visible = true; } f2 public f2(f1 parentform) { initializecomponent(); this.of = parentform; f2a na = new f2a(this); //it give me error describe down there. } public f1 of; f2a - f2d public f2* (f2 parentform) //well lets * stand letter of each form { initializecomponent(); this.of = parentform; } public f2 of; on f2 gives me 2 error 1.the best overloaded method match 'gui_x.f2a.f2a(system.windows.forms.f2)' has invalid arguments 2.argument 1: cannot convert 'gui_x.f2' 'system.windows.forms.mainmenu' so why isn't work f2 f2a - f2d while it's work f1 f2 ? wrong put ?how can resolve ? i'm new c#

PHP odbc_connect Foxpro database -

i'm wondering if it's @ possible connect foxpro database or free table via php odbc_connect . i've tried other examples doesn't want connect. if i'm using odbc_connect need put in quotes? $conn = odbc_connect ('','',''); there no password foxpro database or user associated table. value of $dsn variable? this page shows appropriate odbc connection strings vfp, both database , free tables: https://www.connectionstrings.com/visual-foxpro/

javascript - Google Plus API onload callback behavior -

i trying load google plus api within function in object, like: var myobject = { initialize : function(options) { window.___gcfg = { parsetags : 'explicit' }; (function() { var po = document.createelement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js?onload=onloadgoogleplus'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(po, s); })(); ... then have onloadgoogleplus() defined outside object, regular global function. now, if execute anonymous function load gapi within object, using initialize() function callback not called. in case "this" keyword points object. but, if following (which makes "this" keyword point "window"), work: initialize : function(options) { window.___gcfg = {

Sending files and directories using scp -

i want send following files computer remote computer using scp . directory1 file1 file2 directory2 file3 file4 ... how can send file1 , file2 , etc. such saved same directories on remote computer on computer (e.g. directory1 , directory2 created on remote computer , directory2 contains file3 , file4 )? copy directory "foo" local host remote host's directory "bar" scp -r foo your_username@remotehost.edu:/some/remote/directory/bar the -r tells copy recursively.

python - Storing logical conditions in a dictionary and passing them to if statements -

i have dictionary of logical conditions, i.e. == 1, need use in if statement evaluation. may not possible, wanted find out sure. sample code: z = {'var1':['a == 1'], 'var2':['b == 3'] } = 6 b = 20 #if use dictionary value in if statement this: if z['var1']: print 'true' else: print 'false' #it evaluate true. want statement #translate following form: if == 1: print 'true' else: print 'false' i have been searching various permutations on if statements, list comprehensions , string manipulation, haven't found results matching problem. if not possible, i'd know. if there better approach, i'd know well. in advance answers. you trying store expression, possible use built-in eval() function (you can use exec if want play around statements). >>> = 6 >>> b = 3 >>> z = { 'var1':eval('a == 1'), 'v

internet explorer - Detect when a web page is loaded without using sleep -

i creating vb script on windows opens site in ie. want: detect when web page loaded , display message. achieved using sleep ( wscript.sleep ) approx. seconds when site gets loaded. however, site pops user name, password in midway. when user enter credentials, finishes loading page. don't want use "sleep" approx seconds, instead exact function or way detect page got loaded. checked on line , tried using do while loop, onload , onclick functions, nothing works. simplify, if write script open site yahoo , detect, display message "hi" when page loaded: doesn't work without using sleep ( wscript.sleep ). try conventional method: set objie = createobject("internetexplorer.application") objie.visible = true objie.navigate "https://www.yahoo.com/" while objie.readystate <> 4 wscript.sleep 10 loop ' code here ' ... upd: 1 should check errors: set objie = createobject("internetexplorer.application")

php - Block user not listed in vhost -

i using vhosts file in apache server , have hundreds of domains pointing each 1 one documentroot folder. the problem when user comes server domain not listed in vhosts apache treat first entry in vhosts default. not that. block user, not display page. how can that? i believe want: <virtualhost _default_:*> documentroot /www/default //or ever </virtualhost>

python - how to read and and untar tar.gz files in IPython -

i tried %%sh tar xvf filename.tar.gz but didn't work. how read tar.gz files in ipython. thanks i can't understand why want python (and specially ipython), it's ok... for put command system python use subprocess: from subprocess import call # first param must command, , options, # call(["tar", "-xzf", "filename.tar.gz"]) and must work not on ipython, in every python program.

javascript - How to show an alert if all checkboxes aren't checked? -

i want alert if check-box not checked (- working ) and alert if all check-box not checked ( need in ) checkbox : <input type="checkbox" value="1" id="data" name="data[]"> <input type="checkbox" value="2" id="data" name="data[]"> <input type="checkbox" value="3" id="data" name="data[]"> button : <input name=\"submitclose\" type=\"submit\" value=\"close\" id=\"submitclose\"> below jquery : echo "<script> jquery(function($) { $(\"input[id='submitclose']\").click(function() { var count_checked = $(\"[id='data']:checked\").length; if (count_checked == 0) { alert(\"please select packet(s) close.\"); return false; } else{

Android convert/compile C++ as Neon -

i writing simple android program using c++ of jni , opencv. input image stored mat. instead of using opencv's normalize function, wish write own normalize function in c++. know, there support neon. however, looking @ helloneon sample in ndk folder, realised code written in neon instrinsics. question: there way directly compile c++ code neon code? i.e. wish avoid writing function in neon intrinsics. thank you. largely depends on compiler. both gcc , clang support "automatic vectorizing" in recent versions, quality of generated code variable - depending on actual source code. always, compiler firstly responsible generating correct code, secondly generate fast/efficient code. if in doubt, go "safe" option. it should, however, work use -mfpu=neon -ftree-vectorize . i expect need "massage" code make vectorize well, - @ least that's experience on x86, compiler attempt build sse instructions when vectorizing. succeeds in simple cases,

r - Subsetting a list of data frame with multiple criteria -

i have large dateset multiple data forest inventory. data frame contains species found in each plot. , data organized site. > str(mm,max.level=2) list of 50 $ :'data.frame': 2944 obs. of 18 variables: ..$ plot : int [1:2944] 2 3 3 3 3 4 4 4 5 5 ... ..$ cla : factor w/ 2 levels "a","n": 1 1 1 1 1 1 1 1 1 1 ... ..$ subclase : factor w/ 7 levels "1","3c","3e",..: 5 2 3 2 3 2 3 3 1 1 ... ..$ posesp : int [1:2944] 1 1 1 2 2 1 1 2 1 2 ... ..$ especie : int [1:2944] 28 72 72 41 44 28 43 28 28 43 ... ..$ ocupa : int [1:2944] 10 6 7 3 2 9 5 4 5 5 ... ..$ estado : int [1:2944] 3 4 4 4 4 4 2 2 1 2 ... ..$ fpmasa : int [1:2944] 1 4 4 4 4 2 4 2 1 4 ... ..$ edad : int [1:2944] 14 na na na na 35 na 5 2 na ... ..$ finfor : int [1:2944] 8 na na na na 7 na 5 1 na ... ..$ fiabil : int [1:2944] 4 na na na na 4 na 3 4 na ... ..

php - MemcachePool::get(): Server localhost (tcp 11211, udp 0) failed with: Network timeout -

i have been working memcache , php long time , great have been getting error after every 10 15 minutes. memcachepool::get(): server localhost (tcp 11211, udp 0) failed with: network timeout i thought might due firewall or turned of firewall yet didn't stop giving message. after every error have restart memcache. and it's memcache not d on windows 7 machine php 5.4 msvc9 ts version. can not understand network timeout issue. can done solve this. currently, have 1 local machine windows 7 cannot make cluster of memcache or install memcache(d). unsure if memcache daemon or client issue.

php headers doesn't downloads -

i trying make "force download" via php, strange symbols. i tried add header ("application/typeofmyfile") , header ("content-disposition")... , many others many other post here, nothing i've got this: $f_location = "path/myfile.nl2pkg"; $f_name = "myfile.nl2pkg"; header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=".$f_name); //here tried basename($f_name) nothing header("content-length: ".filesize($f_location)); header("content-transfer-encoding: binary"); i'm doing because when user clicks on "download" button, ajax send him page force download, put data in db , refresh main page. it's first time working on headers, , read, don't know if i'm doing wrong. your headers code seems fine. problem seems somewhere else. to debug code use headers_sent determine if headers have been sent. can use

python - Starting OPEN CL - How to bring a GPU card to its maximum? -

i new gpu computing , need advice , since seems open cl becomes new industry standard move on it, instead of cuda. so used python , multiprocessing fantastic , simple tool. want expand processing capacity gpu power. far have 1 function needs calculated. so far calling function numbers calculated , result after 10 seconds. how can open cl , best tool program open cl under python ? it possible use decorator, send function gpu card , calculate in light speed ? if possible want sent function several thousand times gpu parallel processing 100% calculation power ? how can , open cl right tool of doing ? any advice or demo code appreciated. regards frank the popular method of using opencl python pyopencl . pyopencl full wrapper around opencl api, provides every piece of opencl functionality within python, along nice pythonic simplifications. it's not quite easy adding decorator function, it's still pretty straightforward , running it. there's set of docume

reporting services - Visual Studio 2008 setup for SSRS development on AX 2009 -

Image
my problem didn't find how develop outside production environment, mean when deploy dynamics ax reporting projects, find them in ax production environment, there way specify deployment target (dev, test or other)? tried add /axconfig switch visual studio shortcut path ax config files different environment have error message visual studio: invalid command line. unknown switch : axconfig. i'm using ax 2009 no sp1, sql server 2005, visual studio 2008, reports working fine in visual studio , ax. just change in project properties change these settings

Is there a way I can get appium to start within the code? -

i trying launch appium server within code writing using java. tried following command , doesn't work: appium = runtime.getruntime().exec("/usr/local/bin/appium"); in order start appium on os x should include 'open' , add '.app' @ end. for example: appium = runtime.getruntime().exec("open /applications/appium.app");

Grizzly 2.3.11 + Atmosphere 2.1.3: getServletPath() returns null -

hellow fellow developers! i'm testing atmosphere 2.1.3 using grizzly 2.3.11. i've created managedservice(path="/chat") , error: 'no atmospherehandler maps request /chat status 500 message server error'. if change path managedservice(path="/") works. i've debugged bit , seems org.atmosphere.cpr.atmosphererequest.getservletpath() returns null, default path "/" used , that's cause makes test work using managedservice(path="/") . well, i'll appreciate because need use path kinda managedservice(path="/chat"). in advance! note: post related atmosphere + grizzly: no atmospherehandler maps request /chat status 500 message server error pd: main test class: package com.dweb.atmosphere.grizzly; import java.io.ioexception; import org.atmosphere.container.grizzly2cometsupport; import org.atmosphere.cpr.atmosphereservlet; import org.glassfish.grizzly.comet.cometaddon; import org.glassfish.grizzly.http.serve

html - Mouseover image pulls other images down -

i'm having problem images of website i'm making. i've been trying different ways solve , best found far. still, it's not need. have 8 buttons , need second 1 replaced bigger image. thing is, pulls others down, , wanted on them. there way it? did in coding: <a href="index.html"> <input type="image" src="hp-homebutton.png" alt="submit" style="position: relative;" value="home button"/> </a> <p> <img src="hp-monthsbutton.png" onmouseover="this.src='hp-months.png'" onmouseout="this.src='hp-monthsbutton.png'" style="position: relative;"/> <p> <img src="hp-forumbutton.png" style="position: relative;"/> <p> <img src="hp-newsbutton.png" style="position: relative;"/> <p> <img src="hp-contactbutton.png" style="position: relative;"/> <