Erik's blog

Code, notes, recipes, general musings

Archive for January 2010

Building and running the Mochiweb dev server

leave a comment »



  • Mac OS X 10.5


  1. follow Bob Ippolito’s tutorial from his blog
  2. if your server returns
           exception exit: {noproc,{gen_server,call,  

    when you try to run http:request("")., start inets with inets:start(). and then run the http request call, as described on Pragmatic Dave’s blog.


Written by Erik

January 27, 2010 at 10:23 pm

Posted in tutorial

Tagged with ,

the Internet as a series of tubes

leave a comment »

We’ve long sought to create a singular artificial intelligence.  I wonder if another aspect of intelligence arises simply from the existence of connections.  Our brain is not composed of intelligence, but rather a mass of connections, neural pathways, which somehow creates an opportunity for intelligence to occur.  The Internet currently seems to be beginning to manifest intelligent behavior in that I can interact with it and gain something from that interaction (“You just checked into restaurant X.  Your friend Alan is here too”).  I wonder if it is our input then that brings this intelligence to life, i.e., we are the intelligence in the giant networked computer “brain”.  I can query the Web to find out where my friends are only because they have stated their position.  A measure of the Net’s intelligence could be based on the data it contains, the questions we imagine to ask, and our ability to ask them.

I feel inspired as an Internet software developer to make the process of interaction, contribution, and connection as easy as possible.  How can I make it easier to contribute?  Simplified markup is one option.  Easy authentication is another.  Improved data collection, such as automated geo positioning via mobile devices, and mining enable us to contribute implicitly.  How can I reduce the barrier to entry?

Yahoo!’s recent brand campaign stated that the Internet is all about “you”.  One way to interpret this is that Yahoo! facilitates contributions to, and recognition of, one’s self online.  I spend so much of my time online it seems like a second home.  So much of my persona involves how I see myself  reflected in the Internet.  Yahoo!, and many other services, tries to make it easy to be online and manifest a personality there.  This is one way to describe of the process of growing the Web.  This propagation of the Web could be summarized as: building physical and logical connections between people, and allowing them to input and retrieve data.  I’m curious to see if the Web does seem to become more intelligent relative to the success of these activities.

A few current touch points involving the simplification of Internet interaction, i.e., interaction with the Net itself, come to mind: establishing network infrastructure (how easy can we make it to set up an internet access point?  this shouldn’t be a bottleneck); creating and maintaining online identities (oauth, openid); storing the collected data in easily retrievable formats (semantic web, search, open gov, freebase, wikipedia); processing big data using mapreduce; server-side processing with web hooks and app engines; providing easy access to the processed data via asynchronous communication, key/value interfaces, convenient off-network “connect” access to social data; using apps on existing networks, and mobile devices, for easy delivery and consumption, esp. iphone and android.

Written by Erik

January 13, 2010 at 12:53 am

Posted in notes

Tagged with , ,

standard stack v1: git

with one comment


we’ll use git to facilitate the process of pushing code to the vm.  because there’s a cardinal rule about not serving files from a repo, we’ll need to create a git host and use a githooks to update the web root when code is pushed to the repo.  i’m using the terms hub and prime introduced by Joe Maller in his post A web-focused Git workflow.

i don’t have a cool picture of the concept, like Maller did, but here’s one of a cute red panda (credit: tambako) to set the mood before we get started:

ok, here we go:


  • prime is the copy of the repo accessible by the web server
  • hub is the bare source of truth repository
  • project refers to the prime/hub pair
  • vm is the vmware vm running centos
  • laptop is the development computer you ultimately want to push files from


  • mac os x 10.5.8
  • vmware 2.0.5
  • centos 5.4
  • git


  1. set up
    1. on the vm, install git as root:
      yum install git
    2. on the vm, create a user to handle git-related activity:
      useradd git
    3. on the vm, get its inet ip address using ifconfig:
    4. on the vm, copy your rsa public key (you’ll be pushing git updates over ssh) from your laptop into the git user’s .ssh/authorize_keys file on the vm
    5. on the vm, make sure the correct permissions are set on the authorized_keys file and .ssh dir:
      chmod 700 /home/git/.ssh; chmod 644 /home/git/.ssh/authorized_keys
    6. on your laptop, run a sanity check by logging into the vm via public key. note: if you’re using an alternate ssh port and/or different pub key file name, define these in your laptop‘s .ssh/config file:
      ssh git@{ip address}
    7. on the vm, in /var/www/, as root, create a directory that git can push content to (note: if the dir isn’t owned by git or isn’t world-writable, git throws an “error: cannot open .git/FETCH_HEAD: Permission denied” error):
      mkdir /var/www/git/; chown git:git /var/www/git/
    8. on the vm, cd into the /var/www/git/ directory and su to the git user:
      cd /var/www/git/; su git
  2. create a new project
    1. on the vm, create a new directory {proj name} for the prime repo and cd into it:
      mkdir proj; cd proj
    2. on the vm, initialize a git repo:
      git init
    3. on the vm, create and add a file so we can clone prime later (git dissallows cloning an empty repo):
      touch readme;
      git add readme;
      git commit -m ‘initial commit’

      Note: if you haven’t already told git who you are, run:
      git config “”
      git config “”
    4. on the vm, define a remote repository for the soon-to-be-created hub:
      git remote add origin /home/git/proj
    5. on the vm, cd into git user’s home directory:
      cd ~
    6. on the vm, create the hub repo by cloning the newly created repo using the –bare flag (that’s a double ‘-‘ before bare):
      git clone –bare /var/www/git/proj
    7. on the vm, create a post-update hook in the hub repo to update the web directory when an update is pushed.  open /home/git/proj/hooks/post-update and add the following:
              # jump into web dir
              cd /var/www/sites/
              # w/o this, git throws "fatal: Not a git repository: '.'" error
              # ref:
              unset GIT_DIR
              # pull in the updates
              git pull origin master
  3. start working
    1. on the laptop, open a terminal on whatever machine your going to develop on and clone the new host repo:
      git clone git@{ip address}:proj
    2. on the laptop, edit the readme file in the repo, check in the change and observe in the output the results of the hook-initiated pull
    3. on the laptop, view http://{ip address}/readme to confirm the new code is displaying


Written by Erik

January 2, 2010 at 11:46 pm

Posted in tutorial

Tagged with ,