Posts

Showing posts from January, 2015

daemon - bash script to monitor myself -

i need develop shell script not started if instance of them self running. if build test.sh monitors need know if running , abort, otherwise (if not running) can run #!/bin/bash loop() { while [ 1 ]; echo "run"; #-- (... omissis ...) sleep 30 done } daemon="`/bin/basename $0`" pidlist=`/usr/bin/pgrep $daemon | grep -v $$` echo "1:[ $pidlist ]" pidlist=$(/usr/bin/pgrep $daemon | grep -v $$) echo "2:[ $pidlist ]" echo "3:[ `/usr/bin/pgrep $daemon | grep -v $$` ]" echo "4:[" /usr/bin/pgrep $daemon | grep -v $$ echo "]" if [ -z "$pidlist" ]; loop & else echo "process $daemon running pid [ $pidlist ]" fi exit 0; when run above script first time (no previous instances running) output: 1:[ 20341 ] 2:[ 20344 ] 3:[ 20347 ] 4:[ ] i cannot understand why 4th attempt not return (as expected). what's wrong in script? have

jquery - check for changes in form via Ajax -

i've got little auto-suggest jquery script. when start typing looks database matches via ajax post. when click on result input field value wich picked. that works want check if value of input has changed value. what tried $("input").change(function(){ alert('change'); }); but doesnt work. is there way check if form input field has changed value ajax post? .changed not function in jquery. here function .change use that: $("input").change(function(){ alert('change'); }); use following function instead of above: $(document).ready(function(){ $(".ui-autocomplete").click(function(){ alert("changed input field."); }); }); i using class ui-autocomplete told using jquery autocomplete. can detect name of class or id using firebug.

c# - Switching form EF4 to EF5 switching new to create -

previously when using ef4 objects being added database followed (possibly incorrectly) pattern poll opoll = new poll(); opoll.name = "my special poll question"; context.addtopolls(opoll); context.savechanges(); however when making switch ef5 need make use of create object instead. poll opoll = context.poll.create(); opoll.name = "my special poll question"; context.addtopoll(opoll); context.savechanges(); since have 3,000 pages of code, rather not find new keywords nor go through hand hand. there nice elegant way (by tool or otherwise) update pattern new pattern ef5? if know names of entities, global regex replace: say had poll, vote , person types, replace: (poll|vote|person) (.+) = new .+\(\); with $1 $2 = context\.$1\.create\(\); that'd turn poll opoll = new poll(); poll opoll = context.poll.create(); to add entity types want replace, edit first part of regex.

php - Display div content of iframe on top of the screen -

i have created page have 1 button. on clicking of button, showing fancybox popup iframe . iframe has 1 inputbox . while inputting text, suggests name list auto-complete option. due fixed size of iframe popup, suggestion list not visible after fixed height , width. auto populating suggestions inherited in iframe . so of auto suggested list not visible. it's hidden inside iframe . want pop outside of iframe . please if has solved these types of issue. thanks in advance. if have control on iframe , can give greater z-index value auto-compete list iframe fancy box. or add style overflow:scroll; container holds iframe , set iframe height max example : <html> <body> <div style="width:400px; height:400px; overflow:scroll"> <iframe src="http://www.example.com/" style="width:1000; height:1300"></iframe> </div> </body> </html>

java - Issue with JAVA_HOME -

i trying run sonar runner, have bat file in project directory , when navigate via command promptt , try , run error message saying error: java_home exists not point valid java home folder. no "\bin\java.exe" file can found there. if echo path of java_home pointing $c:\program files (x86)\java\jdk1.7.0_15\bin is path correct or need changed? thanks it should point java root folder, in case c:\program files (x86)\java\jdk1.7.0_15

jquery - PHP: Unable to get the json output into my javascript page as a variable value -

this question has answer here: php : how pass database value javascript/jquery function 3 answers i have output in format var sampletags = ['c++', 'scala']; my javascript function is: <script> $(document).ready(function(){ $(function(){ var sampletags; $.ajax({ url:"<?php echo base_url('ajax_get_tags/gettags'); ?>" }).done(function(data) { if (data) { sampletags = data; } }); ...................... ....................... $(function(){ var sampletags = <?php echo json_encode($query) ?>; my php controller function gettags(){ $json_array=$this->tagsmodel->get_all_tags(); echo json_encode($json_array); } my model //-----

c# - How to return JSon object -

i using jquery plugin need json object following structure(i retrieving values database): { results: [ { id: "1", value: "abc", info: "abc" }, { id: "2", value: "jkl", info: "jkl" }, { id: "3", value: "xyz", info: "xyz" } ] } here class: public class results { int _id; string _value; string _info; public int id { { return _id; } set { _id = value; } } public string value { { return _value; } set { _value = value; } } public string info { { return _info; } set { _info = value; } } } this way serialize it: results result = new results(); result.id = 1; result.value = "abc"; result.info = "abc";

java - Custom Authentication Provider on Spring Security 2 userDetailsService issue -

i had spring security 2.0.5 on webapp, using default provider. requirements have changed , need customauthenticationprovider in order change authentication way. this authenticationprovider public class customauthenticationprovider implements authenticationprovider { @autowired private paramsproperties paramsproperties; @suppresswarnings("unchecked") public authentication authenticate(authentication authentication) throws authenticationexception { //check username , passwd string user = (string) authentication.getprincipal(); string pass = (string) authentication.getcredentials(); if(stringutils.isblank(user) || stringutils.isblank(pass) ){ throw new badcredentialsexception("incorrect username/password"); } //create sso singlesignonservice service = new singlesignonservice(paramsproperties.getservicesserver()); try { //check logged service.setusername(authentication.getname()); service.set

Can I ignore the key word DEFINED in cmake? -

i have simple question related camke keyword defined. not know in condition keyword necessary , in condition keyword can ignored. following example given illustrate question: cmake_minimum_required(version 2.8) project(test) if (not abc) set(abc "hello abc") endif() message(${abc}) if (abc) message(${abc}) endif() if (defined abc) message(${abc}) endif() as can see example, if (variable) , if (defined variable) function same. therefore, question arises: defined necessary? idea appreciated. i notice variable may defined value can off, , in case variable still defined not on, means if(variable) false while if(defined variable) still true. set(initial_pass off) if (defined initial_pass) message(${initial_pass}) endif() if (initial_pass) message(${initial_pass}) endif() set(initial_pass on) if (defined initial_pass) message(${initial_pass}) endif() if (initial_pass) message(${initial_pass}) endif()

java - Quicksort Linked List Pivot Last Element -

i'm trying implement quicksort sorting cyclic linked list! there doublylinkedlist contains listelements . the listelement has element first, has reference predecessor , successor. e.g. doublelinkyedlist in contains listelement first. first can referenced first.prev oder first.next. the last element in linked list has reference first element e.g. last = first.prev ; my problem is, keep getting error, don't know 1 precisely, cause it's never ending loop , terminal not printing precise exception. my code of class sorter.java implement sorting operation: package ads1ss13.pa; public class sorter { public doublylinkedlist quicksort(doublylinkedlist in, int numofelements) { system.out.println("starte sort() in quicksort()"); in = sort(in, in.first.getid(), in.first.prev.getid()); return in; } public doublylinkedlist sort(doublylinkedlist in, int l, int r) { system.out.println("sort()"); l = in.first.getid();

oracle - I want to apply a modification to the path environement system variable without rebooting or restarting the cmd owing to c# -

i using c# dll using installshield add path of oracle path environement system variable able connect oracle database owing instant client. whan run installer first time doesn't succeed make change path variable. succeed on second try because path changed first run. conclusion oracle database provider not view change directly after modifying code. i want way detect changes path variable without need try installation second time. var ancientpath = environment.getenvironmentvariable("path", environmentvariabletarget.machine); environment.setenvironmentvariable("path", ancientpath + ";" + tmp, environmentvariabletarget.machine); what you're trying explicitly not do-able. process can modify it's own environment, , can spawn processes different environments, no process can change environment of process. when launch new process after first installation, should see updated path. if want existing process use new environment vari

paypal payment method not coming up in checkout drupal ubercart -

Image
i using drupal 7 ubercart. using paypal express checkout payment method. i able see "checkout paypal button" in view cart page. but when click checkout button, takes me order submission page. here cannot see paypal in payment method section. i don't know options check. not have other payment method. need change code in module? should do? also able place order in system not going paypal on order submit. if want pay paypal select payment option , , option " paypal website payments standard " , because checkout paypal in ubercart product not working me. have used paypal website payments standard , works fine me.

javascript - JQuery Carousel multiple instances on the same page -

i trying use third-party jquery carousel plugin in project @ work (don't know plugin though). problem when use multiple instances of same plugin on same page 1 of instances updates. think issue how instances setup. have constructed jsfiddle @ here . the carousel attached .carousel class , instances initiated method shown below: // enable carousel $.each($('.carousel'), function (i) { $(this).carousel(this.id); }); unlike in local code, in jsfiddle 1 of carousels works. appreciated. firstly there error when js runs. if in browser dev tools of choice should see typeerror: properties.slider.swipe not function once commented out js run correctly if click of next , previous buttons bottom slider run. because use same instance of var properties . i suggest looking @ creating jquery widget existing code, straight forward do. doing can have several instances of same widget running on page together. coding first jquery ui plugin

html - Why can't I position this <a> over the following div? -

i'm having issues positioning. there container div contains div , tag inside (both separately) need tag on second div, doesn't seem work when use z-index: here jsfiddle http://jsfiddle.net/7yqhu/ and code .container{ width: 100%; background: yellow; opacity: 0.4; height: 130px; position:absolute; } .inner { position: absolute; background: red; opacity: 0.5; height: 100px; width: 100%; margin: 15px 0; } .inner-link { margin:15px auto; background:blue; display:block; width:100px; height: 100px; z-index: 99!important; } create stacking context <a> giving position value other default, static .inner-link { position: relative; } http://jsfiddle.net/adrift/7yqhu/1/

c# - What's a general way to provide an emergency mode for a wcf service -

i have ipad using wcf service. the wcf service loading background data every 10 seconds. background loading process fail , data , service methods become dysfunctional. how can provide 'kill switch' take every mobile service method down , provide brief message (or send mail) automatically when being called? is possible implement in service setting or should else? if find wcf service in bad state, can call httpruntime.unloadappdomain . see recycling wcf web service on iis

Word deleting tabe column via vba macros gives an error -

i want copy data excel word table , delete columns table. can copy data table, when delete column gives error: cannot access individual columns in collection because table has mixed cell widths. my code: public tbl1 table sub callexcel() dim objexcel new excel.application dim exwb excel.workbook set exwb = objexcel.workbooks.open("c:\users\ismayilov\desktop\test") roomnumber = inputbox("enter room number copy word:", "room number") activedocument.formfields("text1").result = roomnumber exwb.sheets("sheet1").range("$a:$h").autofilter field:=8, criteria1:=roomnumber dim rvis range, rdata range exwb.sheets("sheet1").range("$a1:$h600").copy set tbl1 = activedocument.tables.add _ (range:=selection.range, numrows:=1, numcolumns:=8) tbl1.range.paste tbl1.columns(1).delete exwb.close savechanges:=true set exwb = nothing set tbl1 = nothing end sub try change line: tbl1.range.paste i

excel - Extracting XML attribute using VBA -

i'm not developer , have limited xml knowledge i've learned past 3-4 days researching on web. apologies in advance basic level of question. i'm trying wrap 1 time task. i have vba excel knowledge , i'm trying use vba extract sic code attribute given company's page on sec filing website. example, site walmart http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&cik=0000104169&owner=exclude&count=40&hidefilings=0 in blue bar @ top can see 'sic: 5331' it's 5331 i'm trying return vba variable can populate spreadsheet. when right click in ie , clich view source part of page relevant reads in xml as: <div id="contentdiv"> <!-- start filer div --> <div style="margin: 15px 0 10px 0; padding: 3px; overflow: hidden; background-color: #bcd6f8;"> <div class="mailer">mailing address <span class="maileraddress">702 southwest 8th street</span>

PHP - String Logic Parsing - "X AND Y OR Z" -

i take and/or logic query query string of unknown length: $logic = 'elephants , tigers or dolphins , apes or monkeys , humans , gorillas , and 133322 or 2'; and parse array, assume like: $parsed_to_or = array( array('elephants', 'tigers'), array('dolphins', 'apes'), array('monkeys', 'humans', 'gorillas', '133322'), array('2') ); this have far: $logic_e = preg_split('/\s+/', $logic); $or_segments = array(); $and_group = array(); foreach($logic_e $fragment) { if (preg_match('/^(and|&&)$/i', $fragment)) { continue; } elseif (preg_match('/^(or|\\|\\|)$/i', $fragment)) { if (count($and_group)>0) { $or_segments[] = $and_group; $and_group = array(); } continue; } else { $and_group[] = $fragment; continue; } } if (count($and_group)>0) { $or_segments[] = $and_group; $and_group = array(); } any better ways tac

xslt - How to locate XML data between nodes by XSL -

i new xml , xsl, sorry ask silly question. how locate data 'a' using xsl. <a> <b>b</b> <c>c</c> <d>d</d> <e>e</e> </a> i have searched answers , learned locate b, c, d, e using xpath. when comes data a, failed. tried use path displayed data including b c d e. help. several possibilities: /a/text() this selects child text nodes of <a> /a/text()[not(normalize-space() = '')] this selects non-empty text children of <a> /a/text()[3] this selects '\n a\n ' node example specifically (note there whitespace-only text nodes count well!) /a/c/following-sibling::text()[1] this selects '\n a\n' node example specifically //text()[following-sibling::* or preceding-sibling::*] this selects text nodes have element siblings (i.e. mixed content) depends on how @ it.

c# - How to avoid two different user submitting same request for the same person at the same time -

how avoid 2 different users submitting same request same person @ same time? helpdesk asp.net webforms app sql server backend. i have transaction block in stored procedure insert request table. but still when colleague , tested scenario in milliseconds our requests went through choosing same option validate duplicate in stored procedure. first, need define logic comparing if 2 requests same. from information gave us, variables can see (a) person (b) time. example, 2 requests considered same, if (a) belong same person id , (b) recorded within x minutes of each other. however above rule generic , might result in loosing valid requests. suggest following: investigate why more 1 user can submit same request. frequency of such cases? reasons happens? knowledge might arrive @ different , better solution. check further variables add rule e.g. request type, application. if frequency of duplicate requests low, consider using generic rule , whenever detect duplicate, sh

javascript - Dynamically update Grunt config fields -

i have few projects in separate directories , want build them in same way. want define project name task (as param). grunt tasks use project path root path. have several subfolders , not want update manually want update project. there chance that? grunt.initconfig({ paths : { project : null, projectstylesheets : '<%= paths.project %>/stylesheets', // ... } }); grunt.registertask('server', function(project) { // -> project = 'some_name' var paths = grunt.config.get('paths'); paths.project = project; grunt.config.set('paths', paths); // -> { project: 'some_name', projectassets: 'stylesheets' } }); i thinking using js functions outside config not sure best practice. try use registermultitask - http://gruntjs.com/api/grunt.task#grunt.task.registermultitask grunt.initconfig({ projectname1 : { projectstylesheets: 'path_to_stylesheets1', }, projectna

hadoop - How to confirm hive mode of running in CDH 4.2? - local or remote -

in cluster, uses cdh 4.2, see 2 different hive-site.xml files. 1. hive-site.xml file in hive conf directory. 2. hive-site.xml file can view webui of cdh 4.2 my problem both these files have different content in terms of hive execution mode. hive-site.xml file in conf directory lists mode of execution "remote". has "false" value of parameter - hive.metastore.local , defines parameter - >hive.metastore.uris - thrift://<machine_name>:9083 but hive-site.xml file can view using webui, lists local mode true , sets following parameters. <property> <name>javax.jdo.option.connectionurl</name> <value>jdbc:postgresql://<machine_name>:7432/hive</value> </property> <property> <name>javax.jdo.option.connectiondrivername</name> <value>org.postgresql.driver</value> </property> i think running in local mode, because webui states hive metastore running in hive

ruby - Rails uninitialized constant in initializers -

i've taken on working rails 3 app offshore supplier , rails console failing @ line: settings.defaults[:processing_fee] = '0.99' in file config/initializers/settings.rb i've compared file in git blame , matches. i've removed contents of file , runs doesn't line. reading on i've made filename , constant singular. following so post created file in config/application_settings.rb. constant not found in console. moving /initializers yielded on rails console /users/sam/apps/tickat/config/initializers/application_settings.rb:1:in `<top (required)>': uninitialized constant settings (nameerror) from content: settings[:processing_fee] = '0.99' it appears environment not accepting constants here. first noticed pushing heroku , can replicate error in development in console. i've asked around , stuck. i'm sure it's goofed on, sam it might forgot commit file in repo of application. if case, , can't file auth

javascript - How to handle adding a close link within an UL/LI item -

i've got code so: <ul id="ulpersonal"> <li class="break etime"> <p>manage time card.</p> <div id="detime"> content </div> </li> </ul> the div appears once hove on li item, in jquery: $('#detime').hide(); //initially hide div... //when user hovers show div $(".etime").hover(function () { $('#detime').fadein('slow'); }); so page shows li item, hove on , div shown. tried when "un-hover" off li div disappears, ux not friendly...to flickering. so decided add close hyperlink...but if add within li item , click on it, div reappears still "hovering" inside li. how can handle can allow user close div? i've got lot of seperate ul items this, dont want add close link after ul, , cannot add href tag outside of li, plain wrong. try use .mouseenter() instead of

git hook to reload database on checkout when schema changes -

our database schema generated programmatically files in our /models directory. i'd figure out git hook can use when doing checkout or merge, compare sha1 of /models directory, , if not same had before, re-initialize test database , reload our fixtures. is possible lookup sha1 of /models directory, save in variable, , compare results after completing checkout/merge? thanks in advance pointers. for rails, guard-migrate decent solution operates @ different level git. monitors db/schema.rb changes, , updates database if necessary. sure turn off while working on writing migrations.

javascript - $(document).ready don't loading in IE -

i have url gives me various parameters need. i've managed results, reason doesn't show results @ in ie , i'm not sure why. works in every other browser, not ie. i've checked console , there's no errors @ all, i've used jslint.com check js code , that's fine too. i've removed else in file has this. this i'm using results. have separate js file contains this: function call(url, parameters, callback) { "use strict"; $.ajax({ type: 'post', url: url, data: parameters, success: function(data) { callback(data); } } ); } function loadjackpots() { "use strict"; call("https://www.domain.com/passkey", { jl: 0 }, function(data) { var dividentifier, obj = eval('(' + data + ')'); $.each(obj.jl, function() { dividentifier = ""; switch (this.gameid) { case 2: dividentifier = "#snap"; break; case 5: dividentifier = "#dominos"; break; case 1000: dividentifier = "#chess1

Can hadoop take input from multiple directories and files -

as set fileinputformat hadoop input. arg[0]+"/*/*/*" said match no files. what want read multiple files as: directory1 ---directory11 ---directory111 --f1.txt --f2.txt ---directory12 directory2 ---directory21 is possible in hadoop? thanks! you can take input multiple directories , files using ***** operator. it's because "arg[0]" argument isn't correct , therefore it's not finding files. as alternative, can use inputformat.addinputpath or if need separate formats or mappers multipleinputs class can used. example of basic adding path fileinputformat.addinputpath(job, myinputpath); here example of multipleinputs multipleinputs.addinputpath(job, inputpath1, textinputformat.class, mymapper.class); multipleinputs.addinputpath(job, inputpath2, textinputformat.class, myothermapper.class); this other question similar , has answers, hadoop reduce multiple input formats .

c# - How to get text that has no tag with htmlAgilityPack -

i have html file below <div> <div style="margin-left:0.5em;"> <div class="tiny" style="margin-bottom:0.5em;"> <b><span class="h3color tiny">this review from: </span>you meet</b> </div> if know ron kaufman ... <br /><br />whether you're ceo.... <br /><br />written in distinctive, ... <br /><br />my advice? don't 1 copy <div style="padding-top: 10px; clear: both; width: 100%;"></div> </div> <div style="margin-left:0.5em;"> <div class="tiny" style="margin-bottom:0.5em;"> <b><span class="h3color tiny">this review from: </span>my review</b> </div> became fan of ron kaufman after reading earlier book of years ago... <div style="padding-top: 10px; clear: both; width: 100%;"></div> </div&

How do I check for duplicate rows and do calculate on that rows in excel file? -

i have 1 excel file having data following cusip quantity date price af0 500000 5/6/2013 1 ae4 400000 5/6/2013 1.0825 ae4 500 5/6/2013 1 i need check column cusip , date if i'm having duplicate cusip same date need following calculation. 1.need add quantity both of them instead of showing duplicate records need show 1 record( sum of quantity). 2.need calculation on price following newprice = ((400000 * 1.0825) + (500 * 1.00))/(400000 + 500) = 1.08148 for example in using above data need show output cusip quantity date price af0 500000 5/6/2013 1 ae4 400500 5/6/2013 1.082397004 how achieve in excel file using lookup or else ? okay, after quite research (interesting question way!), came this: =if(countif($a$2:a2,a2)>1,"",sumif(a:a,a2,b:b)) =if(countif($a$2:a2,a2)>1,"",sumproduct(--(a:a=a2),b:b,d:d)/sumif(a:a,a2,b:b)) put these

javascript - Karma AngularJs Cancel/mock Timeout E2E -

in angular have service object animates page transitions. problem animation making karma/testacular e2e tests run slowly. code looks following: .factory('animator', function($timeout, $location, $rootscope){ return { animate: function(animationvariable, animationtype, callback){ $rootscope[animationvariable] = animationtype + " animated"; $timeout( function(){ $rootscope[animationvariable] = ""; if(callback) { callback() } },1300) ; } } }) how can mock out animation functionality skipped when running e2e tests in karma. karma able start, unable execute tests if of source files use angular $timeout service. if wish still test application, need remove references $timeout service or write own. source: vojta jína

javascript - Trying to remove element from DOM using jQuery -

i have dom element can accessed javascript using rectangle=document.getelementsbytagname("rectangle")[index]; i trying remove dom, using jquery, follows. element=jquery('rectangle').get(index); element.remove(); however firebug returns error typeerror: element.remove not function $.get returns standard domelement. create jquery object , then $.remove work. element=jquery(jquery('rectangle').get(index)); element.remove(); better yet, in 1 step , use $.eq instead of $.get : element=jquery('rectangle').eq(index); element.remove();

floating point - Data type mismatch in fortran -

i've written rudimentary algorithm in fortran 95 calculate gradient of function (an example of prescribed in code) using central differences augmented procedure known richardson extrapolation. function f(n,x) ! scalar multivariable function differentiated integer :: n real(kind = kind(1d0)) :: x(n), f f = x(1)**5.d0 + cos(x(2)) + log(x(3)) - sqrt(x(4)) end function f !=====! !=====! !=====! program gradient !==============================================================================! ! calculates gradient of scalar function f @ x=0using finite ! ! difference approximation, low order richardson extrapolation. ! !==============================================================================! parameter (n = 4, m = 25) real(kind = kind(1d0)) :: x(n), xhup(n), xhdown(n), d(m), r(m), dfdxi, h0, h, gradf(n) h0 = 1.d0 x = 3.d0 ! loop through each component of vector x , calculate appropriate ! derivative = 1,n ! reset step size h = h0 ! carry out m suc

android - How to make spinner in dialog mode? -

i have button in application , when click on button, opens spinner, spinner in dropdown mode , need make in dialog mode. api 11 , higher, there simple code trick: spinner s1 = new spinner(this, spinner.mode_dialog); but need use code api 7 , higher. me, please? this how did: here, questions string[]; dialoginterface.onclicklistener questiondialoglistener = new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface arg0, int arg1) { // implement coding getting selected item. arg0.dismiss(); } }; alertdialog.builder builder = new alertdialog.builder(this); builder.settitle("select question:"); builder.setitems(questions, questiondialoglistener); alertdialog dialog = builder.create(); dialog.show(); }

ios - Asana server returning error code 500 on OAuth 2 request with GTMOAuth 2 -

i'm using gtmoauth-2 library implement oauth 2 authorization code grant flow asana api, consistently getting server error 500. gtmhttpfetcher log follows (selectively redacted): fetch tokens app.asana.com 2013-05-08 16:46:58 +0000 request: post https://app.asana.com/-/oauth_authorize request headers: content-type: application/x-www-form-urlencoded user-agent: gtm-oauth2 <user-agent> request body: (199 bytes) client_id=<client-id>&client_secret=_snip_&code=<client-secret>&grant_type=authorization_code&redirect_uri=http%3a%2f%2fwww.google.com%2foauthcallback response: status 500 response headers: cache-control: no-store content-length: 303 content-type: text/html; charset=utf-8 date: wed, 08 may 2013 16:46:56 gmt pragma: no-cache server: nginx set-cookie: <cookie> x-asana-content-string-length: 303 x-asana-preferred-release-revision: 20130508_073846_310cafc985fd5fb43121784b58d5dcd2503ffffe response body: (303 bytes) <html> <h

php - Removing exactly one month from a date -

it seems can't use strotime if need reliable , accurate date manipulation. example, if month has 31 days, appears strtotime minuses 30 days, not whole month. so, example, if $event["enddate"] equal "2013-10-31 00:00:01", following code: echo date("y/n/j", strtotime('-1 month', strtotime($event["enddate"])); ouputs: 2013/10/1 instead of 2013/09/30 . question: how know how not it, there another, more accurate, way make php subtract (or add) whole month, , not 30 days? the main issue 2013/09/31 not exist better approach use first day or last day of previous month. $date = new datetime("2013-10-31 00:00:01"); $date->modify("last day last month"); echo $date->format("y/n/j"); // 2013/9/30 when date 2013-10-15 $date = new datetime("2013-10-15 00:00:01"); $day = $date->format("d"); $year = $date->format("y"); $date->modify("las

sockets - C# Application Lags when Communicating over TCP -

i making simple communication between client application , server application. server: tcplistener tcp = new tcplistener(ipaddress.parse("192.168.1.66"),9000); tcp.start(); textbox.text += "start listening \r\n"; //1 socket s = tcp.acceptsocket(); textbox.text += "client has connected \r\n"; the lagging occurs following way, string number 1 not show until client has connected, application freezes, can't drag window. i tried adding delay: textbox.text += "start listening \r\n"; system.threading.thread.sleep(1000); socket s = tcp.acceptsocket(); textbox.text += "client has connected \r\n"; still won't allow first message printed , search sockets. application keeps on freezing until client connected. are doing listening on thread? if not locking gui updating. void startlistener() { system.threading.thread listenerthread = new system.threading.thread(listenerthread)); listenerthread.isbackground =

perl - Testing an XS module that uses Dist::Zilla -

i'm working on perl module has lot of xs code , uses dist::zilla manage packaging. what's best way test things efficiently? know dzil test , that's pretty slow because full build/compile/test cycle every time it's invoked. it nice update parts need updating since last test, , able run t/*.t test scripts rather of them. have solution like? i have, in past, taken build.pl/makefile.pl generated dzil , dropped source repository "makefile_dev.pl" (or "build_dev.pl"), added manifest.skip (or dzil-based, generated equivalent) , used during development.

c# - Can't Add RegularExpressionValidator to Panel -

i'm having issue programmatically adding regularexpressionvalidator container control (panel, placeholder, etc.). here code: // path of file on server string page = page.request.filepath; int managementcompanyid = convert.toint32(session["managementcompanyid_addresident"].tostring().trim()); // field validation details collection<exportfieldvalidation> details = validationbl.getvalidationdetails(managementcompanyid, page); contentplaceholder body = page.form.findcontrol("contentbody") contentplaceholder; foreach (exportfieldvalidation detailitem in details) { // check if control exists on page textbox control = body.findcontrol(detailitem.fieldtovalidate) textbox; if (control != null) { regularexpressionvalidator regex = new regularexpressionvalidator() { controltovalidate = control.uniqueid.tostring(), id = detailitem.validatorfieldname, validationexpression = detailitem.regula

jquery - mouseenter wait a bit then display the div item (in seconds?) -

i'm trying accomplish user hovers on item , jquery takes on , displays item (but after few seconds). i've got following html listed: <ul id="ulpersonal"> <li class="break etime"> <p>manage time card.</p> <div id="detime"> content </div> </li> </ul> the li item visible, , once mouseenter show div detime shown (here jquery): $('#detime').hide(); $(".etime").mouseenter(function () { $('#detime').fadein('slow'); }); this works great..when user hovers on li item div fades in. however, want wait 2-3 seconds before happens. meaning allow user hover on li, should wait , open if still hovering more 2 seconds. if "un-hover" before 2 seconds div should never appear. i hope makes sense. allow hover display div once 2 seconds up. otherwise dont display it. i've g

asp.net mvc - Is a View Model the only way to annotate your model if you're using the EF model generated classes? -

if you're not coding poco's , you're forced use model generated entity framework or 1 of extensions, there way annotate model other than: 1) using view model and 2) annotating model generated ef, should of course ruled out anyway over-written every time model updated or refreshed database? i not know if understand question, seems need write dataannotatios model autogenerated ef , dataannotations can't lost when update ef. if need see: this post .

ruby on rails - entry returned on first query, empty on second -

i have application allows lawyers , law students answer legal questions. answers can voted up. beside each answer on views/question/show.html.erb, application indicates whether answer has been voted , (a lawyer, or law student). however, it's behaving oddly. currently, on test question, if lawyer votes answer, application not showing upvote, if student votes answer, both student's , lawyer's vote displayed, both displayed student votes. this code in show action of questions controller retrieves answers question, , queries type of votes each answer has. def show @question = question.find(params[:id]) @answers = @question.answers @answers.each |a| @lawyervotes = answervote.where({:answer_id => a.id, :lawyervote => true}).reload puts @lawyervotes.inspect puts "lawyervotes" @studentvotes = answervote.where({:answer_id => a.id, :studentvote => true}).reload @uservotes = answervote.where({:answer_id =

windows - masm assembly how to use getpixel to build a color picker -

i build color picker. have tried code invoke getdc,null mov esi,eax invoke getpixel,esi,400,400 invoke lstrcpy,string ,eax invoke setdlgitemtext,hwin,textbox1,string invoke releasedc,null,esi but returns p»© , things that. how return things 00f0f0f0h you not trying format string number, need pass correct flags , specifier wsprintf. *printf format whatever pass it, , convert string according format specifier , put string address passed lpout . the %s specifier formatting strings. lets wanted display return value of getpixel 8 digit hex number 0x in front of number. .data szfmt db "%#08x", 0 .data? buf db 12 dup (?) .code invoke getdc, null invoke getpixel, eax, 200, 200 invoke wsprintf, offset buf, offset szfmt, eax invoke messagebox, null, offset buf, null, mb_ok instead of calling messagebox , can do: invoke setdlgitemtext, hwin, textbox1, offset buf try , see messagebox displays http://msdn.microsoft

How to speed up simple Fortran OpenMP? -

i have simple fortran program in main component 4-core openmp portion calculates dot product omp_num_threads=4 ... 30 k=1,lines co(k)=0 si(k)=0 co_temp=0 si_temp=0 !$omp parallel private(dotprod,qcur) reduction(+:co_temp,si_temp) 40 i=1,ion_count dotprod=(rx(k)*x(i)+ry(k)*y(i)+rz(k)*z(i))*((2*3.1415926535)/l) co_temp=co_temp+cos(dotprod)*26 !qcur/qavg si_temp=si_temp+sin(dotprod)*26 !qcur/qavg 40 continue !$omp end parallel co(k)=co_temp si(k)=si_temp q(k)= ( co(k),-si(k) ) s(k)= s(k) +( q(k) * conjg(q(k)) ) r(k)=r(k)+q(k) 30 continue i'm not experienced fortran or optimization. i'm using xlf90_r file -qsmp=omp compile. 1/2 speedup when using 4 cores, else using c has gotten perfect 1/4 speedup doing same computation. same amount of time whether omp loop on 30 or 40. time around loop 30 program whole , loop takes 99.x% of time, i'm pretty sure bit bottleneck. egregious slow mistakes i've made in portion sees?

java - Make Listview to Occupy Whole Screen -

Image
i have listview want fill whole screen,there 4 items in listview. leaves empty space below after 4 items filled.you can see in screenshot. leaves blank space. want whole screen covered. i have this: here source code mainactivity.java. public class mainactivity extends activity { listview resultpane; list<taskinfo> list; customadapter adapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); resultpane = (listview) findviewbyid(r.id.mylist); list = new arraylist<taskinfo>(); resources res = getresources(); // resource handle drawable drawable = res.getdrawable(r.drawable.browse_home); list.add(new taskinfo("browse", drawable)); drawable = res.getdrawable(r.drawable.jewelry); list.add(new taskinfo("whats new", drawable)); drawable = res.getdrawable(r.

WordPress Toolbar: NO SHOW for specific users while on index page -

i show toolbar visitors of site, exception of; not logged in users\visitors, while on index page. the following placed in function file works fine displaying toolbar visitors @ times. add_filter( 'show_admin_bar', ' __return_true ' ); so hoping replacing meet added conditions... function show_bar() { if ( ! isset( $show_admin_bar ) ) { if ( ! is_user_logged_in() && is_home() ) { $show_admin_bar = __return_false; } else { $show_admin_bar = __return_true; } } $show_admin_bar = add_filter( 'show_admin_bar', '$show_admin_bar' ); return $show_admin_bar; } i don't think function being fired (no warnings or errors, no toolbar visitors. ). question is, there better way this, if not take function work? thx

Windows Batch Script - File iteration issue -

id read input many files 1 @ time , process input before going next file. files have special name defines order of input. follows: ordersheet_a_b_d. though following code in batch file allow me read them in order specified loops, doesn't anything. can maybe see mistake? have following in .bat file: @echo off %%a in (20, 40, 80) ( %%b in (80, 160) ( /l %%c in (1,1,3) ( /l %%d in (1,1,10) ( /l %%e in (1,1,6) ( /l %%f in (0,1,6) ( if %%e lss %%f ( if exist ordersheet_%%a_%%b_%%d echo " " %%e %%f >> output.txt if exist ordersheet_%%a_%%b_%%d start thesisvelo.exe distancematrix_%%a.txt ordersheet_%%a_%%b_%%d %%c %%d %%e %%f >> output.txt ) ) ) ) ) ) ) the batch file below achieve same process of original code, have minor modifications made code clearer , show names of processed files. please, note don't know code supposed achieve! @echo off setlocal enabledelayedexpansion %%a in (20 40 80) ( %%b in (80 160) ( /l %%c in (1,1,3) (

c++ - Print out vector of strings backwards -

i trying write program takes in user input, store vector of strings, , prints out vector according functions. for function, "display_backwards", supposed display input of user in mirrored-like image. i'm having trouble writing code , it's giving me errors don't understand why this code: void asci_art::display_backwards(vector<string> art) { char swap[100]; cout << "your artwork in mirrored image" << endl; cout << "=============================" <<endl; (unsigned int i=0; < art.size(); i++) { for(int j=0; j < art[i].size(); j++) { swap[j] = art[i].end()-j; art[i].begin()+j = swap[j]; } } for(int k= 0; k < swap.size(); k++) { cout << swap[k]; } cout << endl; } the function written in class the vector, art, has user input. , each element of vector, stores line of string want access string of element , swap letters of string, believe create mi

vb.net - Listbox value pass in store in to variable using for loop -

i have 100 order number in listbox , number part or file name. need search file name using order number list box. example value list box 456789-789464 879746-123456 and file name 456789-789464-2013-11-23456-456.pdf. logic finding file working cannot pass order number list box in variable. m using below code mooor string = "" each item string in listbox1.items(1) mooor &= item & vbcrlf next with loop m getting msg ("unable cast object of type 'system.data.datarowview' type 'system.collections.ienumerable'") your listbox1 bound datatable( or dataview) , items datarowview listbox1.items(1).row row(1) of table. to find selected items need ( wd: how determine items selected in listbox ): for x = 0 listbox1.listcount - 1 if listbox1.selected(x) = true msg = msg &amp; listbox1.list(x) &amp; vbcrlf end if next x