Posts

How to store a process in rust -

i'd store std::io::process::process inside struct in rust. however, program goes defunct pass process instance struct. why that? code: use std::io::process::{command, process}; use std::rc::rc; use std::cell::refcell; struct dzeninst { process: rc<refcell<process>> //stdin: std::io::pipe::pipestream } impl dzeninst { // write string stdin of dzen fn write(&mut self, s : string) { let mut stdin = self.process.borrow_mut().stdin.take().unwrap(); println!("writing dzen inst"); match stdin.write_str((s + "\n").as_slice()) { err(why) => panic!("couldn't write dzen stdin: {}", why.desc), ok(_) => println!("wrote string dzen"), }; } } fn createdzen() -> dzeninst { dzeninst {process: rc::new(refcell::new( match command::new("dzen2").spawn() { err(why) => panic!("couldn't spawn ...

asp.net mvc - Limit Value of a text field -

i new mvc i have employee poco this [petapoco.tablename("tblemployee")] [petapoco.primarykey("employeeid")] public class employee { public int employeeid { get; set; } public string name { get; set; } public string gender { get; set; } public string city { get; set; } public int departmentid { get; set; } } department id foreign key coming table tbldepartment. want limit value of departmentid in creating new employee values existing in table tbldepartment(column : id ).how this? existing code in create view @html.editorfor(model => model.departmentid) usually reference integrity managed @ database level. make relationship on database between employees , departments enforce reference integrity, if try save employee department id don't exist on department table should return integrity error. capture error on saving controller , return user. also, if allow users load data limited list loaded existing data on dat...

php - Select data from the most recent row, with a particular ID -

i have database looks this: id | account_id | date_time | followers -------------------------------------------------------------- 1 | 1813 | 2014-11-16 09:31:52 | 1527 -------------------------------------------------------------- 2 | 1826 | 2014-11-16 09:31:52 | 900 -------------------------------------------------------------- 3 | 1854 | 2014-11-16 09:32:25 | 15342 -------------------------------------------------------------- 4 | 1813 | 2014-11-16 16:31:52 | 1539 -------------------------------------------------------------- 5 | 1826 | 2014-11-16 16:31:52 | 905 -------------------------------------------------------------- 6 | 1854 | 2014-11-16 15:32:25 | 15349 -------------------------------------------------------------- the database repeats same sort of entries twice-daily. each day there 2 new entries account_id 1813, 1...

Correct usage of C++ template template parameters -

i've trouble make use of template template parameters. here simplified example: template <typename t> struct foo { t t; }; template <template <class x> class t> struct bar { t<x> data; x x; }; int main() { bar<foo<int>> a; } the compiler (g++ (ubuntu 4.8.2-19ubuntu1) 4.8.2) reports following error: main.cpp:8:5: error: ‘x’ not declared in scope t<x> data; ^ main.cpp:8:6: error: template argument 1 invalid t<x> data; ^ any idea what's wrong? so make use of bar<foo<>> template <typename t = int> struct foo { t t; }; template <typename t> struct baz { t t; }; template <typename t> struct bar; template <template <typename> class t, typename x> struct bar<t<x>> { t<x> data; x x; }; int main() { bar<foo<>> a; bar<baz<float>> b; }

python - Pandas read_csv reading time offset strings -

i have text file data columns '10:15.3' meaning 10 minutes 15.3 seconds after canonical event. when read read_csv, i'm getting strings: >>> df.time.head() 0 08:32.0 1 08:38.0 2 08:39.0 3 08:43.0 4 09:15.0 name: time, dtype: object >>> df.time.head()[:1][0] '08:32.0' >>> i feel should able seconds enough within pandas, either specifying conversion in read_csv or (probably better, have both) appending new column, i'm not seeing how it. i'm pretty sure me being dense. can offer tip me unstuck? you can use datetime.time object. provide: hours, minutes, seconds, microseconds. these provided integers, need int cast relevant part of each string datetime.date constructor. so in case: import datetime df = pd.read_csv('your_csv.csv') df.time = pd.series([datetime.time(0, int(val[:2]), int(val[3:5]), int(val[6:])*100000) val in df.time], index = df.index)

MySQL Update with derived tables and ORDER BY -

this question follow question link . have table person (id) , 1 characteristic (var0) @ different timepoints t. @ timepoints characteristic missing , fill gaps former value. here example of table: +---+---+----+ +----+---+------+------+------------------+ |id | t |var0| | id | t | var0 | var1 | @prev_id := id | +---+---+----+ +----+---+------+------+------------------+ | 1 | 1 | | | 1 | 1 | | | 1 | | 1 | 3 | \n | | 1 | 3 | \n | | 1 | | 1 | 7 | \n | | 1 | 7 | \n | | 1 | | 1 | 8 | b | | 1 | 8 | b | b | 1 | | 1 | 9 | \n | | 1 | 9 | \n | b | 1 | | 2 | 2 | \n | | 2 | 2 | \n | \n | 2 | | 2 | 4 | u | | 2 | 4 | u | u | 2 | | 2 | 5 | u | | 2 | 5 | u | u | 2 | | 2 | 6 | \n | | 2 | 6 | ...

Android Facebook app open link in fb webview and I can't login into my own web app -

i have big problem android native facebook app webview browser. when i'm trying click on mine cta facebook login button (own website) - nothing happened. there's problem android webview, can't open facebook modal login window. i tried use target="_blank" open new window, thats not right way. is there solution fix it? thanks much, jacob. it's simple easy solution fix it. must have special own oauthserver comunicate api, , sent app credentials.