Posts

scripting - Is there a way to create a bash script that will only run for X hours? -

is there way create bash script run x hours? i'm setting cron job initiate script every night. script runs until condition met, exporting it's status holding variable keep track of 'where is' after each iteration. intention start-up process every night, run few hours, , stop, holding status until process starts next night. short of somehow collecting start time, , checking against current time in each iteration of loop, there easier way this? bash scripting not forte (i know enough things done , dangerous) , have not done before. appreciated. thanks. use gnu coreutils gnu coreutils contains actual timeout binary, invoked this: # timeout after 5 seconds when sleeping 30 /usr/bin/timeout 5s /bin/sleep 30 in case, you'd want specify hours instead of seconds, timeout in 2 hours use 2h instead of 5s . see timeout(1) or info coreutils 'timeout invocation' additional options. hacks , workarounds native timeouts or gnu timeout command be...

Git does not commit -

i try commit changes , keep getting this: # on branch master nothing commit (working directory clean) i do: git add . git commit -a -m "test" and error message before can git push like message says, doesn't there changes add cache, let alone commit anything. execute git status see if changes exist (it shouldn't).

machine learning - algorithmic complexity of classification algorithms/artificial neural networks -

the algorithmic complexity of binary trees o(n), n being height of tree. there resources listing complexity of methods selecting best tree? e.g. boosted regression trees, cart or c4.5 (even mars) also, not familiar artificial neural networks, references seem point specific ann implementations being np-complete: http://people.csail.mit.edu/rivest/pubs/br93.pdf , http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.7.8997 . does know extent general result?

c++ - How can I determine the actual type of an 'auto' variable -

in response: https://stackoverflow.com/a/14382318/1676605 this program given: std::vector<int> vi{ 0, 2, 4 }; std::vector<std::string> vs{ "1", "3", "5", "7" }; (auto : redi::zip(vi, vs)) std::cout << i.get<0>() << ' ' << i.get<1>() << ' '; i have no idea type of auto i is, making harder reuse expertise , learn examples. here changing auto i char i returns in function ‘int main()’:| /data/cbworkspace/testzip/testzip.cpp|14|error: cannot convert ‘boost::iterator_facade<boost::zip_iterator<boost::tuples::tuple<__gnu_cxx::__normal_iterator<int*, std::vector<int> >, __gnu_cxx::__normal_iterator<int*, std::vector<int> > > >, boost::tuples::cons<int&, boost::tuples::cons<int&, boost::tuples::null_type> >, boost::random_access_traversal_tag, boost::tuples::cons<int&, boost::tuples::cons<int&, boost...

.net - Using .net3.5 assemblies and mixed-mode dlls on .net4 -

its in context of c++ application uses .net3.5 assemblies through mixed-mode (again targeted .net3.5) assemblies. native app explicitly loads .net assemblies. i want know repercussions of using .net3.5 assemblies on .net4. found few links suggest using uselegacyv2runtimeactivationpolicy. there similar question answer suggests fine, following links make me think better recompile targeting .net4: "...apps built versions 2.0, 3.0, , 3.5 can run on version 3.5, not work on version 4 or later." - on msdn "some framework types have moved across assemblies between versions..." - in answer "no idea. depends on application , apis uses. there breaking changes in .net 4 , application hitting one..." - in msdn forum answer i want know repercussions of using .net3.5 assemblies on .net4. in general, need set runtime activation policy force .net 4. means 3.5 assembly executed using clr 4 runtime, not clr 2 runtime. for scenarios, things ...

crash - Java program crashing when it overwrites an existing .txt file? -

i'm making simple text based game have type commands preform actions. added feature game allows save progress. reason if try save game on existing save file crashes. here code saves game ( when fails save says "there error when trying save game data. game close." expected ): import java.util.formatter; import javax.swing.joptionpane; public class gamesave { private static formatter gamesave; private static formatter firsttimesave; private static formatter attackpoints; private static formatter defensepoints; private static formatter skillpoints; private static formatter wins; private static formatter loses; private static formatter money; // attackpoints, defensepoints, skillpoints, wins, loses, money public static void openfile(){ try{ attackpoints = new formatter("c:\\fightnight\\saves\\"+mainclass.newprofilename+"\\"+mainclass.newprofilename+"_attackpoints.txt"); ...

sql - How to stop Access from thinking my table.field in VBA is a form component? -

so i'm writing sql query in vba in access 2010, , when code ran, thinks supplierconnect.mailboxid component on form, in fact database table (supplierconnect) , field (mailboxid). every time code ran pops box asking me input form component, isn't one. there way around or code differently? thanks! ' mailbox id if isnull(mailboxidcombobox.value) else if firstwhere = true mailboxid = "where supplierconnect.mailboxid = '" & [forms]![supplierquery]!mailboxidcombobox.value & "'" firstwhere = false else mailboxid = " , supplierconnect.mailboxid = '" & [forms]![supplierquery]!mailboxidcombobox.value & "'" end if end if this not popping asking value because thinks form control, because undefined query. cannot find field within query definition. happens because not have proper case sensitive table or field id or incorrect table linked. if provided more code sql statement using begin...

sql - Updating a column using set criteria -

i want update kyc5.status scanned if same kyc5.wallet_number present in jewel_scan2.customer_wallet . so far have used following code: update kyc5 set [status_] = 'scanned' customer_wallet = jewel_scan2.customer_wallet but error message shows: the multi-part identifier "jewel_scan2.customer_wallet" not bound. any solution this? should use update inner join ? any highly appreciated. try add jewel_scan2 table from section below update kyc5 set [status_]='scanned' jewel_scan2 j kyc5.customer_wallet= j.customer_wallet

osmf - How to build strobe media player? -

i downloaded , installed strobe media player http://osmf.org/strobe_mediaplayback.html in mac. need debugging using console log statements. how build this? this doc might help: http://osmf.org/dev/osmf/specpdfs/building-osmf.pdf . otherwise should have debug build available sourceforge download: http://sourceforge.net/projects/smp.adobe/files/ hope helps

sql - Trying to compare two consecutive records -

i using sql server 2008 , need in writing query compares 2 consecutive records. select recorddate sitehistory siteid = 556145 , isrecent = 0 , isrunning = 1 order recorddate desc gives me around 2000 rows looks this: recorddate ----------------------- 2013-05-08 20:04:23.357 2013-05-08 19:45:26.417 2013-05-08 19:30:24.810 2013-05-08 19:17:22.843 2013-05-08 19:00:16.017 2013-05-08 18:44:14.230 ..... ..... now need compare date of each row next row , count how many times difference between 2 consecutive dates greater 15mins. come far: ;with temp as( select row_number()over(order recorddate desc)as 'row', recorddate sitehistory siteid = 556145 , isrecent =0 , isrunning=1 ) select count(*) count temp t1 inner join temp t2 on t2.row = t1.row+1 datediff(mm,t1.recorddate,t2.recorddate)>15 however, doesn't give me desired. please let me know how can correct suit requirements. logic of query correct, thing trying date difference in month ...

Matlab plot won't return correct results -

i have written function beginning of poisson process function n_t = poisproc2(t,tao,size) n_t=0; n=1:size if t>tao(1,n) n_t=n_t+1; end end end tao array of random doubles of length size. simplicity we'll [1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,20] so functions purpose count how many elements of tao t greater given t. this code works fine when write poisproc2(3,tao,20); the answer 19 expected, if write x=1:.01:20; y=poisproc2(x,tao,20); plot(x,y,'-') y shows 0 in workspace (i expect array of length 1901) , plot reads 0. i'm pretty new matlab, seems pretty thing i'm trying , must missing obvious. please help! your code not work giving vector. if condition not working expect. first initialize n_t vector : n_t=zeros(1,length(t)) instead of if t>tao(1,n) n_t=n_t+1; end vectorize expression : n_t = n_t + (t>tao(1,n)) cheers

Combining multiple lines of telnet into 1 batch file -

to perform specific task had following commands telnet 10.0.0.192 *hit enter y (answer yes whatever question comes up) *hit enter domain\username (when prompted username) *hit enter password (when prompted password) *hit enter \\10.0.0.2\path\batchfile.bat (this batch file i'd run in end) *hit neter is there way can combine data 1 batch file (saving passwords fine) have double click batch file , ends executing batchfile.bat on remote server? it not possible automate entierly using batch file. can use vbs script manage session. here's example of such script (called dotelnet.vbs, sake of example): set myshell = createobject("wscript.shell") myshell.run "cmd" wscript.sleep 100 myshell.sendkeys"telnet 127.0.0.1" myshell.sendkeys("{enter}") wscript.sleep 100 etc... you call batch file with: cscript dotelnet.vbs

C# Ways to access containing class without passing reference -

is there way access containing/enclosing class during initialization (constructor logic) of nested owned class without needing reference passed constructor parameter? the reason don't want pass reference containing class constructor parameter nested owned class because virtually every single object in program need it, , feels sloppy passing in argument manually every time never change anyways. want simplify programming as possible other team members of mine using engine. i tried making method container class use when adding new objects take new instance parameter , set instance's "container" variable "this" (the container class), nested owned object's initialization code happens first defeats purpose (i want able access container during initialization, container variable needs set before, not after constructor code executed). any ways make happen? or doomed manually pass in reference container class every time make new nested owned object...

python - How to connect to https site with Scrapy via Polipo over TOR? -

not entirely sure problem here. running python 2.7.3, , scrapy 0.16.5 i've created simple scrapy spider test connecting local polipo proxy can send requests out via tor. basic code of spider follows: from scrapy.spider import basespider class torspider(basespider): name = "tor" allowed_domains = ["check.torproject.org"] start_urls = [ "https://check.torproject.org" ] def parse(self, response): print response.body for proxy middleware, i've defined: class proxymiddleware(object): def process_request(self, request, spider): request.meta['proxy'] = settings.get('http_proxy') my http_proxy in settings file defined http_proxy = 'http://localhost:8123' . now, if change start url http://check.torproject.org , works fine, no problems. if attempt run against https://check.torproject.org , 400 bad request error every time (i've tried different https:// sites, , ...

ruby on rails - User-generated SQL Query -

i'm developing data warehouse using ruby on rails , should allow user perform arbitrary select queries on application database. i know shouldn't do, it's interface client needs (i can't think of possible queries user might want , translate them activerecord queries). there complex joins , sub-queries , on. i'd rather (integrate app) let them access db via pgadmin (i'm using postgresql). my question is: safest way of doing this? should able escape insert, update, drop table, etc... i'm thinking of getting query string , sanitizing these "dangerous" words , using activerecord::base.connection.execute(sanitized_sql_string). reasonable approach? the safest way let postgres handle security you. create new user: create user reader; -- rails app should logon user then, explicitly grant select permissions on objects want them able query: grant insert on tablefoo reader; grant insert on tablebar reader; then, they'll able r...

php - How can I reduce the number of queries Doctrine is performing? -

i'm building product management tool product can have arbitrary number of attributes , documents , features , images , videos single type , brand , , category . there few other related tables, enough demonstrate problem. there's model class called productmodel contains method (reduced clarity): public function loadvalues() { //product entity data $this->id = $this->entity->getid(); $this->slug = $this->entity->getslug(); // 1 of each of these $this->loadtype(); $this->loadbrand(); $this->loadcategory(); // arbitrary number of each of these $this->loadattributes(); $this->loaddocuments(); $this->loadfeatures(); $this->loadimages(); $this->loadvideos(); ... } each of load methods boiler plate executes method: public function loadentitiesbyproductid($productid=0) { // entities of type associated product. $entities = $this->entitymanager ->ge...

android - Email or Something persistent for User signing in via Google+ (Google Game Services) -

is there way retrieve user's email address programmatically when authenticating during google game play services sign in process on android? or if there persistent user id returned token? we trying create scenario user can connect or merge many social accounts single account. gamesclient.getcurrentaccountname() returns logged in user's email address (assuming have get_accounts permission).

performance - Why does having an "include" of a file that doesn't exist slow my entire PHP page to a crawl (on IIS 7.5)? -

as example, let's have following in php code @ top of file: include ($collectiontype."s/collectors_config.php"); what i'm noticing if include file doesn't exists, let's @ path bogus/collectors_config.php , execution of php page slows crawl. if exist, page super fast. i running php 5.4 on iis 7.5 (windows server 2012). why that? there recursive lookup killing performance looking file isn't there? there setting in php.ini need change? looking insight here why happening.

lexical analysis - Conflict while parsing a set of expressions -

i parse set of expressions: r[3]c , r[2]c , r[3]c-r[2]c ... there conflict cannot solve... here part of lexer.mll : rule token = parse | 'r' { r } | 'c' { c } | "rc" { rc } | ['0'-'9']+ lxm { integer (int_of_string lxm) } | '+' { plus } | '-' { minus } | '[' { lbracket } | ']' { rbracket } | eof { eof } ... a part of parser.mly : main: e_expression eof { $1 }; e_expression: | ec = e_cell { ee_rc (rc.cell ec) } | e_expression minus e_expression { ee_string_eel ("minus", [$1; $3]) } e_cell: | r lbracket r = index rbracket c c = index { (rc.i_relative r, rc.i_absolute c) } | r lbracket r = index rbracket c { (rc.i_relative r, rc.i_relative 0) } index: | integer { $1 } | minus integer { printf.printf "%n\n" 8; 0 - $2 } this code curiously not work r[3]c-r[...

android - NotificationCompat.Builder -

i send in constructor of class extends nothing context int icon = r.drawable.ic_launcher; long when = system.currenttimemillis(); mynotification = new notificationcompat.builder(context) .setsmallicon(icon) .setcontenttitle(context.getresources().getstring(r.string.app_name)) .setcontenttext(context.getresources().getstring(r.string.app_name)) .setwhen(when) .setticker(context.getresources().getstring(r.string.app_name)) .setdefaults(notification.flag_no_clear); and send datas through remoteviews , on end intent notificationintent = new intent(context, menu_activity.class); pendingintent contentintent = pendingintent.getactivity(context, 0, notificationintent, 0); contentview.setonclickpendingintent(r.id.layoutnotification, contentintent); mynotification.setcontent(remoteview); mynotification.setongoing(false); mynotification.setautocancel(false); mynotification.s...