Posts

gen server - Erlang gen_server implementation -

in code below, why module prime_server not loading? -module(prime_server). -behaviour(gen_server). -export([new_prime/1, start_link/0]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). start_link() -> gen_server:start_link({local, ?module}, ?module, [], []). new_prime(n) -> %% 20000 timeout (ms) gen_server:call(?module, {prime, n}, 20000). init([]) -> %% note must set trap_exit = true if %% want terminate/2 called when application %% stopped process_flag(trap_exit, true), io:format("~p starting~n" ,[?module]), {ok, 0}. handle_call({prime, k}, _from, n) -> {reply, make_new_prime(k), n+1}. handle_cast(_msg, n) -> {noreply, n}. handle_info(_info, n) -> {noreply, n}. terminate(_reason, _n) -> io:format("~p stopping~n" ,[?module]), ok. code_change(_oldvsn, n, _extra) -> {ok, n}. make_new_prime(k) -> ...

ios - Comparing Date and Time Object -

this question has answer here: how compare 2 nsdates: more recent? 13 answers i working method , not giving me proper output came know, way comparing date , time object wrong. googled not find relevant solution. want compare date , time object object. for example: if (dtcur >= dtstart && dtcur <= mydt) // 2014-03-24 11:30:00 >= 2014-03-24 11:00:00 & 2014-03-24 11:30:00 <= 2014-03-25 11:00:00 { // should come here in if condition } but goes in else. means comparison wrong, can me how compare 2 date , time objects. in advance many objects, including nsdate, have compare: method. use so: if ([date1 compare:date2] == nsorderedascending) { // date2 after date1 } else if ([date1 compare:date2] == nsordereddescending) { // date2 before date1 } else if ([date1 compare:date2] == nsorderedsame) { // they're both sa...

Jquery Group Radio selection -

i have radio buttons this <input name="show[1]" type="radio" value="1" /> show<br> <input name="show[1]" type="radio" value="0" /> hide<br> <input name="show[2]" type="radio" value="1" /> show<br> <input name="show[2]" type="radio" value="0" /> hide<br> ... ... ... <input name="show[n]" type="radio" value="1" /> show<br> <input name="show[n]" type="radio" value="0" /> hide<br> here length of n can varies. this part of form submit. in jquery want make sure 1 of radio button each group should selected. how can this try this: $(':radio').each(function() { nam = $(this).attr('name'); if (submitme && !$(':radio[name="'+nam+'"]:checked').length) { alert(nam...

performance - MongoDB Slow query by ID -

i migrated mongodb database windows server centos. version 2.4.9. noticed have slow retrieval of records _id field! ran repair database on weekend bu did not solve problem. have method retrieves records ids (with in operator) (using spring data mongodb 1.4.1.release): @override public map<string, record> findasmapids( final string[] ids, final componenttype... comps ) { if( null == ids || 0 == ids.length ) { return null; } map<string,record> result = new hashmap<string,record>(); final criteria cr = where("_id").in( idarrfunction.apply(ids) ); final query qry = new query( cr ); setfieldstoreturn( qry, comps ); long start = system.currenttimemillis(); list<record> ritems = gettemplate().find(qry, record.class); long end = system.currenttimemillis(); system.out.println( "findasmapids()::" + (end-start) ); for( record r: ritems ) { result.put( r.getid(), r ); } re...

c++ - Why does this explicit conversion operator work with g++ but not Visual Studio 2013? -

the following example contains 2 templated classes represent degrees , radians explicit conversion operator cast between them. compiles , runs g++ ( ideone link ) not visual studio 2013 visual c++ compiler nov 2013 ctp (ctp_nov2013) platform toolset. #include <iostream> static const double pi = 3.14159265358979323846; // forward declarations template< typename t > class radians; template< typename t > class degrees; template< typename t > class degrees { public: degrees(const t value) : value_(value) {} template< typename u > explicit operator u() const { return value_ * pi / 180.0; } t value() const { return value_; } private: t value_; }; template< typename t > class radians { public: radians(const t value) : value_(value) {} template< typename u > explicit operator u() const { ...

iphone - Kiosk App in iOS can we provide any identifer to that app to use from URL scheme. -

i wanted, give identifier app create kiosk mode in ios. i.e. make add home screen , has icon on home page browse further. is there way, can give identifier name link of app getting created can app access our native , can provide url scheme same. thanks. ios not give access of url schemas. can refer document url schemas selected application given : http://wiki.akosma.com/iphone_url_schemes#phone

http - POST method WEBDAV not run -

i had server install webdav , try webdav method method copy, delete, get, lock, mkcol, propfind, propatch run good. can create file , store data in server put method. don't know how in post. when post anydata exist file server return data of old file. , check in server file not change thing when try post new file return "the requested url - url of file - not found on server." when try post new file out full path, send folder want store file. hope server create file auto gen name of file , return name me. server return resource content in folder ( thing index.html ) i want know how implement post method, can create or repair file on webdav server. 1 can me ? in general, webdav servers not support post (more precisely: webdav specification doesn't mandate specific behavior post, servers vary in do).