Minimise language proliferation; stick to Erlang/OTP as closely as possible; build a web framework that's easy to deploy. Gottit. I just learnt how to do a HEAD request today. That just sounds so wrong. #http Stuck trying to get inets to serve static content. Going home to wash and try again. Laundry. Figured out static file service on OTP's inets. Yay. Hello. BN has allowed a FX derrivative trading for retailers in KL. Not something I can afford to do full time yet. Hehe. Commitments. Meanwhile, gotta make myself work a bit harder on equities research. Getting really torn between that and the Erlang web server project. Need to brush up bad, on international economics. Erlang, inets, httpd, ANTM, start, stop, wait... something doesn't fit here.
It's tutorial time! This is what I've learnt about building Erlang webservers, so far. This example uses Windows conventions for the server_root and document_root addresses.
% Erlang Minimal Webserver
%
% WHAT:
% - handles GET requests
% - serves static files, with directory listing and traversal
% - when possible, returns index.html instead of the directory listing
%
% HOW:
% In any major OS,
% 1. get Erlang OTP installed
% 2. run the Erlang shell
% 3. paste the function's body below (after the -> until and including the period .) into the shell
% 4. hit http://localhost in your browser (assuming that your OS paths are set right)
% 5. try tweaking the code, then copy/paste again in the shell
%
% NOTES:
% I still don't understand why document_root is not treated as an accessible directory;
% I probably need to study the path variables more;
% e.g. you can access a child folder of document_root from its descendent grandchild,
% but you can't access document_root from the child of document_root;
% meanwhile, the directory_index can recognise and serve index.html from document root
%
% In any event, inets supports Apache-like htaccess files, which I haven't poked at yet
minimal() ->
inets:stop(),
inets:start(),
inets:start(
httpd,
[
{ port, 80 },
{ server_name, "localhost" },
{ server_root,"C:\\Users\\yourusername\\Desktop"},
{ document_root,"C:\\Users\\yourusername\\Desktop"},
{ modules,
[ mod_alias,
mod_dir,
mod_get
]
},
{directory_index, ["index.html"]}
]).
% this is the function's head
% you don't input this in the Erlang shell if you just want to run the code in the function's body.
minimal_commented()->
% the function's body starts here, after the arrow
% does nothing if inets hasn't been started;
% but if inets has been started, this stops inets and its services, e.g. httpd
inets:stop(), % comma indicates end of expression
% starts inets (the OTP library module which comes with a http server service)
inets:start(), % comma indicates end of expression
% starts inets' httpd service
inets:start(
httpd,
[
% MANDATORY properties
{ port, 80 },
{ server_name, "localhost" }, % server may treat this as a domain and try to redirect to it :( #wtf
{ server_root,"C:\\Users\\yourusername\\Desktop"},
{ document_root,"C:\\Users\\yourusername\\Desktop"},
% ERLANG WEB SERVER API modules
{ modules,
[ mod_alias, % required by mod_dir, mod_get
mod_dir, % handles apache-style directory listings
mod_get % handles get-requests
]
},
{directory_index, ["index.html"]}
]). % period indicates end of expression, and end of the function's body
On Infrastructure
Salt in the morning, and sugar at night. My brain seems much happier that way. Every cloud has a silver lining. Every piece of silver tarnishes. Chellation and tardiness. It's been an ok year I guess.
On Job
Have been feeling kinda senile. But I suppose two almost solid years of being blockaded by d**** c*******ts will turn anyone insane. Reminiscing startup days talking to the Webcamp folks about CakePHP. Dear Kuala Lumpur. Happy FT Day. I think that integrated marketing communications (IMC) just became my favourite buzzword. But this is closer to the point: "strategic management, integrated marketing communications, human capital management, contract negotiation" #specialties IMC is the stick I shall wield to beat any marketing, PR, brand manegement, CSR, and investor relations people over the head... who tell me that their disciplines are atomic.
On Society
Studying Erlang and the KLSE in Telawi. Feel free to join. Oh shit, Greece... worse thing is, it's not even a real problem. It's just a few hundred bankers and officials playing poker at knifepoint. I'm just being poetic. It's a real problem as soon as the economy falls out and people start starving. But it's not a real problem, in the sense that... they should just boot them out of the EU and treat them like a third-world country, IMF, aid, whatnot. :P Ok, I'm still being ironic. Wish there was a dominant white-label supplier for such services in Malaysia. http://www.twilio.com/ #saas Quick tweetup at Sid's. Left early. Going home to make out with Erlang. ;) I'm an extrovert with introverted parents. I had to work to fit in. Extroverts RTFM yo ;) http://www.thedarktrumpet.com/2010/04/dealing-with-introverts-a-guide-for-extroverts/ http://www.lisapetrilli.com/2011/04/07/extraverts-guide-leading-introverts/ ISO 25,600 #wtf