Posts

haskell - Preventing "getCurrentDirectory: resource exhausted (Too many open files)" error -

i trying run parsec parser on whole bunch of small files, , getting error saying have many open files. understand need use strict io, i'm not sure how that. problematic code: files = getdirectorycontents historyfolder hands :: io [either parseerror [hand]] hands = join $ sequence <$> parsefromfile (many hand) <<$>> files note: <<$>> function this: (<<$>>) :: (functor f1, functor f2) => (a -> b) -> f1 (f2 a) -> f1 (f2 b) <<$>> b = (a <$>) <$> b i don't know parsefromfile function looks right (probably idea include in question), i'm guessing you're using prelude.readfile , @markus1189 points out includes lazy i/o. strict i/o, need strict readfile , such data.text.io.readfile . a streaming data library pipes or conduit allow avoid reading entire file memory @ once, though- knowledge- parsec doesn't provide streaming interface allow happen. attoparsec, on other hand,...

c++ - How much memory does a stack take? -

i'm writing sort algorithm can use stacks. increasing amount of stacks, can sort less operations. anyway, have dataset of 10 integers. difference in memory following (with std::stack ): an array of stacks of size 2 (5 integers per stack) an array of size 10 (1 integer per stack) an array of size 20 (1 integer each in 10 stacks, 10 stacks empty) also, how memory empty stack of int take? int pointer? please treat question academic one. know there better ways of solving problem, can use stacks. the obvious answer is: depends. in reality, there things can said. all of containers incur modest amount of overhead, of order of (perhaps) couple of pointers , couple of integers, @ most. can find out how if want know, constant , quite small, depending on implementation. where c++ standard helps places requirements on storage part of container. because iterators (more or less) equivalent pointers, stack elements placed @ consecutive memory locations same alignment ...

arm - Illegal instruction in Raspberry Pi -

today, compiled opencv-master downloaded github . these instructions in webpage http://ariandy1.wordpress.com/2013/02/13/raspberry-pi-rasbian-opencv/ , , opencv compiled successfully. when wrote simple c++ program, link -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_video , run in terminal. error occured, says illegal instruction . when remove opencv -dependent code, , recompile, can run successfully. doubt packages installed apt-get have bugs. can't find them. face problem? the /etc/apt/sources.list is: deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi deb http://www.deb-multimedia.org/ wheezy main non-free deb http://archive.raspbian.org/raspbian wheezy main contrib non-free deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free update the output of dmesg is: http://pastebin.com/dsr8mgvy update 2 the output of ldd command : http://pastebin.com/s7suqabk update 3 the output of ...

java - How do I use OAuth 2.0 to access Google Calendar (Service Model)? -

Image
i'm trying groovy/grails application speak google calendar api java, using service model. i'll happy simple calendar list. no matter though, end with: uri: /test class: com.google.api.client.auth.oauth2.tokenresponseexception message: 400 bad request { "error" : "invalid_grant" } the same user "googleaccounts@quirk.biz" owns both calendar , api console app. code follows: package quirkplanner import com.google.api.client.googleapis.auth.oauth2.googlecredential; import com.google.api.client.googleapis.javanet.googlenethttptransport import com.google.api.client.http.httptransport import com.google.api.client.json.jsonfactory import com.google.api.client.json.jackson2.jacksonfactory; import com.google.api.services.calendar.calendar import com.google.api.services.calendar.model.*; class testcontroller { def servletcontext private static final httptransport http_transport = googlenethttptransport.newtrustedtransport(); private s...

c - Replace floating point math with integer in sigmoid transfer function -

i replace floating point math in these function without losing precision, because have no fpu. possible? think 3 numbers after comma enough. inline float smaller_f(float value, float bias) { return value < bias ? value : bias; } inline float pow2_f(float fval) { return fval * fval; } float sigm_f(float fx, float fslope) { float fval = (180.f - smaller_f(fabs(fslope * fx), 179.9f) ) / 180.f; return fval / sqrt(1.f + pow2_f(fval) ); } a fixed-point math library need. preferred solution anthony williams' fixed-point math c++ library . because in c++ , defines fixed class extensive function , operator overloading, can largely used replacing float or double in existing code fixed . uses int64_t underlying integer data type, 34 integer bits , 28 fractional bits (34q28), 8 decimal places , wider range int32_t . if compiler supports c++, can still write code using c subset if prefer, using c++ support library. on 32bit arm library performs 5 times fas...

javascript - HTML - An editable paragraph -

this code : (html) <html> <head> <title>editable paragraph</title> </head> <body> <label onclick="changetext(0);" class="edit-button"></label> <h1 id="h1">editable paragraph</h1> <br> <label onclick="changetext(1);" class="edit-button"></label> <p id="p1">hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! </p> <br> <label onclick="changetext(2);" class="edit-button"></label> <p id="p2">hello world! hello world! hello...

javascript - Transitioning to state with query parameter -

i'm using angular ui-router manage client side routing. i'm trying use $state.go() method switch states, want include query parameter in new url, , i'm not sure how to. i've defined target state in app module: $stateprovider.state('login', { url: '/login?returnurl', //more properties } and want navigate http://localhost:3000/login?returnurl=%2fhome . how format $state.go() call correctly? this should work: $state.go('login', { 'returnurl': '/home' }); or if want call login page http response interceptor on 401: $state.go('login', { 'returnurl': $state.current.url });