Posts

functional programming - how to get an int list of months by giving two days of a year? -

write function named month_range takes 2 days of year named day_one , day_two (e.g. 65, 128, assuming year has 365 days) input , return int list of months. size of int list must day_two - day_one + 1; aware, if day_one>day_two, size of list = 0 example : month_range(25,36) should return [1,1,1,1,1,1,1,2,2,2,2,2] january(25,26,27,..,31) , february(1,2,..,5) i wrote code doesn't work : fun month_range (day1:int,day2:int) = let val month_days= [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; fun what_month(day :int) = let fun aux(sum :int, numbers: int list) = let val numbers_tail = tl numbers in if sum <= (hd numbers) 1 else 1 + aux(sum, (hd numbers + hd numbers_tail)::(tl numbers_tail)) end in aux(day, month_days) end in if (day1>day2) [] else what_month(day1) @ what_month(day2) end well per previous question , have function what_month , return month number of given day of year. you pretty simple iterate day_one...

.net - ReaderWriterLockSlim (not so slim) replacement, recursive, with upgradeable read? -

somehow got lot of readerwriterlockslim in our code. each of them takes 6k memory, has become big issue. as quick fix, i'm looking less memory-hungry replacement. i'm trying joe duffy's rw-lock , it's not upgradeable , write-recursive (and pretty hard make such). is there other, more memory-light replacement? well, obvious approach use readwriterlock (sans slim), believe less memory intensive (but less efficient in scenarios).

Symfony 2.1 with PHPPDF -

i trying include image (a jpg file) pdf being created using phppdf bundle of symfony 2.1.3. i able create pdf's cannot them include images. i using, inside twig template: img src="{{ pdf_image('gimage.jpg') }}" i have tried putting jpg in number of different places , tried number of different paths e.g. img src="{{ pdf_image('xx/xx/xx/gimage.jpg') }}" nothing works. have tried path image without pdf_image . can help? are using psliwa pdfbundle ? if says use.. <img src="{{ pdf_image('symfonywebconfiguratorbundle:blue-arrow.png') }}" /> which think linking to.. path/to/symfonywebconfiguratorbundle/resources/blue-arrow.png

BootStrap Mobile CSS Code Not Registering -

this may stupid question, have website , i'm learning bootstrap. have styles working correctly on browser(even when shrink them down mobile view). if @ on mobile website through phone, nothing registering...any ideas? http://goo.gl/yfhni - link viewing. thanks! a couple of details closer answer. in head, add <meta charset="utf-8"> and on line 24, close h4 tag. see happens after make corrections. good luck!

json - Facebook Fan Page feed on Website (Age-Protected) -

need in trying posts/wall posts fan page age-gated on facebook show on site. the fan page age gated let 17 , on view (when logged facebook). but, website behind age gate (locally), want show posts facebook page on site. i've seen done before, never able @ person's code see how he/she did , can't locate has tried or pulled off. i've created app on facebook, tied account, able see page on facebook (whether it's age gated or not): here code <?php function fetchurl($url){ $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_timeout, 20); $feeddata = curl_exec($ch); curl_close($ch); return $feeddata; } $profile_id = "(page id)"; //app info, needed auth $app_id = "123456789"; $app_secret = "123456789abcdefghij"; $authtoken = fetchurl("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id={$app_id}&clien...

HTML calling POST action on embedded php -

i have html page displaying phpbb3 forum through iframe using following: <iframe name="inlineframe" src="http://www.website.net/forums/index.php" frameborder="0" scrolling="auto" width="100%" height="1500" marginwidth="5" marginheight="5" ></iframe>. i doing in order display html coded menu bar on top of forum. on html page (the home page), have container input fields allowing log in directly forums via following code: <form action="http://www.website.net/login.php?mode=login" method="post"> <label for="username">username</label><input type="text" name="username" required> <label for="password">password</label><input type="password" name="password" required> <input type="submit" name="login" value="lo...

multithreading - How can I copy/clone a single row from a ResultSet in Java? Multithread implementation -

i retrieve resultset lot of rows. each row has analyzed, i'd analyze each row in new thread (don't worry: won't start threads simultaneously, let 10 in row). entire resultset used exclusively read data (so, it's kind of static read-only table). so i'd is: resultset rs; public void loadresultset(){ ... rs = _preparedstatement.executequery(); int rowsize = 0; while (rs.next()) { rowsize++; } //this method starts 10 threads simultaneously runthreads(rowsize); ... } and... @override public void run() { //unknown object allows me store copy of single row resultset foo foo = rs.absolute(index); //then can retrieve data normal resultset string s = foo.getstring(1); .... .... } any suggestion? samples appreciated! thanks! if u, rather execute queries in separate threads like: select * table_name mod(id,threadcount)=threadid just give id each thread , execute them. this...