Posts

OCaml: retain value of variable with control statements -

i'm new ocaml / functional programming, , i'm confused implementation of things relatively simple other languages know. use , help. chiefly: in program i'm working on, either increment or decrement variable based on parameter. here's representative of have: let tot = ref 0 in = 0 s if test_num > 0 tot := !tot + other_num else tot := !tot - other_num done;; this not way go it, because if else statement never taken, code acts if is, each , every time, presumably because it's closer bottom of program? know ocaml has pretty sophisticated pattern matching, within level of coed need access handful of lists i've created, and, far understand, can't access lists top-level function without passing them parameters. i know i'm going wrong way, have no idea how idiomatically. suggestions? thanks. edit here's more concise example: let ex_list = [1; -2; 3; -4] in let max_mem = ref 0 in let mem = ref 0 in let () = ...

javascript - Draw a table inside an infowindow of Google maps v3? -

when user click on marker infowindow appear , shows information. it's better show information in beautiful way using table. how can draw table inside infowindow? here loop-for creates markers on map , create infowindow(s) each one. want show تاریخ , ساعت , سرعت in table aligned. for(var counter = 0; counter < arraylatitude.length; counter++) { var marker = new google.maps.marker({ position:new google.maps.latlng(arraylatitude[counter], arraylongitude[counter]), info:arrayutcdate[counter]+" :تاریخ<br>"+arraysatellite_derived_time[counter]+" :ساعت<br>"+arrayspeed[counter].tofixed(2)+" :سرعت" }); marker.setmap(map); //event. when click on marker, infowindow show content of specified marker. google.maps.event.addlistener(marker, 'click', function () { infowindow.setcontent(this.info); infowi...

microphone - windows phone 7 Recording Issue -

i working on recording functionality in windows phone 7 app. implemented recording functionality through reference link . it works fine @ there , in case also. actually scenario is, in application created first page works recording screen same above referred link. , when stop recording redirected second page , saved recording in isolated storage , @ second page bound recorded sounds. @ here played recorded sounds @ works fine. now, when m again go recording screen(first page) , starts recording. times records fine , times skip sounds during recording beep sounds , looks noise in recording , not getting recording sounds. my code like, public partial class nikhilrecord : phoneapplicationpage { //xna objects record , playback microphone mphone; //used storing captured buffers list<byte[]> memobuffercollection = new list<byte[]>(); //used displaying stored memos observablecollection<memoinfo> memofiles = new observablecollection<...

date - Getting last day of the current month -

i can last day in php using cal_days_in_month(cal_gregorian, 03, 2014); function , assign view. want know possible last day in current month using smarty date_format function? in advance i'm not sure can solve using date_format function. wouldn't anyway, since put way application logic template. but... if want anyway, add template function want. php: $tpl = new smarty(); $tpl->registerplugin("function","lastdayofmonth", "smarty_function_lastdayofmonth"); $tpl->display('your_template.tpl'); function smarty_function_lastdayofmonth($params, smarty_internal_template $template) { return date("y-m-t", strtotime($params['date'])); } smarty: {assign var='datevar' value='2014-03-06'} {lastdayofmonth date=$datevar} output: 2014-03-31 keep in mind, easy example. there more 1 way use plugins within smarty.

python - html css example in django -

i wanted use third-party html/css example in django, doesn't work. <!doctype html> <html> <head> <title>example</title> <link rel="stylesheet" type="text/css" href="/static/css/style.css" /> </head> <body> example code </body> </html> i have used example, , commented other code. django recognizes css file, checked it. however, don't sticky footer , header. transform in plain text, main body. i put example in codeacademy engine , works there well. what hidden stones of django might missing? there no hidden stones in django. there no such option recognize css file django. django has nothing css files. i recommend u open network panel in browser developer tools console , check, css file downloaded browser or not. in case if u use django development server there manual how serve static files in development mode https://docs.djangoproject.com/en/1.2/howto/...

javascript - Getting Parsley 2.x working with Bootstrap 3 correctly -

i using twitter bootstrap 3.1.1 parsley v2.0.0-rc3 . made work apart classhandler option. i have html this: <div class="form-group"> <label class="control-label" for="username">user name</label> <input class="form-control" id="username" name="username" required="" type="text" value=""> </div> and run parsley this: $("#register_form").parsley({ successclass: "has-success", errorclass: "has-error", classhandler: function(el) { return $(el).closest(".form-group"); }, errorswrapper: "<span class='help-block'></span>", errortemplate: "<span></span>" }); everything works fine, success / error classes applied wrong element. after page loaded, this: <div class="form-group"> <label class="control-la...

list - can i not do - if nums[i] == nums[i+]: in python -

i new programming , python. (ref code below) - trying compare elements in list eliminate duplicates in adjacent numbers in list (so numbers in resulting list unique). dont hit nested "if" statement because code skips internal if. when try without external if, error: file "list2.py", line 22, in remove_adjacent if nums[i] == nums[i+1]: typeerror: list indices must integers, not tuple def remove_adjacent(nums): x = len(nums) print x in enumerate(nums): if < x-1: if nums[i] == nums[i+1]: del nums[i] return it should for in range(len(nums)) . enumerate returns key/value tuple - not integer, error message says.