Posts

R-how to add columns to a data frame in a for loop? -

R-how to add columns to a data frame in a for loop? - i have info looks , 1000 files same info format. r_338 4 r_341 1 r_471 1 r_491 4 r_494 1 r_642 0 m_218 5 m_222 5 m_292 0 p_185 5 p_187 5 a_308 0 a_473 1 i appreciate if can direct me how can write r script can merge 1000 files keeping first column 1 time , rest 0f 1000 columns appended: example output: r_338 4 5 6 7 8 9 10 11 r_341 1 1 1 1 1 1 1 1 r_471 1 1 0 1 1 1 2 1 r_491 4 4 4 4 4 4 2 0 r_494 1 1 1 1 1 1 1 1 r_642 0 1 0 9 1 1 2 1 m_218 5 5 5 9 5 5 5 9 m_222 5 5 5 5 5 5 5 5 m_292 0 5 1 1 1 1 1 1 p_185 5 5 5 6 5 5 5 5 p_187 5 9 5 5 5 5 3 5 a_308 0 4 4 4 2 4 4 4 a_473 1 1 1 1 0 1 1 0 suppose have character vector containing file names. think l <- lapply(file.names,re...

asp.net - Jquery Ajax and Iframe -

asp.net - Jquery Ajax and Iframe - i have page on calling ajax function processing on server, during processing page displays loading icon. have iframe on same page, purpose of iframe info server , display in iframe using jquery ajax. the problem having is, iframe not updating until first function phone call completed... browser blocking multiple ajax calls or there missing? here code: the phone call made on main page: done on document.ready. calling same file new querystring $.ajax({ url: window.location.href + '&process=1', context: document.body, success : function(response){ window.location.href = response; } }); the page in iframe: calls function after every 2 seconds fetch info server window.settimeout(fetchstatus,1000); function fetchstatus(){ $.ajax({ url: 'webform1.aspx?act=status', context: document.body, ...

c - Packed Structs in (gcc)go -

c - Packed Structs in (gcc)go - i have old c code makes heavy utilize of packed structures. i'm looking using go wrapper code, having difficulty finding way pass or write definitions these structures. example: import "unsafe"; type aligntest struct { c byte; y int16; z int16; q int32; } func main() { vr := new(aligntest); fmt.println(unsafe.sizeof(*vr), "\n"); } returns 12 rather 1+2+2+4 = 9 want packed/unaligned struct. i know create byte array , parsing manually, seems brittle , error prone... you may want rethink architecture- seek passing binary input downwards c layer , utilize existing structures (you won't break don't change). i'm assuming construction packing looks this: #ifdef windows #pragma pack(push) #endif #pragma pack(bytealignment) // e.g. "#pragma pack(1)" or "#pragma pack(8)" //--- packed structs #ifdef windows #pragma pack(pop) #endif #ifdef posix #pra...

PHP timestamp/membership system not expiring on the exact date -

PHP timestamp/membership system not expiring on the exact date - i'm having few problems while creating little membership scheme timestamps. when show timestamp in date, tell me when active membership expires. however, on time/date, not expire, , script resets membership, , counts -numberhere. i don't think i'm doing wrong? i'm doing (time() - $timestamp) work out. here's script(s); $membership = mysql_query("select * `members` `membership` > 0 , `membertype` > 0") or die(mysql_error()); while($mm = mysql_fetch_array($membership)){ if((time() - $mm["membership"]) > $mm["membertype"]){ mysql_query("update `members` set `membership` = 0, `membertype` = 0 `username` = '" . $mm[username] . "'"); } else { echo (time() - $mm["membership"]); } } $membership_date = date("d-m-y h:i:s", $user["membership"]); echo "your membership expiry date...

What is the life time of a C++ data structure object? -

What is the life time of a C++ data structure object? - suppose have have car.h define class called auto , , have implementation car.cpp implement class car , illustration car.cpp can : struct helper { ... }; helper helpers[] = { /* init code */ }; car::car() {} char *car::getname() { .....} what life time of helpers array ? need static helper helpers[]; ? if have done bad practices, please allow me know. any variable declared/defined in global / namespace scope has finish life time until code ends. if want helper helpers[]; accessible within car.cpp should declare static ; otherwise allow global. in other words, helper helpers[]; // accessible everywhere if `extern`ed file static helper helpers[]; // accessible in `car.cpp` edit: as, @andrewdski suggested in comment below; should create helpers[] static variable since using within file; though helper not visible outside. in c++, if 2 exclusively different unit has same named global var...

Python - using subprocess to call sed? -

Python - using subprocess to call sed? - i wish phone call sed python using subprocess. script tried using below. however, pipes sed output standard terminal. seems '>' operator not recognised within subprocess.call statement. suggestions? import sys import os import subprocess files = os.listdir(sys.argv[1]) count = 0 f in files: count += 1 inp = sys.argv[1] + f outp = '../' + str(count) + '.txt' sub = subprocess.call(['sed', 's/\"//g', inp, '>', outp]) also - file names have spaces in them, i.e., " file1 .txt". issue? sed command works fine when phone call sed terminal, not script. thanks. use out_file = open(outp, "w") sub = subprocess.call(['sed', 's/\"//g', inp], stdout=out_file ) python sed subprocess

Run ant from Java -

Run ant from Java - is there tutorial on how run ant java? got code here: setting java_home when running ant java but haven't been able create work. i've been trying find illustration or tutorial on how utilize it. here's have far: project p = new project(); p.setuserproperty("ant.file", buildfile.getabsolutepath()); p.firebuildstarted(); p.init(); p.executetarget("default"); but guess error: exception in thread "main" target "default" not exist in project "null". @ org.apache.tools.ant.project.tsort(project.java:1912) @ org.apache.tools.ant.project.toposort(project.java:1820) @ org.apache.tools.ant.project.toposort(project.java:1783) @ org.apache.tools.ant.project.executetarget(project.java:1368) @ com.arthrocare.vss2svn.vss2svn.newprocess(vss2svn.java:128) @ com.arthrocare.vss2svn.vss2svn.main(vss2svn.java:52) java result: 1 i tried ...