Just had some fun with node.js
I found Introduction to Node.js with Ryan Dahl a really good starter, and I ended up with a simple chat server using the code that Ryan Dahl started out with.
Friday, August 26, 2011
Wednesday, August 17, 2011
Setting up ircd-hybrid
$ sudo apt-get install ircd-hybrid
Log file:
/var/log/ircd/ircd-hybrid.log
Message of the day:
sudo vim /etc/ircd-hybrid/ircd.motd
Restart ircd:
sudo /etc/init.d/ircd-hybrid restart
sudo vim /etc/ircd-hybrid/ircd.conf
Default irc port is 6667
Log file:
/var/log/ircd/ircd-hybrid.log
Message of the day:
sudo vim /etc/ircd-hybrid/ircd.motd
Restart ircd:
sudo /etc/init.d/ircd-hybrid restart
sudo vim /etc/ircd-hybrid/ircd.conf
Default irc port is 6667
Saturday, August 06, 2011
Thursday, August 04, 2011
Magically Provisioning VirtualBox
Recently, I had the fortune of figuring out how to boot and provision VirtualBoxes in a private network on the host machine automagically.
First, the primary objectives:
- The virtual machines should be connected in a private network on the host machine so that they can communicate securely with each other. The machines should have an ip address in the private address space.
- The virtual machines should also be able to communicate with the "outside world". From the point of view of the guest machine, this can be other machines on the same network as the host or the Internet-at-large.
- The host machine should be able to network (primarily ssh) with the virtual machines. Typically, this can be done through the router gateway of the host or a "host-only adapter" (a virtual adapter that resides on the host).
Possible Solutions:
- TunTap networking. This can be tricky to setup correctly and varies across platforms.
- Each VM uses two network interface cards (NICs):
- One Host-only adapter with its own dhcp server for the private network OR use the "Internal Network" feature of virtual box.
- One bridge adapter that get its ip address from the outside world (possibly the router to which the host machine connects to).
Next, secondary objectives:
- We want to boot the VMs automagically, find out the ip address.
- Then, we want to ssh into the machine and do provisioning via chef or puppet.
Possible Solutions:
- Use VBoxManage guestcontrol to execute the /sbin/ifconfig command
- Use NAT with port forwarding for ssh
($ VBoxManage --natpf<1-N> [],tcp|udp,[ ] ) - Hack /etc/init.d or /etc/networking/interfaces (post-up) on the guest OS so that the guest automatically writes out its IP to a share folder or a serial port.
Monday, July 11, 2011
Sunday, July 10, 2011
Gist Github
A while ago, I used the subdomain feature of pastebin to keep track of my public pastes (e.g. hanworks.pastebin.com), but it seems that pastebin has disabled this feature, making retrieval of old pastes difficult (of course, you can sign up). Hence, I am moving over to the really awesome github gist, which supports various markups such as markdown and reST on top of source code syntax highlighting. I also like the fact that there is a "revisions feature" to see previous revisions.
In other news, github released Github for Mac (more about the design)
Saturday, July 09, 2011
Geeks and Geezers
A long time ago, I read Harvard Geeks and Geezers: How Eras, Values and Defining Moments Shape Leaders (by Warren G. Bennis and Robert J. Thomas)
"Big four" qualities of leadership:
1. Adaptive capacity
2. Engaging others through shared meaning
3. A distinctive voice
4. Integrity
The book also stressed the power and influence of the crucible, and it create exceptional leaders.
Stuff about Python
The stuff here should be seen in the context of CPython unless otherwise stated.
Advanced
Basic
- "import this" easter egg
- the pass keyword
- Remember to have __init__.py to you modules. You can put code in __init__.py too! (e.g. for initializations, and functions in there can be imported)
- Single underscores should be used for private variables.
- re.match() only attempts to match a pattern at the beginning of a string where re.search() will match a pattern anywhere in a string.
- Readline configuration for python
- Else clauses on for loops (or even try-except statements)
- Function closures
Advanced
- unittest module
There is so much magic happening behind the scenes that I recommend taking a look at the source code to understand what's going on. - Design Patterns in Python
- More Design Patterns (slides) (from Google)
- Use coroutines via enhanced generators (PEP 342). A cool networking/threading library written using coroutines. More about coroutines via PFPL chp 33.3
- Mixins
- Decorators (tutorial, advanced)
- What you should know about exec and compile
- New and old classes
Implementations of Py
- CPython
- JPython
- IronPython
- StacklessPython
Note: This post is a work in progress.
Thursday, July 07, 2011
web2py
Free open source full-stack framework for rapid development of fast, scalable, secure and portable database-driven web-based applications. Written and programmable in Python. LGPLv3 LicenseRead more...
Wonders how web2py compares against django.
Subscribe to:
Posts (Atom)