Posts

Showing posts from February, 2011

authorization - Achieving property value assignment control using a generic approach for POCO or plain C# entity classes -

i working on .net application & trying achieve following in c#. let's assume have entity employee class below few public auto implemented properties. assume have created attribute - beforepropertyset & have annotated of entity properties - in class below. class employee { [beforepropertyset("some delegate", "some other prop value")] public string address { get; set; } public string name { get; set; } public int age { get; set; } } what want can explained of code snippet - var e = new employee(); e.address = "confidential data"; //this assignment restricted user x //whereas allowed user y e.name = "general data"; whenever assign value property, if property annotated special attribute beforepropertyset callback common function standard thing across application. example, if currentuser not expected view value being assigned new value assignment can cancelled. this approach enables me remove attribut

Regex expression to return match if word is found at a particular distance from another word -

i need build regular expression return true or false specified word in same sentence either word "county" or "counties" , comes either before or after either of words , no more either 10 words or 100 characters apart "county" or "counties". for example : county test test1 test2 word test3 test4 or test test1 test2 test3 word test4 test5 counties test6 test7 should return true , while counties test1 test2 test3 test4 test5 test6 test7 test8 test9 test test8 test3 test4 word test5 test7 should return false here got: \bword\w+(?:\w+\w+){0,10}?counties\b i added county works far if words county and/or counties after word: \bword\w+(?:\w+\w+){0,10}?(counties|county)\b can please point me in right direction? does solve problem? tried on regex101 word\s\w*(?:(?!word)\w+\w*){0,10}?(?:counties|county)|(?:counties|county)\s\w*(?:\w+\w*){0,10}?word

c# - How to make WCF service available in a local network? -

i'm new in wcf. wrote simple service: namespace wcfservice1 { [servicecontract] public interface iservice1 { [operationcontract] int add(int a, int b); } } namespace wcfservice1 { public class service1 : iservice1 { public int add(int a, int b) { return (a + b); } } } how can let local network access service? there several ways host (i think that's mean publish in context) wcf service: hosting in internet information services (iis) hosting in windows activation services (was) hosting in console or desktop application (self hosting) hosting in windows service where option 1 , 4 interesting if service more test project ;-) take @ tutorial more information: http://www.codeproject.com/articles/550796/a-beginners-tutorial-on-how-to-host-a-wcf-service

actionscript 3 - How to transform seconds in minutes ? in Flex -

my problems have value...75 seconds , want display in grid 1:15 minutes... how can ? i'm trying this... xmlcttsemacao = new xmllistcollection(event.result..ctt); var i:int = 0; each(var node:xml in xmlcttsemacao) { xmlcttsemacao[i].@dur_ctt = (xmlcttsemacao[i].@dur_ctt / 60) %60; i++; } xmlcttsemacao.refresh(); gp2.refresh(); but result example is: 1:25 another example...56 seconds displaying 0.933333 first, split bit, calculate seconds , minutes before putting them together: for each(var node:xml in xmlcttsemacao) { var durctt:int = xmlcttsemacao[i].@dur_ctt; var seconds:int = durctt % 60; var minutes:int = durctt / 60; var timedisplay:string = minutes + ":" + seconds; xmlcttsemacao[i].@dur_ctt = timedisplay; i++; }

arrays - PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" -

i running php script, , keep getting errors like: notice: undefined variable: my_variable_name in c:\wamp\www\mypath\index.php on line 10 notice: undefined index: my_index c:\wamp\www\mypath\index.php on line 11 line 10 , 11 looks this: echo "my variable value is: " . $my_variable_name; echo "my index value is: " . $my_array["my_index"]; what these errors mean? why appear of sudden? used use script years , i've never had problem. what need fix them? this general reference question people link duplicate, instead of having explain issue on , on again. feel necessary because real-world answers on issue specific. related meta discussion: what can done repetitive questions? do “reference questions” make sense? notice: undefined variable from vast wisdom of php manual : relying on default value of uninitialized variable problematic in case of including 1 file uses same variable name. majo

travis ci - Choose a specific Ubuntu version -

if i'm using default travis file looks build machine ubuntu precise. hit http://ppa.launchpad.net precise release.gpg is there tweak use trusty or utopic machine? this implemented, add .travis.yml : dist: trusty to use ubuntu trusty.

LightSwitch HTML Client: How to set the value of a computed property based on another computed property -

before asking question, make simple example make question clear. in lightswitch html client, have table 1 column: "amount" i made computed property, "amountplustax" , set value follow, myapp.browsetransactions.amountplustax_postrender = function (element, contentitem) { contentitem.databind("data.amount", function () { $(element).text(parsefloat(contentitem.data.amount) * 1.05); }); }; as see, amountplustax = amount * 1.05 the problem have want make computed property value depends on value of "amountplustax" computed property. like, amountplustaxplusinterest = amountplustax * 1.03 how possible? this doesn't work: myapp.browsetransactions.amountplustaxplusinterest_postrender = function (element, contentitem) { $(element).text(parsefloat(contentitem.screen.amountplustax) * 1.03); }; although doesn't directly answer question, alternatively capture inserting/inserted/updating/upda

c - Is read/recv thread safe (MSG_PEEK) -

i have 1 thread doing blocking read : rec = read(socket, data, size); i'm curious know whether safe or not me have thread, doing recv(msg_peek) in background on same socket: while (true) { if (recv(socket, byte, size, msg_dontwait | msg_peek) > 0) { printf("peeked %d", byte); } sleep(1); } since syscalls operate in kernel space, thread safe (they have be, otherwise kernel data corrupted , bring down entire system) in sense program won't crash - however, noted jeremy friesner in comments: the order in syscalls executed may not guaranteed. syscalls take time. means lot of data slip past in between calls recv () . however, write bytes named fifo. open writing end in thread doing read () , reading end in thread doing recv () . now, every time complete read () , write first byte (that's wanted, yeah?) fifo. meanwhile, in other thread, instead of using sleep () in between recv () , use blocking read of size 1 byte

java - How to override @Autowired with XML -

in spring project trying injection work in oval (a sourceforge library) custom validators (checkwith implementations). oval injector contains roughtly: public class springinjector { @autowired private autowiredannotationbeanpostprocessor processor; } and according oval documentation supposed declared way: <bean class="net.sf.oval.integration.spring.springinjector" /> . problem there 3 candidates injection. there way override @autowire in xml config given processor variable has no accessor methods? or other way injection work in oval custom validators? add this: <bean class="org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor"/> <bean class="net.sf.oval.integration.spring.springinjector"/>

Use javascript/jquery to see if items in list are due soon in Sharepoint 2013 -

i trying determine date if item due. in use case, user create item date in following format (mm/dd or 06/15). if date user chooses fall in next 30 days or month turn red. if date fall within next 60 days or less (until reaches 30) orange , if greater 60 yellow. so clarify, if date <= 30 days today's date turn red , on... i looking date.js perform these calculations unsure of how started. what thinking far following: var _duedate = currentitem.dateneeded; //not sure if correct syntax sharepoint development var = date(); var nowplus30 = new date(); nowplus.setdate(now.getdate() + 30); var nowplus90 = new date(); nowplus.setdate(now.getdate() + 90); if (_duedate == '' || !_duedate) { return ''; } , using values change background color example: if( _duedate <= nowplus30 ) //find data use determine color { x[i].parentnode.style.backgroundcolor = 'orange'; // set color } but doing these each co

database - Copying a complex data structure -

in our postgres database, have structure of class 1-* assignments 1-* questions 1-* alternatives previously assignments reused multiple classes, meaning several classes point same assignment id , fine world. now, need make change in system requires assignments unique each class. means need replicate assignments several copies can make them unique each class. so, generate unique assignments each class , each of them have own questions , alternatives. what's efficient way replicate without having build huge recursive code?

Excel Multiple Conditional Statements -

Image
hour daypart daypart cluster ------------- ------------------------------- 1 overnight 6 10 morning 6 morning 10 15 midday 15 afternoon 15 19 afternoon 20 evening 19 24 evening 8 morning 24 6 overnight i need assign 'daypart' grouping (in separate column) reflect daypart cross-reference table based on hour. for instance, if hour > 10, , hour < 15 , cluster should "midday" . i running problem when because need account other dayparts. so far conditions in excel result in false: =if(and(h2>$o$2,h2>$p$2,$q$2),if(and(h2>$o$3,h2<$p$3,$q$3),if(and(h2>$o$4,h2<$p$4,$q$4),and(h2>$o$5,h2<$p$5,$q$5)))) you need change overnight start @ 0 , go 6 move first row of criteria. i'll start nested set conditional statements. if start single condition no other

Flume - Stream log file from Windows to HDFS in Linux -

how stream log file windows 7 hdfs in linux ? flume in windows giving error i have installed 'flume-node-0.9.3' on windows 7 (node 1) . 'flumenode' service running , localhost:35862 accessible. in windows, log file located @ 'c:/logs/weblogic.log' the flume agent in centos linux (node 2) running. in windows machine, java_home variable set "c:\program files\java\jre7" the java.exe file located @ "c:\program files\java\jre7\bin\java.exe" flume node installed @ " c:\program files\cloudera\flume 0.9.3" here flume-src.conf file placed inside 'conf' folder of flume on windows 7 (node 1) source_agent.sources = weblogic_server source_agent.sources.weblogic_server.type = exec source_agent.sources.weblogic_server.command = tail -f c:/logs/weblogic.log source_agent.sources.weblogic_server.batchsize = 1 source_agent.sources.weblogic_server.channels = memorychannel source_agent.sources.weblogic_server.interceptors = it

How do I compare strings in Java? -

i've been using == operator in program compare strings far. however, ran bug, changed 1 of them .equals() instead, , fixed bug. is == bad? when should , should not used? what's difference? == tests reference equality (whether same object). .equals() tests value equality (whether logically "equal"). objects.equals() checks nulls before calling .equals() don't have (available of jdk7, available in guava ). consequently, if want test whether 2 strings have same value want use objects.equals() . // these 2 have same value new string("test").equals("test") // --> true // ... not same object new string("test") == "test" // --> false // ... neither these new string("test") == new string("test") // --> false // ... these because literals interned // compiler , refer same object "test" == "test" // --> true // ... should call objects.equals() o

python - Sort data frame in Pandas and draw a bar graph -

Image
i have result data frame , want sort index column of result data frame. result data frame stores groupby operatation performed here output of result data frame. i want sort index column. data types of column int64. right short data alphabets. want draw bar graphs sorted data. you index contains string representations of dates/periods first need converted before sorting. result['dates'] = [dt.datetime.strptime(d, "%b %y") d in result.index] result.sort('dates', inplace=true) to remove column, result.drop('dates', inplace=true, axis=1) to use pandas periods (which plotting data): result['periods'] = [pd.period(dt.datetime.strptime(d, "%b %y"), "m") d in result.index] to set index: result = result.reset_index().set_index('periods')

swf as trusted in android webview -

i try load swf file in webview android, swf load other files locally , acces network, test in web browser in computer, set swf trusted global security settings panel : http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html but in android load other page, contains local storage , peer-assisted networking: http://settings.adobe.com/flashplayer/mobile/ is there way configure swf trusted? or there way swf can read files locally , access network? flash not supported on modern android versions. chrome android (on modern android webview based) never ever supported flash.

c++ set and shared_ptr -

i have class x like: class x { public: bool operator<(const scn& other) const; }; the have following code std::multiset<std::shared_ptr<x>> m; my questions are: how data in m ordered? address of x(shared_ptr) or x.operator for m, if want access elements smallest bigest, can following code grantee that? if not, how? for (auto& : m) { f(i); } your set ordered based on key_type std::shared_ptr<x> . std::shared_ptr<x> comparable , ordering of std::shared_ptr prevails. for sake of reference, multiset defined as template< class key, class compare = std::less<key>, class allocator = std::allocator<key> > class multiset; as can seen, typename compare std::less<key> , std::less should overload function overload possibly implemented as constexpr bool operator()(const t &lhs, const t &rhs) const { return lhs < rhs; } both lhs , rhs of type t in cas

javascript - Choose <li> insertion place in list with jQuery according to id of siblings -

i have regular html ordered list: <nav id="global_nav"> <ol class="menu"> <li id="section1">section1</li> <li id="section2">section2 <ol> <li id="subsection1">subsection1</li> <li id="subsection2">subsection2</li> <li id="subsection3">subsection3</li> </ol> </li> <li id="section3" >item3</li> </ol> </nav> and made small html form too: <form> <label for="nuevo">insert</label> <input type="text" id="nuevo"> <label for="despues">after section</label> <input type="text" id="despues"> <input type="button" id="btn" value="insert"> </form> the point able populate list d

java - How to invoke a gwt service from c client? -

i'm looking simple way invoke gwt service c client. server side i'm using simple gwt default source: public string greetserver(string input) throws illegalargumentexception { // verify input valid. if (!fieldverifier.isvalidname(input)) { // if input not valid, throw illegalargumentexception to: // client. throw new illegalargumentexception( "name must @ least 4 characters long"); } string serverinfo = getservletcontext().getserverinfo(); string useragent = getthreadlocalrequest().getheader("user-agent"); // escape data client avoid cross-site script vulnerabilities. input = escapehtml(input); useragent = escapehtml(useragent); return "hello, " + input + "!<br><br>i running " + serverinfo + ".<br><br>it looks using:<br>" + useragent; } now i've create rpc call c client call greetserver string pa

swing - Character by character reading the input from JEditorPane in Java -

i trying create html editor. using jeditorpane, in want read input jeditorpane character character , want them stored in string. example: if user types <h want read 2 characters , according characters suggest users tags, in case <html>,<header>,<head> etc (i.e. tags starting 'h'). not getting how , function use read character jeditorpane user inputs jeditorpane. so not getting how , function use read character jeditorpane user inputs jeditorpane. you can use documentlistener read section swing tutorial on how write documentlistener more information , examples. if creating editor, displays text, not actual formatting, should use jtextarea or jtextpane. jeditorpane displaying existing html files.

c# - ASP.NET session redirect without postback -

i have single page application in asp.net c# . informations in application getting loaded using ajax calls. there's no postback @ all. however, every time click on different menu item loads data web services checks if user has valid session . since there's no postback , when session expires users still see main page , when click on menu item data not load since session expired (but users don't know that). i know how redirect login page when session expires if there's postback , how can achieve same result without postback ? the thing comes mind here use ajax call webservice check if session active, , act accordingly. along these lines (untested): ashx handler: <%@ webhandler language="c#" class="checksessionalive" %> using system; using system.linq; using system.web; using system.web.sessionstate; using system.web.script.serialization; public class checksessionalive : ihttphandler, irequiressessionstate { public vo

ios - Accelerate framework "sign" function -

i'm trying find super fast way of getting sign of each value in vector. hoping find function in accelerate framework this, couldn't find one. here's do: float *inputvector = .... // audio vector int length = ...// length of input vector. float *outputvector = ....// result for( int = 0; i<length; i++ ) { if( inputvector[i] >= 0 ) outputvector[i] = 1; else outputvector[i] = -1; } ok, think i've found way... vvcopysignf() "copies array, setting sign of each value based on second array." so, 1 method make array of 1s, use function change sign of 1s based on input array. float *ones = ... // vector filled 1's float *input = .... // input vector float *output = ... // output vector int buffersize = ... // size of vectors; vvcopysignf(output, ones, input, &buffersize); //output array of -1s , 1s based sign of input.

python - Convert a string field to a number field in arcpy -

i have large (>1000) number of files in there fields containing numbers defined text fields. need have fields containing these values numbers. can add new fields, when i'm failing populate them. i'm using arcgis 10.1. rows may have values ranging 0-10, , including 1 decimal place, or may empty variable (actually blank, no placeholder). below python script i'm using 2 of variables ( n_ct , n_cfy ), , error get. looks problem in how transfer text value decimal conversion. i'm new scripting, please excuse me if description or word choices unclear. import arcpy, os, sys arcpy import env decimal import * arcpy.env.overwriteoutput = true env.workspace = "c:\users\ouellettems\desktop\ice_data_testarea" listfcs = arcpy.listfeatureclasses("*") fc in listfcs: print str("processing " + fc) # displays file being handled strnct = "n_ct" # current, text version of field newnct = "nct&

unit testing - Why do the tests not run using this gradle script -

using: android studio 1.1.0; gradle (in built) i'm trying create unit tests , run them. created example project (calculator type deal) tests. ran tests ide , worked correctly. tried same console because ultimate aim run these on integration server, tests don't run. why tests not run console? gradle script have errors? sorry long post. better give excess data less. i'm total of 1 day old in gradle. , yes, jacoco task because want coverage next. of see empty reports because tests not running suppose. build.gradle buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' // note: not place application dependencies here; belong // in individual module build.gradle files } } apply plugin: 'java' apply plugin: 'jacoco' test { testlogging { events 'started', 'passed' } } jacocotestreport { reports { xml.e

It's okay to make a db conection multiple times? PHP - MySql -

i'm using class called mymysqli conect, make queries, etc. mymysqli.php: ... public function query($query){ $this->total_queries++; $result= mysqli_query($this->conection, $query); if(!$result){ echo "error: " . mysqli_error($this->conection); exit; } return $result; } ... ... public function free(){ mysqli_free_result($this->result); } ... and have other class define users. inside it, have public function modify data of user: public function makeactive($id){ if($this->userexists($id)){ $db = new mymysqli; $db->query("update users set useractive =1 iduser=".$id); $db->free(); return 1; } return 0; } and function userexists //checks if user exists : public function userexists($id){ $db = new mymysqli; $db->query("select iduser users iduser=".$id); if($db->num_rows($db->query) === 1){

sql - Advantage Database LEFT JOIN very slow -

sorry english i have following query joins 2 tables select t1.cod1, t2.xcod xcod1, t1.cod2, t2.xcod xcod2, t1.cod3, t2.xcod xcod3 from table1 t1 left join table2 t2 on t1.cod1 = t2.cod left join table2 t3 on t1.cod2 = t3.cod left join table2 t4 on t1.cod3 = t4.cod the query returns joined tables correctly , query runs slowly actually tables have more 200,000 records i think doing right through sub queries or left join (select ..)... any idea thanks.. table1 table2 +---------+-------- +---------+ +-----+-----+ | cod1 | cod2 | cod3 | | cod | xcod| +---------+------ --+---------+ +-----+-----+ | | | f | | | 1 | | d | b | | | b | 2 | | c | | | | c | 3 | | f | | d | | d

powershell - Read Computer Names from Text File and Execute a Command -

i have simple powershell script check status of bitlocker drive encryption on computer on network. i'd script determine status of multiple computers in text file. here's basic script far: $getid = read-host "what device id?" $computerid = manage-bde -status -cn "$getid" foreach ($computer in $computerid) { write-host("$computer") } what prompt tech host name , gives results. how can have script prompt tech path text file , have script give list of results text file? $textfilepath = read-host "what path text file?" if (test-path $textfilepath){ $computersarray = get-content $textfilepath foreach ($computer in $computersarray) { if (test-connection $computer -count 1){ $computerstatus = manage-bde -status -cn "$computer" write-host($computerstatus) } else { write-host("$computer appears offline.") } } } else { write-error &

mysql - two columns primary key, auto-increment and foreign key -

the following query successful when enter null values order id , different values(those not exist in column) item id, order id still getting incremented. how retain same order id? there problem way foreign key has been stated? create table orders( orderid int not null auto_increment, itemid int not null, quantity int not null, tot_price int not null, cid int not null, code varchar(10), order_time time, order_date date , constraint order_pk primary key (orderid, itemid), foreign key (itemid) references items(itemid), foreign key (cid) references customer(cid), foreign key (code) references coupon(code) ); the problem stems trying one-to-many (order items) relationship in single table. end badly. need two. 1 order, 1 items in order. or bad, how relational databases lists. create table orders ( orderid int not null primary key auto_increment, cid int not null references customer(cid), code varchar(

c# - Can I use the .Min() Linq extension method on a bool type? -

i want find if have bools false in collection. can use following code find it? this.mylist.min(e => e.mybool) i'm hoping return false if there false in collection. you can use (renamed collection reasons of readability): bool anyfalse = mybools.any(b => !b); or bool anyfalse = !mybools.all(b => b); both efficient since break on first false . if there complex objects in collection(as seerms be) use: bool anyfalse = mylist.any(x => !x.mybool); or bool anyfalse = !mylist.all(x => x.mybool);

mqtt - websocket and cloudmqtt, code example not working -

is possible work websockets , cloudmqtt ? have following code nothing working. first use mqttw31.js paho , in host file define connection details. src="js/mqttws31.js" type="text/javascript"> src="js/host.js" type="text/javascript"> var mqtt; var reconnecttimeout = 2000; function mqttconnect() { mqtt = new paho.mqtt.client( host, port, "web_" + parseint(math.random() * 100, 10)); var options = { timeout: 3, usessl: usetls, cleansession: cleansession, onsuccess: onconnect, onfailure: function (message) { $('#status').val("connection failed: " + message.errormessage + "retrying"); settimeout(mqttconnect, reconnecttimeout); } }; mqtt.onconnectionlost =

antlr3 - ANTLR 3.5 generates "extraneous parentheses" warning with C++ target -

i using c++ target in antlr v 3.5 , generated lexer.cpp file has bunch of extraneous parentheses warnings. warning is: warning: equality comparison extraneous parentheses [-wparentheses-equality] this happens in 5 places, corresponding generated lexer code is: void qualifiednamelexer::mtokens() { { // qualifiedname.g:1:8: ( t__11 | t__12 | t__13 | t__14 | t__15 | pn_chars_base | helper_rule_for_other_punctuation_chars | pn_chars_others | digit ) antlr_uint32 alt2; alt2=9; { int la2_0 = this->la(1); if ( (la2_0 == '-')) { alt2=1; } else if ( (la2_0 == '.')) { alt2=2; } else if ( (la2_0 == ':')) { alt2=3; } else if ( (la2_0 == 0x00b7)) { alt2=4; } else if ( (la2_0 == '_'))

android - Map fragment shows another wrong map fragment (one from the back stack) above it -

i have 1 activity , 4 fragments follow. fragment opens fragment b (has map fragment inside along other components). fragment b opens fragment c fragment c opens fragment d (has map fragment inside along other components) what's weird see map in fragment d , other map fragment b above it. <!-- fragment b --> <linearlayout .... <fragment android:id="@+id/put_ad_google_map1" android:name="com.google.android.gms.maps.supportmapfragment" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/continue_button" android:layout_alignparenttop="true" /> <!-- fragment d --> <linearlayout .... <fragment android:id="@+id/put_ad_google_map2" android:name="com.google.android.gms.maps.supportmapfragment" a

Android: Read and Write Primitive Types to Internal Storage -

is possible read , write primitive datatypes to/from file in internal storage? i've found plenty of tutorials , examples using read(bytes[]) , similar functions, nothing reading , writing, example, data members class, or bunch of ints, doubles, , strings. relying on function blindly reads number of bytes , trying parse result offsets , typecasting seems non-android me, can't seem find alternative. perhaps i'm attempting use wrong tool wrong job , that's why i'm running roadblock. i'm writing app connects via bluetoothle (using worst api i've ever seen, that's project requirements called i'm stuck it), , after connect device, want save device's "name" appears akin mac address bluetooth, , next time see device want display "friendly name" more human-readable name know after connecting device first time. lets me display friendly name device has been connected before - , skip authentication step. there, perhaps, better mec

python - Pandas DataFrame merge between two values instead of matching one -

i have dataframe date column , want merge not on match column if date column between 2 columns on second dataframe. i believe can achieve using apply on first filter second based on these criterion , combining results apply has in practice been horribly slow way go things. is there way merge match being between instead of exact match. example dataframe: ,code,description,begindate,enddate,refsessiontypeid,organizationcalendarid 0,2014-2015,school year: 2014-2015,2014-08-18 00:00:00.000,2015-08-01 00:00:00.000,1,3 1,2012-2013,school year: 2012-2013,2012-09-01 00:00:00.000,2013-08-16 00:00:00.000,1,2 2,2013-2014,school year: 2013-2014,2013-08-19 00:00:00.000,2014-08-17 00:00:00.000,1,1 instead of merge on date=begindate or date=enddate want match on date between(begindate, enddate) you can use numpy.searchsorted() simulate between . say data , lookup value this: in [162]: data = pd.dataframe({ .....: 'date': pd.series(pd.np.random.randint(142944

python - Why is the subprocess.Popen argument length limit smaller than what the OS reports? -

i running python 3.4.3 on linux 3.16.0. want use subprocess.popen run command long single argument (a complex bash invocation), 200kib. according getconf , xargs , should within limits: $ getconf arg_max 2097152 $ xargs --show-limits < /dev/null environment variables take 3364 bytes posix upper limit on argument length (this system): 2091740 posix smallest allowable upper limit on argument length (all systems): 4096 maximum length of command use: 2088376 size of command buffer using: 131072 however, python fails quite smaller limits: >>> subprocess.popen('echo %s > /dev/null' % ('a' * (131072-4096)), shell=true, executable='/bin/bash') <subprocess.popen object @ 0x7f4613b58410> >>> subprocess.popen('echo %s > /dev/null' % ('a' * (262144-4096)), shell=true, executable='/bin/bash') traceback (most recent call last): [...] oserror: [errno 7] argument list long note python limit same "ac

c# - Debugging .Net 3.5 code from a .Net 4.0 web site -

there post similar title. solution given move vs 2010. i'm having same problem when using vs 2013. have .net 4.0 built web site uses .net 3.5 built assemblies. can't debug assemblies. if change web site build against .net 3.5, debugging works expected. anyone know of solution? thing know of not use .net 4.0. thanks help. kevin

optimization - AngularJS: Pause $digest & watchers on hidden DOM elements -

we're building single page application has multiple pages loaded tabs. content of 1 tab visible @ given time (much browser), want temporarily pause $digest , watchers executing on dom nodes of hidden tabs, until user switches tab. is there way achieve this, model continues updated background tabs, view updates based on condition. the following code illustrates problem: <div ng-repeat="tab in tabs" ng-show="tab.id == current_tab.id"> <!-- tab content bindings --> </div> the goal optimization. i'm aware of scalyr directives , want more specific solution without features contained in scalyr. after trial , error i've figured out following directive pauses children's $$watchers if expression on attribute evaluates true , on false restores backed $$watchers app.directive('pausechildrenwatchersif', function(){ return { link: function (scope, element, attrs) { scope.$watch(att

Word VBA "Saveas" without hidden text? -

is there way programmatically saveas microsoft word .docm without including hidden text? i'm having users click button few other things , opens save dialog save .docm file .html file, using in word vb editor: with dialogs(wddialogfilesaveas) .format = wdformathtml .show end it saves appears on page saves paragraphs hidden. (they're hidden in web display of html page, hidden content still in .html, marked mso-hideall tags.) save content not hidden, if possible, it's not in html file @ all. i don't see provides here , i'm wondering if might know of way using vb. i've been working on deleting hidden text using vba, it's tricky because have show first, select it, delete it, , parts hidden different each time depending on user selects in word .docm document. update: here's complete code have now: public stractiveoption string private sub optionconcept_click() stractiveoption = "optionconcept" bookmarks("conceptte

reactjs - How to mock return value in another file? -

i'm testing actions file in flux jest , can't seem figure out how mock return value in it. when specify return value (see code below) mocked module in test file, works fine, when same function called in module i'm testing, comes undefined. #missionactions-test.js jest.dontmock('../missionactions'); describe('missionactions', function() { var gamestore = require(root + 'stores/game/gamestore'); var missionactions; beforeeach(function() { missionactions = require('../missionactions'); }); it('should...', function() { gamestore.getgame.mockreturnvalue({test: "test"}); console.log(gamestore.getgame()); // prints {test : "test"} missionactions.addmissionfrombank(); }); }); and missionactions.js being tested. # missionactions.js var gamestore = require('../../stores/game/gamestore'); var missionactions = { addmissionfrombank: function(ban

c - Strange things happen when swapping two vars in QuickSort -

i'm implementing quicksort in c. here's swap procedure: void swap(int *x, int *y) { *x += (*y); *y = (*x) - (*y); *x = (*x) - (*y); } and here's partition procedure: int partition(int a[], int sx, int dx) { int indice_pivot = (rand()%(dx-sx+1))+sx; int = sx-1, j; swap(&a[indice_pivot],&a[dx]); for(j=sx;j<dx;j++) { if(a[j] <= a[dx]) { i++; swap(&a[j],&a[i]); } } i++; swap(&a[i],&a[dx]); return i; } the problem when swapping 2 variables, magically (?) become 0. did debugging , seems working fine inside swap procedure. array contains zeros @ end of partitions (not of them). strange thing if replace swap procedure void swap(int *x, int *y) { int temp = *y; *y = *x; *x = temp; } everything works fine. why? your swap function not work if both pointers point same element. if second step *y = (*x) - (*y); sets el

ssl - Does Android trust StartSSL certificates? -

i developing android app , encrypt data sent server. i've seen many people saying best practices using ssl , found startssl free. questions are: would android trust startssl certificate? do recommend me startssl or should use certificate authority rapidssl or godaddy? thanks! i got certificate here: https://www.namecheap.com/security/ssl-certificates/domain-validation.aspx it cheapest find , havent gotten trust issues. (ios, android, chrome, firefox, ie) just make sure certificate chain setup correctly.

ios - IAP Restoring Hosted Content -

we developing app has in app purchased - hosted content apple, app works , users can make purchase of content , app downloads ok. however have since started developing restore purchases button in app, , cannot seem figure out how can request list of purchases apple using restorecompletedtransactions currently when request store kit invoking delegate method - (void)paymentqueue:(skpaymentqueue *)queue updateddownloads:(nsarray *)downloads { and downloads starting automatically ideally receive list of available downloads user part of restore , present them screen select files want download , kick off download of content. apple guidelines state cannot seem find examples: apps more few products, products associated content, let user select products restore instead of restoring @ once. these apps keep track of completed transactions need processed they’re restored , transactions can ignored finishing them immediately. thanks aaron when transactions come thro

perl - Data::Dumper returned hash with a slash -

so have line of perl code reads this: my $stored_value = $foo->some_function($argument); when dumper on it: warn dumper $stored_value i receive result. $var1 = \{ 'foo' => 'abc', 'bar' => '123' }; now, i've seen results this: warn dumper $another_hash; $var1 = { 'foo' => 'bar', 'baz' => 'quux' }; and if wanted say, foo's value, i'd type in this: warn dumper $another_hash->{'foo'}; to result. $var1 = 'bar'; originally, couldn't find through google searches, now, made little test script play around saw, , found out #!/usr/bin/perl # use strict; use warnings; use data::dumper; sub test { $brother = {'ted'}; $brother->{'ted'} = 'brother'; return \$brother; } $blah= test(); $blah = ${$blah}; print dumper $blah->{'ted'}; print "\n"; here results: $var1 = &

How can I download a .mp4 file instead of playing it on browser? Support for Chrome, Firefox and IE using javascript or jQuery -

i have .mp4 file need download system when click on anchor tag. html: <a href="dscsa_webinar.mp4">download here</a> is there way download instead of opening in browser? i needed run on ie , option have through javascript or jquery. else simpler can suggested. i aware of html5 download attribute, doesn't support on ie. i found this: http://www.webdeveloper.com/forum/showthread.php?244007-resolved-force-download-of-mp3-file-instead-of-streaming , similar things excel files. directly there: use small php file handle download, put in same folder .mp3: <?php $file = $_get['file']; header ("content-type: octet/stream"); header ("content-disposition: attachment; filename=".$file.";"); header("content-length: ".filesize($file)); readfile($file); exit; ?> which can accessed in anchor this: <a href="direct_download.php?file=fineline.mp3">download mp3</a>

PHP: SQL Syntax error on equivalent server -

our development , production servers identical, except capacity (ram, disk, , on): ms win server 2008 r2 ent/ms sql server 2005/apache2.2/php 5.213. in our dev machine following (summarized) sql works perfectly: select somecol collate database_default localtable union select somecol collate database_default linkedserver.remotedb.dbo.table note: linked server same 1 in both dev/prod servers. in prod server gives following error: [microsoft][sql server native client 10.0][sql server]incorrect syntax near 'database_default'. if remove collate dabatase_default clauses, error (as expected): [microsoft][sql server native client 10.0][sql server]cannot resolve collation conflict between "sql_latin1_general_cp1_ci_ai" , "sql_latin1_general_cp1_ci_as" in union operation. if if point prod code dev database, works. on other hand, if point de dev code prod database, fails. what on earth going on? thank you. i belive have d

python - can properties use array syntax? -

can use either property or @property create uses array syntax? in code, like: x = exampleclass() x.y[6] #x.y property, 6 passed arg getter function thanks you can making y container type: >>> class a(object): ... def __getitem__(self, index): ... return 2 * index ... >>> = a() >>> a[3] 6 >>> class exampleclass(object): ... def __init__(self): ... self.y = a() ... >>> x = exampleclass() >>> x.y[6] 12

bazaar - Preventing bzr-update changes to user-specific .cfg file -

i have project, hosted on launchpad, contains user-specific configuration file. once project checked out, .cfg file should downloaded. however, further updates (via "bzr update") ideally not alter .cfg file, user have made own edits it. these edits overridden / merged should (with potential conflicts) push update using code own .cfg file - don't want happen! what's best practice avoid this? can't "bzr ignore", future users checking out via bzr not have .cfg file. i could, of course, replace .cfg file "stock" 1 each time commit, seems bit clunky. or equivalently clunky, supply .cfg file separately. what i'm looking "single-shot" download, never update subsequently. any advice? this tricky problem, because version control systems in general not engineered have fine-grained commit strategies needed approach. if operating in controlled environment, use plugins or hooks exclude files commits etc., doesn't s

html - padding from outside table border line -

Image
quick question. have table, has border. when add padding, adds padding from inside of table. way make add padding outside border ? essentially, table border lines should appear within cell . regards (whatever displayed as) im not 100% sure mean may want this. html: <table> <tr> <td>cell 1</td> <td>cell 2</td> </tr> </table> css: body { padding: 20px; } table { width: 400px; height: 400px; outline:2px solid red; outline-offset: -15px; } td { border:2px solid blue; } table only: demo here cell only: demo here so here setting outline , can put outline-offset on it. bring table if use - value. use border remember doesn't count towards width or height. note: can use on each cell etc.

fortran - Pass arguments and take sum -

i passing 2 values fortran program, need sum of arguments , print result: i have program reading arguments follows: program argtest implicit none integer*4 nargs,i character arg*80 nargs = iargc() = 0,nargs call getarg(i, arg) print '(a)', arg end end i passing values 10 , 20. tried this: program argtest implicit none integer:: nargs,i character:: arg integer:: num1 integer:: num2 integer:: result nargs = iargc() = 1,nargs call getarg(i, arg) !print *, arg if( == 1) num1 = ichar(arg) else if(i == 2) num2 = ichar(arg) else end if end result = num1+num2 print *, num1 print*,num2 end i need print answer 30. getting values 49 , 50 instead of getting 10 , 30. please me. here simple version: reads arguments strings, converts them ints 1 after other, , adds them up. program argtest implicit none integer*4 nargs,i character arg*80 integer :: total, int_arg nargs = iargc() total = 0 = 1,nargs

css - How to combine compass with bless? -

i working on compass project , final css output huge needs be blessed . i using codekit compile scss files, , has bless option less , sass files unluckly option seems not available compass projects (btw there no workaround fix problem https://github.com/bdkjones/codekit/issues/163 ) is there alternative way automatically after compiling process? possible watch css file nodejs , bless it? ==================================================== update i not using codekit anymore use grunt build project assets , works charm. well, seems using this reference can like: on_stylesheet_saved |filename| system('blessc ' + file.basename(filename)) end after have installed bless . what attaching event after compile compass file :) enjoy

Determine java version used to call a program -

this question has answer here: how find jvm version program? 10 answers i'm trying determine inside application java version used call jar. i saw solutions talking system.getproperty(java.version) , if user have different versions of java, , command this: c:\absolute\path\to\java\1.5\java -jar something.jar is there way know real java version? you should use system.getproperty("java.version") . give version of currently running jvm string , , can check prefix 1.5 or 1.6 , , have version of java. also check this question , , docs system.getproperty(...) . hope helps.

php - Stop user from viewing page if condition is not met -

hi appologies if has been answered can not find clear answer question. lets have 2 pages, called fruit.php , salad.php when user has entered data fields fruit.php directed salad.php nothing prevents user typing salad.php browser open second page , give wrong results because data page1, fruit.php has not been entered. any idea how can stop user accesing salad.php before fruit.php completed? in such case can this: since user expected enter values in 1st page (form) presenced there, let's one: fruit.php <form name="fruit" id="fruit" action="salad.php" method="post"> first component: <input type="text" name="component1"> second component: <input type="text" name="component2"> <input type="submit" value="check"> </form> now second page: salad.php <?php //first thing first, we're going check whether user //is being redi