Posts

c - Why does this code using fork() work? -

i've code executes code depending of if active process parent or child process in infinite loop: pid_t childpid; childpid=fork(); while (1) { if (childpid >=0) { if (childpid==0) { [do child process stuff] } else { [do parent process stuff] } } else { printf("\n fork failed, quitting!!!!!\n"); return 1; } } code simple there's 1 big thing on me don't understand how happens although have guess: if not taking consideration we're creating 2 processes looks childpid being reasigned don't think makes sense. so guess, fork creates childpid each process, returning 0 parent process , pid child process, though syntax makes me think should return 1 result , assign chilpid. is guess correct or there other thing involved? thank you. so guess, fork creates childpid each process, returning 0 parent process , pid child pr...

java - android - viewpager OutOfMemoryError -

i have problem. want image url json , setting viewpager. tried drawable folder, large images causing problems. if image small, not have problem. how can large images? benefited article : enter link description here galleryactivity @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_gallery); viewpager viewpager = (viewpager)findviewbyid(r.id.viewpa); galleryadapter ga = new galleryadapter(this); viewpager.setadapter(ga); } gallery adapter (extending pageradapter) context context; private int[] galimages = new int[] { r.drawable.one, r.drawable.two, r.drawable.three }; galleryadapter(context context){ this.context=context; } @override public int getcount() { return galimages.length; } @override public boolean isviewfromobject(view view, object object) { return view == ((imageview) object); } @override public object instantiateitem(viewgr...

How to avoid prepending .self when using eval in a reference class in R? -

i need use eval call reference class method. below toy example: myclass <- setrefclass("myclass", fields = c("my_field"), methods = list( initialize = function(){ my_field <<- 3 }, hello = function(){ "hello" }, run = function(user_defined_text){ eval(parse(text = user_defined_text)) } ) ) p <- myclass$new() p$run("hello()") # error: not find function "hello" - doesn't work p$run(".self$hello()") # "hello" - works p$run("hello()") # "hello" - works?! p <- myclass$new() p$run("my_field") # 3 - no need add .self i guess eval(parse(text = paste0(".self$", user_defined_text))) , don't understand: why .self needed eval methods, not fields? why .self no longer needed after has been used once? 'why' questions challenging answer;...

ios - Objective-c: How to add borders to a UIView with auto layout -

how add border specific color , thickness uiview when using auto layout in objective-c ? this function add border specific color , thickness border of uiview - (void)addborder:(uiview *)view toedge:(uirectedge)edge withcolor:(uicolor *)color withthickness:(float)thickness{ uiview *border = [uiview new]; border.backgroundcolor = color; [border setautoresizingmask:uiviewautoresizingflexiblewidth | uiviewautoresizingflexiblebottommargin]; switch (edge) { case uirectedgetop: border.frame = cgrectmake(0, 0, view.frame.size.width, thickness); break; case uirectedgebottom: border.frame = cgrectmake(0, view.frame.size.height - thickness, view.frame.size.width, thickness); break; case uirectedgeleft: border.frame = cgrectmake(0, 0, thickness, view.frame.size.height); break; case uirectedgeright: border.frame = cgrectmake(view.frame.size.width - thick...

jquery - Resorting the active bootstrap tab when stacked -

Image
for new bootstrap website i'm working on, sorting active tab when nav-tab stacks, selected tab connected tab-pane. while works, feels hack me. there better way accomplish preserves original tab order? html markup: <div id="tab-bundle" class="container-fluid"> @html.hiddenfor(model => model.selectedbundle) <ul class="nav nav-tabs" id="coveragetabs"> <li><a href="#minimum">@languagedb.me.minimum</a></li> <li><a href="#better">@languagedb.me.better</a></li> <li><a href="#best">@languagedb.me.best</a></li> <li><a href="#custom">@languagedb.me.custom</a></li> </ul> <div class="tab-content"> <div class="tab-pane active bg-info" id="ajaxpanel"> @html.partial("selectedb...

Is there a way I can update my Meteor app without wiping my MongoDB on the production server? -

i'm installing ssl certificate , need run mupx setup , mupx deploy work. however, doing , deploying app wipe mongodb on production server , users lose of accounts. nightmare. i run mupx deploy after making fixed meteor app update app. however, when installing ssl certificate (according mup documentation) have run mupx setup work. is there way can without wiping user database on deployment server?

web services - Host web UI with executable application? -

this may stupid question have spent 5 hours doing research on web , found nothing clarify doubts. in few words have been asked possible employer develop executable application part of "technical test". supposedly they're measuring expertise working wcf. given 2 days develop such app , information following: deliverable:                 - executable that                                 * when app ran, should host wcf service (service) web ui (ui) accessible web browsers.                                 * through ui, user should able add or delete messages stored in database (db).                                 * ui should display current list of messages stored in db.                                 * if changes made db, changes should show in ui without need reload page.                 - of project source code.                 additional notes: use of existing libraries allowed long r...