Posts

Showing posts from March, 2013

perl - error when installing bugzilla - You must install Linux::Pid -

i followed guide in order install bugzilla on apache2 server: http://www.bugzilla.org/docs/4.4/en/html/configuration.html i installed modules , configured files. went until section: 2.2.4.1.2. apache httpd™ mod_perl i needed add lines in apache2.conf: perlswitches -w -t perlconfigrequire /var/www/html/bugzilla/mod_perl.pl when trying finish process restarting apache, error: you must install linux::pid apache::sizelimit work on platform....... i searched on web solution coudn't find instruction how install or solve in way.. please help p.s. this exception: syntax error on line 95 of /etc/apache2/apache2.conf: must install linux::pid apache::sizelimit work on platform. @ /usr/local/lib/perl/5.14.2/apache/sizelimit/core.pm line 128.\nbegin failed--compilation aborted @ /usr/local/lib/perl/5.14.2/apache/sizelimit/core.pm line 171.\ncompilation failed in require @ /usr/local/lib/perl/5.14.2/apache2/sizelimit.pm line 48.\nbegin failed--compilation aborted @ /usr/

scala - Map versus FlatMap on String -

listening collections lecture functional programming principles in scala , saw example: scala> val s = "hello world" scala> s.flatmap(c => ("." + c)) // prepend each element period res5: string = .h.e.l.l.o. .w.o.r.l.d then, curious why mr. odersky didn't use map here. but, when tried map, got different result expected. scala> s.map(c => ("." + c)) res8: scala.collection.immutable.indexedseq[string] = vector(.h, .e, .l, .l, .o, ". ", .w, .o, .r, .l, i expected above call return string, since i'm map -ing, i.e. applying function each item in "sequence," , returning new "sequence." however, perform map rather flatmap list[string] : scala> val slist = s.tolist slist: list[char] = list(h, e, l, l, o, , w, o, r, l, d) scala> slist.map(c => "." + c) res9: list[string] = list(.h, .e, .l, .l, .o, ". ",

java - Accessing variables and getting null value -

i'm working on class has inner classes. these classes public , variable passed on other class declared public also. problem whenever, try access example inner class named public class classx and needing variable public int position . inside inner class classx there method calculating position, , in inner class public class classy , wanted display current value of position whenever tried access position classx null?how happen? by way, aware of using instantiate , using constructor. tried set reset value. here sample code: public class mainclass { public static class subclass1 { public int position,x,y; } public class subclass2 { private subclass1 s; public void methodcalculate() { s = new subclass1(); s.position = s.x + sy; } } public class subclass3 { private subclass1 s; public void displaymethod() {

ruby on rails - RoR, how does a "onclick event" work on "check_box_tag" -

i working on application using rails 4. in page, have checkbox want store in user session hash. following code: # show.html.erb ... <%= check_box_tag "", "", staytuned_get(some_id), onclick: staytuned_swap(some_id) %> ... # myhelper.rb def staytuned_get(some_id) session["staytuned_#{some_id}"] || false end def staytuned_swap(some_id) session["staytuned_#{some_id}"] != session["staytuned_#{some_id}"] end staytuned_get returns false if "staytuned_#{some_id}" not set or false. otherwise, returns true. staytuned_swap swaps boolean session variable (from true false , vice versa). unfortunately, session["staytuned_#{some_id}"] false, after click , refresh. can solve this, thank you. this not how works in browser. when onclick: staytuned_swap(someid) , calls function, return false (a variable equal ...) , use onclick attribute. want javascript doing ajax on click.

ios - undefined method `initWithNibName' -

i have started learning ios development rubymotion , i'm doing tutorial . seems pretty easy understand, right i'm stuck error when run rake command: colorcontroller.rb:7:in `initwithcolor:': undefined method `initwithnibname' #<colorcontroller:0x9b4f470> (nomethoderror) searchcontroller.rb:46:in `open_color:' color.rb:35:in `block in find:' query.rb:358:in `call_delegator_with_response' query.rb:128:in `connectiondidfinishloading:' i got part whew ton of code isn't it. found on tutorial page , i'm stuck there. code looks like: # app_delegate.rb class appdelegate def application(application, didfinishlaunchingwithoptions:launchoptions) @window = uiwindow.alloc.initwithframe(uiscreen.mainscreen.bounds) @search_controller = searchcontroller.alloc.initwithnibname(nil, bundle: nil) @navigation_controller = uinavigationcontroller.alloc.initwithrootviewcontroller(@search_controller) @window.rootviewc

syntax error - Scheme notation for "and" conditional -

for sicp course learning scheme , had assignment asked check if point in axis-aligned rectangular. did this: (define in-rect? (lambda (px py rx1 ry1 rx2 ry2) (<= (* (- px rx1) (- px rx2)) 0) , (<= (* (- py ry1) (- py ry2)) 0))) i did according previous c habits , forgot polish notation while there. interpreter our online tutor program uses runs code "correctly", intended. however, afaik, usage of 'and' should syntactically wrong. drracket points out syntax error when try run this. then how did evaluate correct values every test case on online tutor? option valid maybe? the syntax and same expression - uses prefix notation; can have 0 or more arguments, don't have boolean expressions: (and <exp1> <exp2> <exp3> ...) for code should follows: (define in-rect? (lambda (px py rx1 ry1 rx2 ry2) (and (<= (* (- px rx1) (- px rx2)) 0) (<= (* (- py ry1) (- py ry2)) 0)))) as why code seemed w

architecture - How does realtime text analysis happen -

i have been doing reading on topic not able find right information, have been using services twitter streaming, datasift , other data push service. wanted understand how following services work, the number of tweets received per second high. a number of people connect specify keywords want receive tweets for, these can complex boolean queries. realtime checking of tweets against these boolean queries , streaming data right connection. any pointer towards kind of architecture being used helpful. i think first need understand magnitude , resources of services twitter trying create understanding of!! performance can handled managing taking care of both below mentioned fronts. imagine multi-tiered eco-system load balancers, multiple web-servers , large data centres distributed caching!! irrespective of complexity of algorithm performance can managed making algorithms multi-threaded!! if want understand try reading map-reduce, hadoop etc idea

Amazon s3 storage video takes long time to load -

good day. please have website want develope. video viewing website sharing local drama viewers. each darama of average of 1:10:00 duration . problem , tried hosting videos on amazon, video takes long time start streaming. around 20 min sometimes. confused , not sutre problem is? using joomla video, template using accept .mp4 videos , kind of difficult me. not sure if there better cms site?. appreciate recommendation. also hosting video, amazon s3 better choice or there other means? checking on vimeo pro , not sure if trick? my site http://hantsitv.com/ s3 great storing video, want use amazon cloudfront streaming since optimized content delivery.

c++ - OpenGL code Works in Windows but not Mac -

Image
my school uses windows computers have mac @ home. code runs fine in windows reason errors running in xcode. wasn't sure frameworks include added glkit, cocoa, glut, , opengl. missing something?? xcode setup can work on homework same code work on windows. here code #include <stdio.h> #include <stdarg.h> #include <math.h> #define gl_glext_prototypes #ifdef __apple__ #include <glut/glut.h> #else #include <gl/glut.h> #endif #define glut_key_escape 27 const glsizei windowwidth = 500; const glsizei windowheight = 500; glfloat cuberotatex = 45.0f; glfloat cuberotatey = 45.0f; bool keys[255]; glvoid establishprojectionmatrix(glsizei width, glsizei height) { glviewport(0, 0, width, height); glmatrixmode(gl_projection); glloadidentity(); gluperspective(45.0f, (glfloat)width / (glfloat)height, 0.1f, 200.0f); } glvoid initgl(glsizei width, glsizei height) { establishprojectionmatrix(width, height); glshademodel(gl_smo

android - Batch contextual action mode -

i want enable multiple view selection on longclick(). should declare action mode object , call startactionmode()? also, how change menu list single item click? used documentation reference, shown. listview listview = getlistview(); listview.setchoicemode(listview.choice_mode_multiple_modal); listview.setmultichoicemodelistener(new multichoicemodelistener() { @override public void onitemcheckedstatechanged(actionmode mode, int position, long id, boolean checked) { // here can when items selected/de-selected, // such update title in cab } @override public boolean onactionitemclicked(actionmode mode, menuitem item) { // respond clicks on actions in cab switch (item.getitemid()) { case r.id.menu_delete: deleteselecteditems(); mode.finish(); // action picked, close cab return true; default: return false; } } @override public boolean oncreateactionmod

c++ - Homework help: prime numbers -

i'm trying make bool isprime function creates list of prime numbers covering user-input integer, linearly search through list , return true if input integer in list. i'm having problem, however, figuring out how make list covers input integer (that is, if user inputs 4, list must have 2,3, , 5). here code have far (i know it's wrong, i've tried doing research can't figure out how this. bool isprime(int n){ int i,tprime=3; list<int>prime; prime.push_back(2); list<int>::iterator it; (it=prime.begin();it!=prime.end();it++){ if (*it<n){ while (i<sqrt(tprime)){ if(n%i!=0){ if(i<sqrt(tprime)) i++; else prime.push_back(tprime); } tprime++; } } } (it=prime.begin();it!=prime.end();it++){ if (*it==n) return true; } return false; } can guys give me hints on how make work? can figure out linear search. you got list

function to remove class of a selected item using jquery -

look code , see if guys can me with. html <div class="images_list"> <ul> <li class="border" title="content_1"><img src="http://localhost/freedownload/admin/upload/923411_481490901920862_1216973581_n.jpg" width="150" /><span></span></li> <li class="border" title="content_2"><img src="http://localhost/freedownload/admin/upload/923411_481490901920862_1216973581_n.jpg" width="150" /><span></span></li> </ul> </div> css .images_list li { list-style: none; float: left; width: 150px; height: 150px; margin-right: 10px; } .images_list li span { display: none; position: absolute; top: -10px; left: 128px; width: 32px; height: 32px; background: url(../upload/check.png); } .images_list li span:hover { background: url(../upload/uncheck.png); } .images_lis

javascript - executing code in address bar -

i saw in few places can execute code using address bar, test out typed in javascript:alert("hello"); , pressed [enter] yet nothing happens. i have tried code else wrote here. javascript:(function%20nomify(){var %20shapes={"w_rect":["cookiemonstercrumbypicturesopen-o.gif","tumblr_mohxt1v6a91svhqpoo1_500.gif","tumblr_md0q05wmjb1rxis0k.gif","tumblr_ml0nmjwpx41snjjivo1_500.gif","cookie4.gif"], "t_rect":["cookiemonster-sitting.jpg","487961_10150955894571587_1215263686_n.jpg","534767_10151516100086587_1790492047_n.jpg","patientmonster.png"], "square":["cookie_monster.jpg","935823_10151502554911587_1547641144_n.jpg","902502_10151355606796587_45192127_o.jpg","cookie-monster.jpg"]}, img_path="http://downloads.cdn.sesame.org/sw/omnomnomify/";function%20chooseimg(shape){return%20img_path+shapes[shape] [math.fl

c++ - how to delete the buttons "one page", "two pages" ... "six pages" in printpreviewdialog? -

Image
i want know how delete buttons "one page", "two pages", etc, , "page" in printpreviewdialog? use c++ windows forms visual studio 2012. thanks printpreviewdialog boilerplate implementation of dialog uses printpreviewcontrol. supposed implement own dialog if want own design. nevertheless, can messed in .net. these buttons private members of class can't access them in own code. reflection support in .net provides backdoor, can private fields bindingflags::nonpublic. make similar (using default names): using namespace system::reflection; ... form1(void) { initializecomponent(); array<string^>^ names = gcnew array<string^> {"onepagetoolstripbutton", "twopagestoolstripbutton", "threepagestoolstripbutton", "fourpagestoolstripbutton", "sixpagestoolstripbutton", "separatortoolstripseparator1"}; (int

concurrency - Is this a good design for implementing the java synchronized keyword as an object? -

just practice wanted implement java synchronized keyword java object. code below design this? guess atomicreference have similar performance atomicboolean? updated code after suggestions: public class synchronizedblock implements runnable{ private final lock lock; private final runnable runnable; public synchronizedblock(runnable r, lock l){ runnable = r; lock = l; } public void run() { try { while(!lock.compareandset(false, true)){ thread.sleep(100); } runnable.run(); } catch (interruptedexception e) { e.printstacktrace(); } { lock.unlock(); } } } public class lock { private final atomicreference<boolean> locked = new atomicreference<boolean>(false); public boolean compareandset(boolean expected, boolean update){ return locked.compareandset(expected, update); } public boolean islocked(){ return locked.get(); } public void unlock(){ locked.set(false); } } @test publ

iphone - Table View Group Header View -

Image
i want create effect similar open table application. want section header stick top scroll table. of course default behavior plain table view, because of style, want group table view. any ideas or suggestions? one way (i'd wager opentable way) use plain table style dress cells grouped. you'd need 3 background images cells, 1 first cell in section (with rounded upper corners), 1 last row in section (with rounded lower corners), , 1 others looks grouped cells (with left , right insets).

Parsing ISC files with python (dhcpd.conf) - iscpy module -

what best way parse dhcpd.conf file looks like? ddns-update-style none; authoritative; option domain-name "example.org" option domain-name-servers ns1.example.org, ns2.example.org subnet 172.16.31.0 netmask 255.255.255.0 { # default gateway option routers 172.16.31.10; option subnet-mask 255.255.255.0; option domain-name "aaaaaa"; option domain-name-servers 172.16.31.10; #option nis-domain "domain.org"; range dynamic-bootp 172.16.31.80 172.16.31.90; default-lease-time 21600; max-lease-time 43200; host test { hardware ethernet 00:23:8b:42:3f:d1; fixed-address 172.16.31.3; } } i tried iscpy module: a = iscpy.parseiscstring(open('dhcpd.conf', 'r').read()) that module makes dictionary option key , string next option value of dict. isn't works if options looks like: option domain-name "example.org" option domain-name-servers ns1.example.org, ns2.example

HTML PHP form with multiple fields -

Image
i have html form 5 rows , 30 fields. note attached image. i have capture of these fields in array later convert csv file. each field labelled @ follows: qt1, fa1, en1, et1, ba1, qt2, fa2, etc... instead of taking each row , adding them array in php 1 @ time there easy(ier) way accomplish this? i can take each row , add them array issue feel speed of script , fact have write 30 lines of array data in php script. is looking for? <?php for($i = 0; $i < 30; $i++): ?> <input name="qt[<?php echo $i; ?>]"/> <input name="fa[<?php echo $i; ?>]"/> <input name="en[<?php echo $i; ?>]"/> <input name="et[<?php echo $i; ?>]"/> <input name="ba[<?php echo $i; ?>]"/> <?php endfor; ?> on server side, receive data in $_post variable anyways, in array regardless. has advantage of saving values of same row same index , same data types under 1 a

android - how to get two diffrent url in backgound task -

below code have 1 url in backgroundtask , string on postexecute in senario have 2 http connection do? please me url1 , url2 hwo both work onbackground parrllel???? public class thetask extends asynctask<void, string, string> { @override protected void onpreexecute() { super.onpreexecute(); } @override protected string doinbackground(void... arg0) { try { string query = urlencoder.encode("american%20cheese%20burger", "utf-8"); string url = "http://198.57.208.46/xyz"; log.i("url",""+url); httpclient client = new defaulthttpclient(); httpget request = new httpget(url); httpresponse response = client.execute(request); httpentity resentity = response.getentity(); _response=entityutils.tostring(resentity); }catch(exception e) { e.printstacktrace(); } return _response;

javascript collapse table cookie -

i came script collapse table <script type="text/javascript"> var rowvisible = true; function toggledisplay(tbl) { var tblrows = tbl.rows; (i = 0; < tblrows.length; i++) { if (tblrows[i].classname != "headerrow") { tblrows[i].style.display = (rowvisible) ? "none" : ""; } } rowvisible = !rowvisible; } </script> <div class="datagrid"><table id="thread_1"> <thead><tr class="headerrow"> <th width="100"><a href="#" onclick="toggledisplay(document.getelementbyid('thread_1'))" style="color: white">slo</a></th> it works fine problem want save state when person leaves website. guess easiest way cookie. haven't done before. how can that? if don't need support, let ie7 can use browser localstorage. // our flag determine if rows hidden or not va

c++ - Sort Array but keep row indexes -

i have array this: names, state, houseprice, carsprice john, wi, 200, 100 jimmy, mi, 100, 90 ... how sort houseprice , car price without changing elements in same row? sort whole row of "john" based on houseprice , carprice against row in array keep in row together. this have far, for (int i=0;getline(file,(names[i]),',');i++) { getline(file, states[i], ','); getline(file, houseprice[i], ',') ; getline(file, carprice[i]); } how want sort houseprice , carprice against row without losing name , states along row. just project field interested in part of comparison function object otherwise treat objects 1 unit: house array[] = { ... }; // sort houseprice; similar other attributes: std::sort(std::begin(array), std::end(array), [](house const& h0, house const& h1) { return h0.houseprice < h1.houseprice; });

razor - ASP.NET MVC : Generating multi level menu using recursive helpers -

i using code generating menu, menu populates items database (category table) using this technique partial view : @using sarbarzdarb.helper @model ienumerable<sarbarzdarb.models.entities.category> @showtree(model) @helper showtree(ienumerable<sarbarzdarb.models.entities.category> categories) { foreach (var item in categories) { <li class="@(item.parentid == null && item.children.any() ? "dropdown-submenu" : "")"> @html.actionlink(item.name, actionname: "category", controllername: "product", routevalues: new { id = item.id, productname = item.name.toseourl() }, htmlattributes: null) @if (item.children.any()) { showtree(item.children); } </li> } } also i'm passing model controller above partial view way : public ilist<category> getall() { r

What do the methods do in this Java program? -

i'm confused methods exactly, hoping explain concept me example program: import java.io.*; import java.util.*; public class programb { public static void main(string[] args) throws ioexception { string filename; string total=""; string c = ""; string size = ""; int num1=0, num2=0; char ch; scanner keyboard = new scanner(system.in); system.out.println("enter name of file want read data from:"); filename=keyboard.next(); scanner fromfile = new scanner(new filereader(filename)); while (fromfile.hasnext()) { string type = fromfile.next(); ch = fromfile.next().charat(0); num1 = fromfile.nextint(); if (type.equals("rectangle")) { num2 = fromfile.nextint(); } system.out.print(type + " "); system.out.print(ch + " "); system.out.print(num1 + " ")

access denied - Using SIGAR to get oracle process info, from a web app server (glassfish4) -

i have been working on web monitor using sigar gather system information, need oracle's ram , cpu usage. did using sigar.getproccpu(pid).gettotal() function. but when deploy app on glassfish 4, error message: org.hyperic.sigar.sigarpermissiondeniedexception: access denied. is there walkaround this? can give sigar access info im requesting? i got exact same problem yours. found post after asked my question , find answer. , here's answer own question: the os not allow program access process information until run program admin privilege, need provide admin privilege. there methods provide admin privilege, including ask user right click on icon , select "run administrator". but better way might wrapping java application in .exe here , here said. however, have hack os excowboy said here want show information on web page , can't wrapping app in .exe file. i think have give up. put these links may need it. :) oh, total

c++ - Center bitmap text to a rectangle with OpenGL -

i need center piece of text rectangle. i found example , i'm struggling understand does. it not hard achieve this, need know how find width , height of text after being drawn, cannot find anywhere. to draw text, char char: static void drawtext(std::string str, float x, float y, float z) { glrasterpos3f(x, y, z); (unsigned int = 0; < str.size(); i++) { glutbitmapcharacter(glut_bitmap_helvetica_18, str[i]); } } not sure if best way, first program using opengl. raster fonts awful, not work in modern opengl know - need use texture-mapped triangles implement bitmap fonts now-a-days. if starting out, legacy opengl may work you, find things raster pos not supported in opengl es , core opengl 3+. that said can sum glutbitmapwidth (...) across of characters in string, this: unsigned int str_pel_width = 0; const unsigned int str_len = str.size (); // finding string length can expensive depending on implementation (e.g. in // c

Clean database before executing a test in .NET -

scenario we're working on set of integration tests make use of application database. purpose switched database separate test database that's used during integration tests. the test database reset after each test it's original state, restoring sql server database snapshot. works okay, it's given quit headache set up. question are there tools make cleaning database before or after automated test easier? we using mstest our test framework, i'm open suggestions require different test framework database cleaning tool work.

javascript - Dropdown menu dynamically populates a second dropdown -

i had code first dropdown menu dynamically populates second dropdown menu using php , jquery. the code used $('#first_choice').change(...) and inside function getter.php file loaded data database second menu using first choice value, so: $first_choice=$("#second-choice").load( "getter.php?choice=" + $("#first-choice").val() ); this php page json encoded. inside change function there .get() function having url of select menu php page, function(data) append second menu's's options , format "json" last parameter. change function called once change second menu when first menu clicked. remember .ajax parameter false. example ajax second dropdown menu change when first dropdown menu change: <!doctype html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-1.9.1.min.js"></script> <script> $(functi

Find a key in a python dictionary and return its parents -

i have nested dictionary has list of folders, 1 2013_09_10 root folder: {'2013_09_10': {'master.tex': none, 'master.log': none, 'master.pdf': none, 'makefile': none, 'pieces': {'rastin.tex': none, '02 human information processing.txt': none, 'p1.tex': none, 'p3.tex': none, '03 models , metaphors.txt': none, 'p2.tex': none}, 'master.aux': none, 'front_matter.tex': none}} what i' trying accomplish is, given name of file (for example p1.tex), print actual path of file 2013_09_10/pieces/p1.tex i've created piece of code gives me names of files, not parent keys (directiory): def get_files(directory): filename in directory.keys(): if not isinstance(directory[filename], dict): print filename else: get_files(directory[filename]) output: master.tex master.log master.pdf makefile rastin.tex 02 human information proc

C++ string to char conversion -

i have function requires parameter of type 'unsigned char'. if use: unsigned char x[8] = "a\0ab-cd"; and pass 'x' parameter function call, desired result. however, inputs rwcstrings, , not char type variable. in case, have : rwcstring a1 = "a"; rwcstring b1 = "ab-cd"; i try concatenate using : rwcstring final = a1 + "\0" + b1; and try using conversion inside function call (unsigned char*) final.data(); however, produces different result called function. what doing wrong here ? when doing a1 + "\0" operation, sourcepro evaluates "\0" string length = 0, returning a1. the documentation += operator notes operator doesn't support strings embedded nulls.

ruby - Get Post Full Path in Jekyll/Octopress -

in octopress, i'm trying post's full file path (something ~/projects/site/source/_posts/2012-01-01-something.markdown ) extending jekyll:post class. module jekyll class post alias_method :original_to_liquid, :to_liquid def to_liquid # test if function called puts "hello" original_to_liquid.deep_merge({ 'full_path' => file.join(@base,@name) }) end end end i name file full_path.rb , put in plugins folder. oddly, to_liquid function never called, since hello message didn't show up. even more strange, find date.rb shipped octopress defines to_liquid method of class post , add full_path => file.join(@base,@name) line there , works! i'm soooo confused. so question is, why to_liquid method didn't called? update after upgrading jekyll 0.12.0 1.2.1, magically works...... you might take @ post#permalink documentation . shou

c++ - Does QT use managed code? -

i have been looking @ qt , seeing how ideal code with: code once, deploy everywhere, , drag , drop. ( scratch , grown ups :d) anyway, managed, unmanaged, or c++/cli standard qt form? used native/unmanaged c++ code, , msvc c++ made more complex needed be, , deploy 1 platform. however, being oldschool c++ coder, decided against using qt if had learn managed code too. realize might have learn managed someday, if can avoid it save me lots of time. qt cross-platform application , ui framework developers using c++ or qml, css & javascript language. qt creator supporting qt ide. you use common c++ syntax code qt + make use of course of qt classes, qt macros , qt meta-call mechanism, still c++. qt doesn't depend on c++/cli or other proprietary frameworks.

Check if element found in array c++ -

how can check if array has element i'm looking for? in java, this: foo someobject = new foo(someparameter); foo foo; //search through foo[] arr for(int = 0; < arr.length; i++){ if arr[i].equals(someobject) foo = arr[i]; } if (foo == null) system.out.println("not found!"); else system.out.println("found!"); but in c++ don't think i'm allowed search if object null c++ solution? in c++ use std::find , , check if resultant pointer points end of range, this: foo array[10]; ... // init array here foo *foo = std::find(std::begin(array), std::end(array), someobject); // when element not found, std::find returns end of range if (foo != std::end(array)) { cerr << "found @ position " << std::distance(array, foo) << endl; } else { cerr << "not found" << endl; }

ios - How to halt concurrent OpenGL drawing during app backgrounding? -

as app goes background must stop calling opengl functions. somehow efforts stop opengl fail , app (but not always) crashes when user presses home button. it crashes exception type: exc_bad_access code: kern_invalid_address @ 0x1 libgpusupportmercury.dylib gpus_returnnotpermittedkillclient to understanding if call opengl functions after app not in foreground anymore app crash because gpu not available app. the view renders opengl has dispatch queue self.drawingqueue = dispatch_queue_create("openglrenderqueue", dispatch_queue_serial); it has render in parallel uiscrollview. there gcd semaphore let queue wait uiscrollview. self.rendersemaphore = dispatch_semaphore_create(1); i create cadisplaylink update runloop: cadisplaylink *dl = [[uiscreen mainscreen] displaylinkwithtarget:self selector:@selector(update)]; [dl addtorunloop:[nsrunloop currentrunloop] formode:nsrunloopcommonmodes]; self.displaylink = displaylink; the update method performs d

How to do lock in javascript -

i have function called addelementtodom() in javascript, runs loop on array , adds elements 's dom (many of them, takes long time). function being called different events. want make sure every call function waiting previous call finish function before starting addelementtodom. idea doing lock() in c#. couldn't find 1 in javascript. best way implement lock ? javascript single-threaded don't have concurrency issues. hence, no locks. locks meant resolve concurrency problems. you might still want logic though, "operation foo shouldn't run until operation bar completed." like: var operationbariscompleted = false; function foo() { if(!operationbariscompleted) { return; } // ... } function bar() { // ... operationbariscompleted = true; } but i'm writing programming logic you. however if event-driven need learn work asynchronous code , callbacks. can't teach on answer; plenty of resources on google , stackoverf

html - Search Focus and Out -

so making search bar , wondering how make when click in search bar shows different image , when click out goes old image css /***** search form *****/ #search-form { padding:45px 10px 0 0; float:right; } #search-form fieldset { position:relative; width:100%; display:block; overflow:hidden; } #search-form .search-field { float:right; width:300px; height:34px; background:url(../images/search-bg.jpg) 0 0 no-repeat; } #search-form input { width:245px; font-size:14px; line-height:1.25em; padding:9px 15px 9px; font-family:arial, helvetica, sans-serif; background:none; border:none; margin:0; outline:none; } #search-form .search-button { display:block; width:20px; height:21px; text-indent:-5000px; background:url(../images/search-icon.png) left top no-repeat; position:absolute; right:7px; top:7px; } html <form id="search-form" method="post" enctyp

android - Eclipse Error when booting up - "Error when loading the SDK" -

i'm trying simple android application running. every time boot eclipse, following error: [2013-10-06 20:26:06 - android sdk] error when loading sdk: error: error parsing /android-sdk-macosx/tools/lib/devices.xml cvc-elt.1: cannot find declaration of element 'd:layout-devices'. i've had no success in fixing this. need fix before moving on?

c - How do I get my array to return an int array to be used in another function? -

i need function drop_balls return array can make next function use array. need take in integer parameter, , return int array can used in function making after. have been reading can passed pointer, have absolutely no idea how coded, can please me out. #include <stdio.h> #include <stdlib.h> #include <time.h> /* prototype drop_balls, int parameter number of balls being dropped */ int [] drop_balls(int); /* gets number of balls need dropped user */ int get_num_balls(); int main() { drop_balls(get_num_balls()); } int get_num_balls() { int num_balls; printf("how many balls should dropped? "); scanf("%d", &num_balls); /* ensure atleast 1 ball */ while(num_balls <= 0) { printf("you have drop @ least 1 ball! \n "); printf("how many balls should dropped? "); scanf("%d", &num_balls); } /* return number of balls dropped */ return num_balls;

c++ - Who should own the pointer -

while programming, many times i've come across following design choice: user creates object , passes other object processes in way in second stage. as example, imagine raytracer. user creates sphere properties , calls raytracer.addtraceable(sphere) . now, there 3 ways can think of doing this. the raytracer becomes responsible of deallocating memory allocated sphere object the user needs deallocate memory allocated sphere object. the raytracer copies sphere object , both user , raytracer deallocate local copy. generally best design choice in such case? there other options besides ones mentioned (not including smart pointers)? ps: i've come across same problem in plain c when using object oriented approach. the consistent use of raii makes moot point. using smart pointer such std::shared_ptr object owned all of pointers , deleted after last pointer destroyed. c doesn't have convenient way express raii idiom.

constants - ?define macro or .hrl file alternate in Elixir for configuration purpose -

in erlang can use define macro or .hrl file keep configuration @ 1 place. whats best place in elixir. i couldn't find elegant way of doing it. right doing like:- def get_server_name "test" end am missing something? whether use functions or macros should matter in end, if you're looking "keeping in 1 place" part, i'd suggest putting in own namespace/module defmodule myapp.configuration def server_name "foo" end # or if prefer having on 1 line def host_name, do: "example.com" # complete equivalency, can use macro defmacro other_config "some value" end end and in app, instead of including file, can alias module have short prefix indicate it's configuration, , indicate come elsewhere defmodule myapp.server alias myapp.configuration, as: c end or if want use names directly defmodule myapp.server import myapp.configuration end

java - How do I correctly get the largest and smallest numbers in a sequence of numbers? -

i'm supposed smallest , largest number out of sequence of numbers. know method body each method not right. help? public class dataset { private int sum; private int count; private int largest; private int smallest; public dataset() { sum = 0; count = 0; largest = 0; smallest = 0; } public void addvalue(int x) { sum = sum + x; count++; } public int getsum() { return sum; } public double getaverage() { double average = sum/count; return average; } public int getlargest() { int largest = integer.max_value;//not giving right answer, don't know how use return largest; } public int getsmallest() { int smallest = integer.min_value;//not giving right answer, don't know how use return smallest; } } here tester class if needed, although don't think problem lies here. public class datasettester { public static void main(string[] args) { dataset mydata = new dataset(); myd

Coin Flip Grouping Results (C#) -

i having trouble assignment have, after displaying results of coin flip program, typically like: (this c# way) heads tails tails tails etc. i have group them in rows. example, if name group(10, 4), 10 mean total flips of "coin" , 4 how results grouped: heads tails tails tails tails heads tails tails heads heads i'm confused whether in flips() should in groups() along loop manipulate sorting of results? or totally separate? i'm stumped on how begin.. sorry, appreciated! using system; namespace heads_tails { class mainclass { static void main() { (int v = 0; v <= 10; v++) flip (); } static void flip() { int lo, hi, n; random r = new random (); lo = 0; hi = 2; n = r.next(lo, hi); if (n == 1) { console.writeline ("heads"); } else { console.writeline ("tails"); } } } } here's hint

iphone - EAAccessory protocolstrings issue -

i trying connect iphone custom bluetooth device. , following eademo. running app, not getting null in protocolstrings . whereas, object when debug app. insight on why happens? could timing problem? its being inconsistent... it problem device itself. there no issue code. thanks.

css - reset float after second column -

i have following layout: html: <div class="test"> <div class="a"> test</div><div class="b">test2</div> <div class="a"> test</div><div class="b">test2</div> <div class="a"> test</div><div class="b">test2</div> <div class="a"> test</div><div class="b">test2</div> <div class="a"> test</div><div class="b">test2</div> <div class="a"> test</div><div class="b">test2</div> </div> css: .test .a,.test .b { float: left; width: 100px; } .test .a:nth-child(4n+1) , .test .b:nth-child(4n+2) { background: lightgreen; } .test .b:after { clear: both; display: block; content: "\a"; } it not reset float after .b ; what tried acheive 2 column list test test2 te

eclipse - IBM Worklight - How do I tell if Worklight Studio is running v6.0.0.0 or v6.0.0.1? -

Image
when navigate link upgrade worklight studio tech note ( http://www-01.ibm.com/support/docview.wss?uid=swg27039574 ) sends me series of pages , end here ( http://www.ibm.com/developerworks/mobile/worklight/download/install.html ) instructs me use eclipse market place. i have done this, can't see states have upgraded v6.0.0.1 details in eclipse still indicate 6.0.0.0. yes, it's not clear right now... if navigate in eclipse either help > eclipse or help > install new software... > installed see there full version number, , include build date. if build date recent, that's v6.0.0.1. 6.0.0.20130926-1933 == worklight 6.0.0.x(1...) september 26th 2013 @ 19:33. this clearer in future releases of ibm worklight. also, here: http://www-01.ibm.com/support/docview.wss?uid=swg27039574 says "fix pack 1", refers v6.0.0.1 well.

php - file_get_contents adding extra /\ slashes -

i'm tesitng callback , it's adding unnecessary slashes impeding upon api's ability successfuly communicate server. why appending these slashes , how can remedy situation? code below: <?php $real_secret = 'cantletyousee'; $my_address = '16qvmcfj6eergwquixlqhucbc2bzzdpmfo'; $my_callback_url = 'http://myurlcantseeit.me/gg/blockchain_callback.php?secret=' . $real_secret; $root_url = 'https://blockchain.info/api/receive'; $parameters = 'method=create&callback='. urlencode($my_callback_url) . '&address=' . $my_address; $response = file_get_contents($root_url . '?' . $parameters); var_dump($response); $object = json_decode($response); ?> the var dump returning: string(203) "{"input_address":"1mtyhcdeq1euiv7pjl58xtjfwtgx3bqqpe","callback_url":"http:\/\/myurlcantseeit.me\/gg\/blockchain_callback.php?secret=cantletyousee","fee_percent":0,"

objective c - Open my Own Mac App Preferences -

Image
i newbie in cocoa application. want programmatically open application's preferences window by googling, can found --> [[nsworkspace sharedworkspace] openfile:@"myapp.prefpane"];" any appreciated.--- thanks. you open preference window other within app: in app delegate class: - (ibaction)showpreferencepanel:(id)sender { if (!_preferencecontroller) _preferencecontroller = [[preferencecontroller alloc] init]; [_preferencecontroller showwindow:self]; } where preferencecontroller is: @interface preferencecontroller : nswindowcontroller <nswindowdelegate, nstoolbardelegate, fontchooserviewdelegate> ... @end and in mainmenu.xib showpreferencepanel method hooked in this:

jsp - resource not available in struts2 -

i new struts have developed first struts application using struts 2.3.15 , apache 7.0.42 when running following code saying requested resource not available my code snippets are: struts.xml <?xml version="1.0" encoding="utf-8"?> <!doctype struts public "-//apache software foundation//dtd struts configuration 2.3//en" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="default" namespace="/" extends="structs-default"> <action name="gettutorial" class="org.shekhar.javabrains.action.tutorialaction"> <result name="success">/success.jsp</result> <result name="failure">/error.jsp</result> </action> </package> </struts> web.xml <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xml

How to let users download a file with data stored in an array (CSV/Node.js)? -

how allow users download array has stored list of objects csv without using express or additional libraries? this have tried not sure stick infront of res.setheader - , want try prompt user if want download it. var filename = 'music' + new date() + '.csv'; res.setheader('content-disposition', 'attachment; filename=' + filename); you can use http package bundled nodejs var http = require('http'); var options = { host: 'localhost', port: 80, path: '/download', method: 'post' }; var req = http.request(options, function(res) { res.setheader('content-type', 'text/csv'); res.setheader('content-disposition', 'attachment;filename=' + filename); }); req.on('error', function(e) { console.log('problem request: ' + e.message); }); // write data request body req.write('data\n'); req.end();

xcode - iOS Simulator launching Black screen Appear -

Image
xcode 4.6 , ios simulator version 6.1 run projects given error occurred following scenarios not worked 1.change debugger lldb gdb. given message appear in xcode: gnu gdb 6.3.50-20050815 (apple version gdb-1824) (thu nov 15 10:42:43 utc 2012) copyright 2004 free software foundation, inc. gdb free software, covered gnu general public license, , welcome change and/or distribute copies of under conditions. type "show copying" see conditions. there absolutely no warranty gdb. type "show warranty" details. gdb configured "x86_64-apple-darwin". 2.delete derived data given path ~/library/application support/iphone simulator/6.1/applications , ~/library/developer/xcode/deriveddata my system available in following folder path: ~/library/application support/iphone simulator/6.1/ 3.try ios simulator option reset reset content , settings i had same problem. me was, forgot set storyboard main interface in project editor.

How can i post values from android to jsp website -

i making 1 android application in when login in android app login details should post jsp website.how can store login details oracle db .......... please help create web service secure login details also. introduction web services

c# - Delete file: The process cannot access the file -

i use mvc , have controller takes file name , deletes server, when use visual studio development server on local machine, page(controller) delete file on production server i'm getting following error: the process cannot access file 'filename' because being used process system.io.file.delete(server.mappath("~/content/myfolder/" + id)); before line of code custom request validation dont access file. file has been saved page right before page. in fact want know process may accessing file. , if code previous pages(controllers) may cause problem? have searched found nothing useful. you check identity under application pool of application runs, check permissions account. check process locked file, try this link.

javascript - Value &# to unicode convert -

i have lots of characters in form &#182; display unicode characters in text editor. ought convert them: var newtext = doctext.replace( /&amp;#(\d+);/g, string.fromcharcode(parseint("$1", 10)) ); but doesn't seem work. regular expression /&amp;#(\d+);/ getting me numbers out -- string.fromcharcode not appear give results i'd like. up? the replacement part should anonymous function instead of expression: var newtext = doctext.replace( /&amp;#(\d+);/g, function($0, $1) { return string.fromcharcode(parseint($1, 10)); } );

c# - WPF set visibility of item in listbox - code behind -

i have listbox (added in code behind) , want set visibility of last item when items.count > 4. have list box full of buttons. private void movingofbuttons(listbox list, int index) { control previousbutton = (control)list.items.getitemat(list.items.count - 1); int itemcounts = ktery.items.count; indexbutton = index; // create new buttons addnewbutton("sound"); addnewbutton("addsound"); maincycle(list); // not work - show messagebox if (itemcounts >= 4) { messagebox.show("" + previousbutton.name); previousbutton.visibility = visibility.collapsed; } (list).items.removeat(index); } this previousbutton.visibility not work. where error? i found error: i have "refresh" items in listbox.. ;) maincycle(list); previousbutton = (control)list.items.getitemat(list.items.count - 1); if (itemc

sharding - MongoDB two member replica-set -

i have 2 member replica set (within sharded cluster), no arbiter. know recommended design have 3 servers (or odd number) right have stick design. the problem when primary down, secondary doesn't elected temporary master (since priority both servers 1 , have no arbiter). is there way automatic failover (slave becomes primary -> primary online -> default primary gets previous state)? thank you! you must have @ least 3 members in replicaset, having 2 members worse having single node (never ever this!!). problem worst think, main problem if secondary goes down, primary demote secondary , go down because have no more primary. don't know why 'have stick configuration', can not solution. the solution create , arbiter , node, lightweight member of replicaset has no actual data , there take part in election new primary if 1 of other members goes down.

javascript - How do you force a Jquery Mobile popup to open using php? -

basically, trying force 1 of jquery mobile popups open when isset($_post["submit"]) triggered. note having popup load on page load not work in situation, must activated when form submitted. for example: <?php if(isset($_post['submit'])) { //other stuff //force open popup } ?> <form method='post' action='self.php'> <input type='submit' name='submit' value='submit' /> </form> <a href="#popup" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="check" data-theme="a" data-transition="pop">popup</a> <div data-role="popup" id="popuplogin" data-theme="a" class="ui-corner-all"> <!-- popup contents --> </div> thanks in advanced! can try 1 ?? <script type="text/javascript"&

javascript - zoom canvas not working for clip area -

i using following code zoom in , zoom out effect. problem performing clip[suppose clip circle stroke colour] on canvas , doing zoomin. happened elements zoomed, clip area not zoomed. how can make clip area zoom? clip method :: canvas.clipto = function(ctx) { var shp = new fabric.rect({ top : top_pos, left : left_pos, width : c_width, height : c_height, fill:'', stroke : 'red', strokewidth : 5 }); shp.render(ctx); }; zoom method :: // zoom in function zoomin() { // todo limit max canvas zoom in console.log('zoom in called'); if (zoomeffect == false) { canvasscale = canvasscale * scale_factor; canvas.setheight(ca