Monday, January 30, 2012

2 Weekdays

On Studies

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

Saturday, January 28, 2012

7 days till the next 4 day weekend

On Studies

Great time for an IPO - too much liquidity in the market this year. #facebook On going back to banking: well I miss lots of other things too. Documentation for the Chicago Boss installation on Windows is slightly incomplete, to say the least. I've offered to re-document the process in great detail, if someone would just show me how to do it once. Meanwhile, I'm sorely tempted to just get Nitrogen or write my own web framework in the meantime. Since I can't get the better Erlang web frameworks to work out of the box on Windows, I'm going to work on finance today, first. Disappointed with the Windows interoperability of the best existing Erlang web development frameworks. Going to perhaps start writing one after I study some finance. Need to learn more about the sovereign debt economy, and its decades-long lifecycles. Rested somewhat. Tea. Shower. Off to write some code for a stock screen, and maybe a web server too. Now I understand how a "long straddle" works well in markets like these - stocks like GOOG and AAPL react violently to earnings calls. Seems like I'm doing daily commitments to either computing or financial studies. Writing a web(server+dev.) framework in Erlang would teach me about 1) compilers and 2) networking. Do I want that now? Or focus on finance? Ok - so now that I see the Erlang "exp1, exp2, expN." syntax, I see how things can fail silently. :-S Just skimmed through all the ServiceConfig properties for Erlang/OTP's (inet's) httpd service. God, there's a lot of them. I guess it's not as bad as PHP.ini :


% MANDATORY properties
      { port, 8081 }, % http://localhost:8081
      { server_name, "hello_world" },  
      { server_root,"log"},  
      { document_root,"www"},  
      % FILE Properties
      % { proplist_file , RTFM },
      % { file, RTFM },
      % COMMUNICATIONS properties
      % { bind_address,RTFM },
      % { socket_type, RTFM },
      % { ifamily, RTFM },
      % ERLANG WEB SERVER API modules
      { modules, 
        [ %mod_alias,    
          %mod_auth,    
          mod_esi%,    
          %mod_actions,    
          %mod_cgi,    
          %mod_dir,    
          %mod_get,    
          %mod_head,    
          %mod_log,    
          %mod_disk_log  
        ]
      },  
      % LIMIT properties
      % { disable_chunked_transfer_encoding_send , RTFM },
      % { keep_alive , RTFM },
      % { keep_alive_timeout , RTFM },
      % { max_body_size , RTFM },
      % { max_clients , RTFM },
      % { max_header_size , RTFM },
      % { max_uri , RTFM },
      % { max_keep_alive_requests , RTFM },
      % ADMINISTRATIVE properties
      { mime_types,
        [ { "html", "text/html"},   
          {"css","text/css"},   
          {"js","application/x-javascript"}  
        ]
      }, 
      % { mime_type , RTFM },
      % { server_admin , RTFM },
      % { log_format , RTFM },
      % { error_log_format , RTFM },
      % SSL Properties
      % { ssl_ca_certificate_file , RTFM },
      % { ssl_certificate_file , RTFM },
      % { ssl_ciphers , RTFM },
      % { ssl_verify_client , RTFM },
      % { ssl_verify_depth , RTFM },
      % { ssl_password_callback_function , RTFM },
      % { ssl_password_callback_arguments , RTFM },
      % { ssl_password_callback_module , RTFM },
      % URL ALIASING Properties - requires mod_alias
      % { alias , RTFM },
      % { re_write , RTFM },
      % { directory_index , RTFM },
      % CGI Properties - requires mod_cgi
      % { script_alias , RTFM },
      % { script_re_write , RTFM },
      % { script_nocache , RTFM },
      % { script_timeout , RTFM },
      % { action , RTFM },
      % { script , RTFM },
      % ESI Properties
      { erl_script_alias, 
        {"/erl", [hello_world]}
          % /erl/hello_world
      },  
      % { erl_script_nocache , RTFM },
      % { erl_script_timeout , RTFM },
      % { eval_script_alias , RTFM },
      % LOG Properties
      { error_log, "error.log"},  
      { security_log, "security.log"},  
      { transfer_log, "transfer.log"}
      % DISK LOG Properties - required mod_disk_log
      % { disk_log_format , RTFM },
      % { error_disk_log , RTFM },
      % { error_disk_log_size , RTFM },
      % { security_disk_log , RTFM },
      % { security_disk_log_size , RTFM },
      % { transfer_disk_log , RTFM },
      % { transfer_disk_log_size , RTFM },
      % AUTHENTICATION Properties - requires mod_auth
      % { directory , RTFM },
      % { allow_from , RTFM },
      % { deny_from , RTFM },
      % { auth_type , RTFM },
      % { auth_user_file , RTFM },
      % { auth_group , RTFM },
      % { auth_name , RTFM },
      % { auth_access_password , RTFM },
      % { require_user , RTFM },
      % { require_group , RTFM },
      % HTACCESS authentication properties - requires mod_htaccess
      % { access_files , RTFM },
      % SECURITY Properties - requires mod_security
      % { security_directory , RTFM },
      % { data_file , RTFM },
      % { max_retries , RTFM },
      % { block_time , RTFM },
      % { fail_expire_time , RTFM },
      % { auth_timeout , RTFM },


On Jobs

Where I am right now, is a good balance I suppose - unless some hedge fund wants to hire me on a 9-5 schedule. Taking a break from messing with symbols. These days it seems I'm tossing out 1-year commitments left, right, and center. These days I seek a quieter life. (Checking my memory. I counted management fiascos at over a dozen operations in 5 years. Insane.) Ask some people for a brief with some numbers and they send you a slide deck. Surely business isn't that bad? Ran into the careers page of Jane Street, a firm I watched in a video back in 2007. Since I'm working on related stuff these days, I thought I'd drop them a cursory job application:

"Hi there.

I have a long-term interest in computational finance / financial engineering.

After college, I sought work as a quant at a Malaysian Bank (a rather superficial role involving Sharpe and Information Ratios, and fund accounting), but it wasn't technically challenging, so I left in 2007 to pursue further studies on my own. Since then I've paid the bills wherever I can, while learning about the local business environment.

Most recently in 2011, I've found time to practice stock and warrant trading on the KLSE. I've also begun studying Golang and Erlang, and am considering writing a web server and development framework from scratch in Erlang, in order to familiarise myself with networking, compilers, and functional programming.

Though I ticked "not currently a student,' I am pursuing independent study at home, though not attached to any accredited institution. I'm catching up on computing, mathematical, and statistical subjects that I postponed in college, while pursuing studies in quantifying human experience. I know very well how to quantify how humans think, and nowadays my studies are about learning how to explain it to machines."


Code editors and GL. (Picture) You can't really see it here, but syntax highlighting comes into its own when it glows like kryptonite.

On Society

The advantage of being a know-it-all, is that you probably have the privilege of being able to die happy, even if you have to die alone. No matter how complicated an idea is, I can find a way to explain it from zero. But I find that many people don't like doing that. Gotta figure out how to minimise gratuitious travelling costs, and the appearance of being antisocial. I figure I'm willing to spend about $500 disposal income on social tourism in 2012. Work ~2wks to earn it it! Some ppl make that in 2 days! Dexter, Sherlock, House... bah... caricatures. I guess the world enjoys its entertainment. :)

On Infrastructure

Further cost reductions. Walking out to look for dinner. Just like good old times, before work got busy. Chicken rice again. Booted up a housing journal. 2001-2011: I moved residences 21 times, for an average of one move every 5.71 months. #fark No wonder I'd rather buy at this point. Actually, it's iPhone and Windows for suit work; iPad for studies; and Ubuntu for freelance/personal. Macs are gay. In a good way. On some online course in AI: "Cool. But the same issue I had in college remains - I haven't reached the limit of what I can teach myself, so I find it troublesome to seek much help elsewhere. Very busy these days, hope to nail down more solid infrastructure soon. Then I can afford to engage in more improvisation again. Was just discussing this with a friend. Hehe."