diff --git a/.config/newsboat/my_urls b/.config/newsboat/my_urls
index 05c2c4c4..2026b66e 100644
--- a/.config/newsboat/my_urls
+++ b/.config/newsboat/my_urls
@@ -43,3 +43,4 @@ file://./rss/sometechblog.xml
file://./rss/markus_oberlehner.xml
file://./rss/nicos_blog.xml
file://./rss/npr.xml
+file://./rss/mixus_blog.xml
diff --git a/.config/newsboat/rss/mixus_blog.xml b/.config/newsboat/rss/mixus_blog.xml
new file mode 100644
index 00000000..a5aeec3e
--- /dev/null
+++ b/.config/newsboat/rss/mixus_blog.xml
@@ -0,0 +1,1288 @@
+
+
Simple GET request
+curl -k "https://localhost/foo?bar=baz&abc=def"JSON POST or PUT request
+curl -k -H "Content-Type: application/json" -X POST -d '{"accountName":"test","value":"hello"}' https://localhost/foocurl -X "PUT"... for a PUT
+POST a file
+curl ... --data-binary @filenameFake a /etc/hosts entry and a Host: header with curl
+curl -vvv --resolve 'book.mixu.net:80:123.145.167.189' http://book.mixu.net/Make a request with basic auth enabled
+curl -vvv -u name@foo.com:password http://www.example.comor:
+curl --user name:password http://www.example.comSet the Referer header
+curl -e http://curl.haxx.se daniel.haxx.seSet the User Agent header
+curl -A "Mozilla/4.73"or
+curl --user-agent "Mozilla".Set Cookies
+curl -b "name=Daniel"or
+curl --cookie "name=Daniel"Time a request (connect time + time to first byte + total tile)
+curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" http://google.comDownloading files from Github
+curl -O https://raw.github.com/username/reponame/master/filename+
+]]>http://localhost:5000/2013/01/29/curl-cheatsheet
Coffee
+Philz Coffee. The best coffee in SF (in my opinion); the one closest to the center is on Van Ness (good if you go to the Tenderloin for lunch). The other Philz in the city center is at the Caltrain in SOMA (all locations). I always stop by when I’m close. Protip: don’t get the coffee with sugar, because they put too much and it detracts from the taste. Tantalizing Turkish, Aromatic Arabic and Soo Good (light roast) are my favorites.
+Machine Coffee at 6th/Golden Gate is also quite good as are their sandwitches.
+Blue Bottle. I would describe the coffee as artsy (as in “this coffee thinks it’s better than me”) – good for the occasional cup but I’m not a huge fan.
+We have Peet’s coffee beans at the office so I haven’t really tried Peet’s at a store. In any case, these are all better than Starbucks, which is utter crap unless you get one of the specialty blends of the month rather than their regular coffees.
+Japanese noodles
+There are basically two good noodle places in the city center:
+If you have a car, drive to San Mateo, as there are some delicious noodle places there:
+Japanese curry
+Muracci’s (Union Square towards Financial District) specializes in Japanese curry. I go there so often it’s ridiculous, only open till 6pm and only on weekdays though.
+Kare-Ken (Tenderloin) is open after 5:30 till fairly late, however, their portions are smaller and the curry sauce isn’t quite as delicious as at Muracci’s.
+Vietnamese sandwitches (banh mi)
+These are a combination of Vietnamese -style veggies and meat in sandwitch form. Tasty and cheap.
+There are hole-in-the-wall type places where you can get two meals worth of food for 6-8 bucks:
+Vietnamese
+Pho = thin noodles with a ligher soup and veggies. The vermicelli noodle salad with spring rolls is also delicious. Check out:
+First steps
+I used the amd64 (e.g. x86-64) weekly testing build rather than the stable build, because, well it gets me on testing without needing to do a stable install first and comes with more up-to-date packages.
+While none of the docs make it clear, all you need is the first CD (or the netinstall build) to start the install.
+Edit sudoers
+su -c "visudo"At the end of the file, add:
+<code>yourusername ALL=(ALL) NOPASSWD: ALL</code>Copy ssh keys over from old machine
+Update and install packages
+Add "contrib" and "non-free" after "main" to /etc/apt/sources.list - this is needed for stuff like the flash plugin.
+If there are lines mentioning "cdrom:" as a source, delete or comment out those lines.
+sudo apt-get update && sudo apt-get upgrade
+
+sudo apt-get install git mlocate mercurial nitrogen wicd-gtk \
+gnome-icon-theme htop unzip openssl chromium-browser zsh \
+xterm epdfview mysql-server ruby tmux curl wget redis-server \
+xcursor-themes xarchiver gzip bzip2 zip unzip unrar p7zip \
+meld mplayer make gcc libc-dev build-essential openssl \
+libssl-dev libx11-dev libxinerama-dev guake xfce4-notifyd \
+keychain flashplugin-nonfree lxappearance treeInstall node
+mkdir other
+cd other
+wget http://nodejs.org/dist/v0.8.12/node-v0.8.12.tar.gz
+tar xvvf node-v0.8.12.tar.gz
+cd node-v0.8.12
+./configure && make && sudo make installInstall nwm, my window manager
+git clone git://github.com/mixu/nwm.git
+cd nwm
+npm installCreate ~/nwm.sh and chmod +x:
+#!/bin/sh
+/usr/local/bin/node /home/m/nwm/nwm-user-sample.js 2> ~/nwm.err.log 1> ~/nwm.logCreate /usr/share/xsessions/nwm.desktop:
+[Desktop Entry]
+Encoding=UTF-8
+Name=nwm
+Comment=This session starts nwm
+Exec=/home/m/nwm.sh
+Type=ApplicationSet the user shell from bash to zsh
+sudo chsh
+Set the default xdg-open action for PDFs
+In case you don't know what xdg-open is - it's the thing that decides what happens when you try to open a file (e.g. a downloaded file from Chrome).
+I don't want to open PDFs and PS files in Gimp, I want to open them in a document viewer
+xdg-mime default evince.desktop application/pdf
+xdg-mime default evince.desktop application/postscript
+To query the default app: xdg-mime query default $(xdg-mime query filetype FILENAME)
+Configuring appearance
+Download https://wiki.ubuntu.com/Artwork/Incoming/DustTheme and unzip the theme to ~/.themes/
+I find the easiest way to configure gnome2 is to use lxappearance, since it allows you to set the gnome theme and x11 cursors in a few clicks.
+gconftool-2 --set /apps/guake/general/use_vte_titles --type boolean falseEdit ~/.gitconfig:
+[color]
+ui = true
+[user]
+email =
+name =
+[core]
+editor = nano
+[alias]
+lg = log --graph --pretty=format:'%Cred%h%Creset-%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)%Creset' --abbrev-commit --date=relative
+[push]
+default = current# Lines configured by zsh-newuser-install
+HISTFILE=~/.histfile
+HISTSIZE=1000
+SAVEHIST=9999
+unsetopt beep
+bindkey -e
+# End of lines configured by zsh-newuser-install
+# The following lines were added by compinstall
+zstyle :compinstall filename '/home/m/.zshrc'
+
+autoload -Uz compinit
+compinit
+# End of lines added by compinstall
+
+bindkey "\e[1~" beginning-of-line # Home
+bindkey "\e[4~" end-of-line # End
+bindkey "\e[5~" beginning-of-history # PageUp
+bindkey "\e[6~" end-of-history # PageDown
+bindkey "\e[2~" quoted-insert # Ins
+bindkey "\e[3~" delete-char # Del
+bindkey "\e[5C" forward-word
+bindkey "\eOc" emacs-forward-word
+bindkey "\e[5D" backward-word
+bindkey "\eOd" emacs-backward-word
+bindkey "\e\e[C" forward-word
+bindkey "\e\e[D" backward-word
+bindkey "\e[Z" reverse-menu-complete # Shift+Tab
+# for rxvt
+bindkey "\e[7~" beginning-of-line # Home
+bindkey "\e[8~" end-of-line # End
+# for non RH/Debian xterm
+bindkey "\eOH" beginning-of-line
+bindkey "\eOF" end-of-line
+# for freebsd console
+bindkey "\e[H" beginning-of-line
+bindkey "\e[F" end-of-line
+# for guake
+bindkey "\eOF" end-of-line
+bindkey "\eOH" beginning-of-line
+bindkey "^[[1;5D" backward-word
+bindkey "^[[1;5C" forward-word
+bindkey "\e[3~" delete-char # Del
+
+alias ls='ls --color=auto -F'
+alias ga='git add'
+alias gp='git push'
+alias gl='git log'
+alias gs='git status'
+alias gd='git diff'
+alias gdc='git diff --cached'
+
+autoload -U colors && colors
+
+PROMPT="%{$fg_bold[white]%}[%1~]%{$reset_color%} "
+
+PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
+[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
+
+gr() {
+ local cmd="$"
+ for dir in /home/{FILL IN REPOSITORIES HERE}; do
+ (
+ print "\nin $dir"
+ cd $dir
+ eval "$cmd"
+ )
+ done
+}
+
+alias grs="gr git --no-pager status -sb"
+alias grl="gr git --no-pager log --decorate --graph --oneline -n 3"
+alias grd="gr git diff"
+alias grdc="gr git diff --cached"
+alias grn="gr npm ls"
+
+eval `keychain --eval --agents ssh id_rsa`
+
+# Stuff for git
+parse_git_branch () {
+ git branch 2> /dev/null | grep "" | sed -e 's/ (.)/ @\1/g'
+}
+
+# colors for prompt
+BLACK=$'\033[0m'
+RED=$'\033[38;5;167m'
+GREEN=$'\033[38;5;71m'
+BLUE=$'\033[38;5;111m'
+YELLOW=$'\033[38;5;228m'
+ORANGE=$'\033[38;5;173m'
+
+function precmd() {
+ export PROMPT="%{$fg_bold[white]%}[%1~%{$reset_color%}%{$YELLOW%}$(parse_git_branch)%{$fg_bold[white]%}]%{$BLACK%}%\ "
+}]]>1. Assume the reader has Internet and Google capabilities. Skip the parts that are covered better elsewhere or that will go out of date quickly. For example, installation tutorials are never up to date. I'll generally skip the sales pitch for the technology as well, since I'm here to tell you about the tech, not sell you on using it.
+2. Keep it short and to the point. I hate books that try to be cute or clever with me - if I want a story, I'll go read fiction. Similarly, don't surprise the reader with irrelevant sections. Just because you wrote it doesn't mean it should exist. I keep a crap file where all the useless text goes, and I usually have a couple of chapters worth of text that I delete. I've written several chapters on the history of a piece of tech, and always deleted them in the end.
+3. Use teasers, lists, tables and code blocks. Assume that the reader can get bored quickly, so throw in something interesting quick (a teaser) and support skimming readers with subheadings, lists and other structural elements.
+4. Don't treat everything as equally important. The easiest way to write a book about a piece of tech is to take the API, and then cover each and every function in it. It's also the worst possible way to do it. Unless you are writing the API docs, you should avoid talking about everything and focus on the interesting parts.
+As a reader, if I want to find out more, I can always read the API or code. What is much more important is understanding what are the neat things that I can do with the new tech, what kinds of patterns are common in using it and why you as the author think they are good or bad. Talk about how the pieces fit together. If everything is equally important, then nothing stands out. I like getting the author's angle on things, even if I might disagree with their choices, I still feel like I gain insight.
+5. Give me a choice in formats. Provide HTML, PDF, epub and mobi versions of long texts. Converting html for the Kindle just requires running one command with Calibre, so I wish more authors gave me the option to download their writing. For example, I wish I could get Google's tutorials for Android as a Kindle mobi book, since that's how I like to read long form writing.
+6. Help me navigate. Often, when I like what I read, I'll want to read more. Don't force me to go page by page through your writing. If you have a blog, have an archive that can show all the content, and let me get an idea of what else you've written about at a glance (a most popular list always helps).
+More about writing:
+http://www.paulgraham.com/writing44.html
+http://bighow.com/news/the-art-of-great-writing-60-writing-tips-from-6-alltime-great-writers
+http://dannystack.blogspot.com/2009/01/joss-whedons-top-10-writing-tips.html
++]]>
Setting up short aliases for you git commands changes everything.
+Two things: enable colors, and make git push push the current branch to a branch of the same name (and not all the branches, which is the default). This means when you do git push, it pushes your working branch but not other branches.
git config --global color.ui true
+git config --global push.default currentMaybe worth it:
+git config branch.autosetuprebase always
+git difftool -t <tool>
+git mergetool -t <tool>These are small things, but they make things so easy. I instinctively type gs after changing directory nowadays.
+alias ga='git add'
+alias gp='git push'
+alias gl='git log'
+alias gs='git status'
+alias gd='git diff'
+alias gdc='git diff --cached'
+alias g='git'
+git config --global alias.lg "log --graph
+ --pretty=format:'%Cred%h%Creset-%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset'
+ --abbrev-commit --date=relative"Apparently, the "git lg" above can be replicated fairly well with:
+git log --decorate --graph --onelineThis one is way simpler than those fancy ones offered elsewhere, but it works well for me:
+# get the current branch
+parse_git_branch () {
+ git branch 2> /dev/null | grep "" | sed -e 's/ (.*)/ @\1/g'
+}
+
+# colors
+BLACK=$'\033[0m'
+RED=$'\033[38;5;167m'
+GREEN=$'\033[38;5;71m'
+BLUE=$'\033[38;5;111m'
+YELLOW=$'\033[38;5;228m'
+ORANGE=$'\033[38;5;173m'
+
+function precmd() {
+ export PROMPT="%{$fg_bold[white]%}[%1~%{$reset_color%}%{$YELLOW%}$(parse_git_branch)%{$fg_bold[white]%}]%{$BLACK%}%\ "
+}A fairly simple way of doing this is to add a function that you can use to run the same command in multiple directories. This one is for zsh:
+gr() {
+ local cmd="$*"
+ for dir in /home/m/repos/{one,two,three}; do
+ (
+ print "nin $dir"
+ cd $dir
+ eval "$cmd"
+ )
+ done
+}
+
+alias grs="gr git --no-pager status -sb"
+alias grl="gr git --no-pager log --decorate --graph --oneline -n 3"
+alias grd="gr git diff"
+alias grdc="gr git diff --cached"
+alias grn="gr npm ls"In the example below, I 1) switch all working repos to master, 2) fetch the recent remote changes, 3) check the status of every repository, and 4) after going into those couple of dirs and stashing stuff (not shown in detail), pull all repos to update them
+gr git checkout master
+gr git fetch
+grs
+in /home/m/repos/one
+## master
+in /home/m/repos/two
+## master...origin/master [behind 8]
+in /home/m/repos/three
+## master...origin/master [behind 4]
+ M Makefile
+gr git pull$ git add -AAdds all files and file deletes, so you don't need to enter them manually.
+$ git add -uSame, but doesn't add files that didn't exist before.
+$ git log -p.. to show the patches alongside the log
+git log --author="git config --get user.name" --pretty=format:'%h %an %Cred%ar %Cgreen%s' v1.0.1..mastergit supports friendly dates specs:
+git log HEAD@{one.day.ago}Shows the commits that you've made between "refactor" and "master", e.g. for emailing a changelog with your commits:
+6591466 Mikito Takada 7 months ago Port over more code
+1f464fb Mikito Takada 7 months ago Refactor window
+41a3ec9 Mikito Takada 9 months ago Handle switching from window to root window$ git log staging -1 -p -- my/subdirShow the latest commit that affects the my/subdir path on the branch "staging" with the patch.
+$ git log --statShow the changed files only.
+$ git log --author=fooOnly commits by author foo.
+$ git log --stat -- subdirectoryShow the commits affecting only "./subdirectory", with a summary of the files (--stat).
+For example:
+$ git log --stat -- .Shows the summary of commits affecting the current directory.
+$ git log --grep='.foo.'Grep for a specific log message.
+$ git log --since="1 week ago" --until="2 weeks ago"Filter commits by date.
+$ git shortlog -snShows a "top contributors list" by commits.
+branch^ first parentbranch^2 merge parentbranch~5 five first-parents backbranch:path/to/file directly get a blobbranch@{yesterday} local date based referencebranch@{5} the 5th last value of branch (locally)Differences between the staged files and the last commit:
+$ git diff --cachedI use that a lot just before committing the changes to check what my commit changed.
+So git diff is for the files that are unstaged, while git diff --cached is for staged files.
+What's different between my branch and some other branch, e.g. master?
+$ git diff my_branch..masterWhat changed in the last three commits?
+$ git diff HEAD^3Ignore whitespace?
+$ git diff HEAD^ --word-diffWhat's different between my branch and some other branch in subdirectory (or file)?
+$ git diff my_branch..master subdirectoryRemember, git diff outputs an applicable patch:
+$ git diff > my.patch
+$ git apply < my.patchFor example, I once used git diff to generate a patch for a folder that was missing it's .git directory, and then applied that patch to a live environment (patching a test VM):
+git diff --no-index --diff-filter=MRC -- ./lib ../myapp/lib > my.patch
+cd ../myapp/
+git apply ../myapp-git/my.patch$ git grep -e foo --or -e bar --not -e bazGrep for foo or bar, but exclude the expression baz.
+$ git grep --untracked fooInclude untracked files in grep.
+$ git grep --cached fooInclude cached (staged) files in grep.
+$ git grep --no-index foo /var/barUse "git grep" instead of regular grep, grep for foo in /var/bar. Compared to regular grep, git grep is nicer due to the colors and paging defaults.
+List all require('foo') statements content (sed to filter out just the string).
+git grep -h -e "require[(]'[a-zA-Z]" | sed -E "s/.require(.([a-zA-Z][^']+).)./\1/" | sort | uniq
+Checkout the branch you want to base your work on:
+$ git checkout masterThen create a branch and check it out:
+$ git checkout -b local_namePush the branch to the remote
+$ git push -u origin local_nameLater on, merge it:
+$ git checkout master$ git merge local_nameLook at the unmerged branches:
+$ git branch --no-mergedLook at branches that contain a particular commit (e.g. when cherrypicking):
+$ git branch --contains 1234abcdInstalling:
+cp pre-commit.sh .git/hooks/pre-commit
+chmod a+x .git/hooks/pre-commitExamples:
+If all you need is a place for storage, you just need sshd and disk space.
Setting up a remote repository
+~/.gitignore for globally excluded files:
npm-debug.log
+.DS_Store
+.DS_Store?
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db.git/info/exclude for files you want to exclude without changing the gitignore file:
conf/*.gitignore for a checked in list of excluded paths:
node_modules/Whitelisting a directory (note: needs the rest of the path):
+static/mixu.net/blog/*
+!static/mixu.net/blog/assets/$ git stash
+$ git stash list
+$ git stash applyYou can specify a specific stash item from the git stash list output to apply or remove:
$ git stash apply stash@{0}
+$ git stash drop stash@{0}$ git blame path/to/fileSee who changed what.
+$ git blame abce1234^ path/to/fileSee the blame, starting one commit before abce1234. E.g. when you need to trace back a particular line of code in history.
+Changing from Github to Bitbucket
+$ git remote -v # look at remotes$ git remove rm origin # delete$ git remote add origin git://addr/to/repo # add new remote$ git push -u origin master # push to new remoteAdding a upstream repo to pull in new changes from a forked project
+$ git remote add upstream git://addr/to/repo$ git checkout master && git pull upstream masterFor small commits made on top of a frequently changing branch like master, you might want to rebase your local changes on top of the current remote before you merge a feature branch (more in depth):
+$ git pull --rebase$ git pushList all branches:
+$ git branch -aUnmerged branches:
+$ git branch --no-mergedCheckout a branch (protip, zsh does git branch completion):
+$ git checkout nameIf there is a branch called origin/name and you checkout name, then name will be set to track origin/name automatically (that means that git pull works, for example).
Create a feature branch based on the current branch:
+$ git checkout -b nameCreate a orphan branch (no history) for storing documentation or resources:
+$ git checkout --orphanMerge branches:
+$ git mergeApply a commit from another branch:
+$ git cherry-pick sha1_of_commitReset the branch to the current head:
+$ git reset --hard HEADWhen a branch tracking a remote has become outdated (e.g. you are on staging now but your commits have diverged):
+$ git reset --hard origin/stagingReset a single file to HEAD:
+$ git checkout -- path/to/fileReverting (unapplying) a bad commit:
+$ git revert sha1_of_commitTaking the current branch and creating a version that's squashed into one commit:
+$ git checkout -b new-branch
+$ git rebase -iDuring the rebase, only pick one commit and squash the rest.
+First, remove local branches that do not exist on origin (--dry-run if you want to preview):
+$ git remote prune origin$ git branch -r | wc -l
+ 123Get the latest commit of all remote branches
+[gist id=2313880]
+Get the latest commit of all remote branches, and summary, ordered by age
+Use this Node script:
+https://gist.github.com/91ba46dee32b221b3a84
+Delete a local branch:
+git branch -d some_branch_nameReally delete a local branch, even if git complains about it in the previous command:
+git branch -D some_branch_nameDelete a remote branch, e.g. in Github:
+git push origin :some_branch_nameThe reason for that syntax is that you can do git push origin local_branch_name:remote_branch_name so what that line above is doing is essentially pushing NULL to the remote branch, thereby killing it off.
In git >= v1.7.0:
git push origin --delete <branchName>git add -i
+git reflog]]>Well, there is whole world of keyboards that are even better, namely: buckling spring keyboards (e.g. the IBM Model M), Cherry MX switch keyboards and Topre switch keyboards.
+I got this one for my place - Cherry MX brown switches, which are less noisy (though definitely they could be even more silent):
+ +The major difference between a mechanical keyboard and a regular one is in the feel of the keys. Mechanical keyboards have metallic springs, while cheaper keyboards just have some flexible plastic. After a short while typing on the MS Ergonomic keyboard started feeling like typing on a mushy piece of plastic compared to the mechanical keyboard. I do kind of miss the more ergonomic split layout, but typing is just a lot nicer overall on a mechanical keyboard.
+I ended up buying two keyboards, both with Cherry MX switches (~110 USD from here). I didn't get a buckling spring keyboard, because they are more noisy and there aren't any space-saving tenkeyless models available. The third alternative - keyboards with Topre switches - are more expensive (~300+ USD) and have been described as less tactile. I'll probably get a Topre keyboard eventually anyway, just so I can try it out.
+Here is the new keyboard I use at work, which has Cherry MX blue switches (a bit more noisy than my other keyboard, but definitely one I prefer):
+ +Best purchase in a long time!
+]]>Edit /etc/rc.conf. Add thinkpad_acpi to MODULES=() in the hardware section.
+Create a new file enabling fan control as /etc/modprobe.d/thinkfan.conf:
+options thinkpad_acpi fan_control=1sudo modprobe -r thinkpad_acpi && sudo modprobe thinkpad_acpiTo view the current fan speed:
+[~]$ cat /proc/acpi/ibm/fan
+status: enabled
+speed: 2887
+level: 4
+commands: level ( is 0-7, auto, disengaged, full-speed)
+commands: enable, disable
+commands: watchdog ( is 0 (off), 1-120 (seconds))To control fan speed:
+# echo level 0 | sudo tee /proc/acpi/ibm/fan (fan off)
+# echo level 2 | sudo tee /proc/acpi/ibm/fan (low speed)
+# echo level 4 | sudo tee /proc/acpi/ibm/fan (medium speed)
+# echo level 7 | sudo tee /proc/acpi/ibm/fan (maximum speed)
+# echo level auto | sudo tee /proc/acpi/ibm/fan (automatic - default)For easy control from the command line:
+function fan() {
+ sensors
+ echo level $@ | sudo tee /proc/acpi/ibm/fan
+}Now you can run fan 2 to set the fan level to 2 and so on.
To view fan speed, install lm_sensors following the instructions on the Arch wiki. Example output:
+[~]$ sensors
+acpitz-virtual-0
+Adapter: Virtual device
+temp1: +37.0°C (crit = +99.0°C)
+
+thinkpad-isa-0000
+Adapter: ISA adapter
+fan1: 2904 RPM
+
+coretemp-isa-0000
+Adapter: ISA adapter
+Physical id 0: +39.0°C (high = +86.0°C, crit = +100.0°C)
+Core 0: +37.0°C (high = +86.0°C, crit = +100.0°C)
+Core 1: +37.0°C (high = +86.0°C, crit = +100.0°C)
+Core 2: +35.0°C (high = +86.0°C, crit = +100.0°C)
+Core 3: +39.0°C (high = +86.0°C, crit = +100.0°C)Mateusz Loskot: Thanks for the quick and clear how-to. +FYI, I used it in my response to one of thinkfan questions on the Arch forum: +https://bbs.archlinux.org/viewtopic.php?pid=1112691#p1112691
+]]>I wrote a benchmarking suite (siobench). The benchmark is rather simple. Clients connect one at a time, and a new client is only allowed to connect when the previous one is connected. When the server has used up 5000 milliseconds of CPU time, the benchmark is stopped. Every second, every connected client sends a single message which is echoed back by the server (more details).
+This workload is geared towards a situation where Socket.io is used to notify people of things as part of a larger application: e.g. most of the load is assumed to be idling connections rather than real-time messaging like in, say, a multiplayer game.
+The "end of test" condition is 5000 ms of CPU time, because this seemed to be a easy way to give all implementations the same amount of time. CPU usage % is not accurate, since it is dependent on how much CPU time the process gets over a particular amount of wallclock time. In the graphs the CPU usage % calculated over a 100ms interval, while usertime and systime are the actual numbers reported at that particular time.
+| Node (0.4.12) using tcp | +~ 8000 connections on a single core | +
| socket.io 0.6.17 using websockets | +~ 2300 connections on a single core | +
| socket.io 0.7.11 using websockets | +~ 1800 connections on a single core | +
| socket.io 0.8.6 using websockets | +~ 1900 connections on a single core | +
Note that the absolute numbers are mostly unimportant - I ran this on the following 15" Macbook Pro running Arch with the 3.1.04 Linux kernel in Virtualbox with 4096 Mb of RAM, a SSD and four cores (Intel(R) Core(TM) i7-2635QM CPU @ 2.00GHz GenuineIntel GNU/Linux). You can get numbers that are more representative of your system by getting siobench and running it:
+Usage: node siobench.js [env]
+A tool for benchmarking your Socket.io server.
+
+Available environments:
+ 0.6.17
+ 0.6.17_poll
+ 0.7.11
+ 0.8.7
+ 0.8.7_poll
+ tcpYou can also write your own benchmarks under ./bench, by writing a new server.js (example #1, #2) and a new client.js (example #1, #2). Each benchmark has it's own set of npm dependencies installed, so that one can run benchmarks against many versions of socket.io.
+Some notes on performance
+The relative performance is more interesting.
+First, the node TCP speed represents the highest achievable performance on this benchmark, since it only uses the built-in TCP implementation. Compared to this, Socket.io is has about 1/3 of the performance (~ 2300 vs ~8000 connections) when using WebSockets.
+Second, it appears that 0.8.7 is about 20% slower than 0.6.17 on this benchmark. If I remember correctly, Socket.io 0.7 switched to a new protocol, and there are clearly some performance improvements over 0.7.11 in 0.8.7 (+100 connections in this bench); it's just that the overall performance is still worse in this benchmark than in the old 0.6.17 branch.
+Working towards higher-performance
+As this is just a simple benchmark, I don't really have solutions - only some suggestions.
+1) A CI build that includes benchmarks and community contributed test cases
+First, I'd love to see a CI build for Socket.io that would include performance benchmarks and community contributed test cases.
+However, currently setting up a CI build for Socket.io is difficult because the bundled test suite only works on OSX. It would be a lot easier to contribute if the tests worked on other platforms.
+I am hoping that as Engine.io gets going, the test suite will be fixed so that it can be run on other platforms. Otherwise, contributing improvements will be tricky/impossible since there is no way to tell whether the code works.
+2) More realistic performance test scenarios
+The current test scenario is rather limited in that it mostly tests performance in terms of establishing connections (without terminating them). I'd love to hear more realistic scenario suggestions, particularly from people who have run into memory usage issues.
+siobench is only a starting point: it's way better than just looking at htop and wondering whether performance was better in the last version or not. There are still specific questions that should be formulated as replicable tests.
+3) A polling transport that works on Node.js
+I did write tests for the xhr-polling transport for Socket.io as well. These showed much worse performance, around:
+4) Comparative benchmarks
+Hopefully, this will help with performance testing new releases of Socket.io and other Comet libraries. Since the plan is that Engine.io will allow people to work with a lower level than Socket.io, there might be new performance oriented versions, and it would be useful to see benchmarks for those. Re: the other Node.js pubsub frameworks: I can't benchmark Faye, because it does not provide the right API out of the box, and Juggernaut uses Socket.io internally.
+I'm going to use siobench it for internal testing to ensure that the pubsub implementation I am working on (built over Socket.io) will not have performance regressions.
+The full graphs are below. Please leave comments and suggestions for improvements - I am hoping that the developer community around Socket.io can help in improving the performance going forward, kind of like what Mozilla did with "arewefastyet.com".
+Socket.io 0.6.17 - Websockets - CPU usage and time
+ + +Socket.io 0.6.17 - Websockets - resident set size
+ +Xananax: Hey Mixu. My comment is totally unrelated to your post (which has been useful to me by the way). You don't know me, but I know you a little: I have been following your blog for a while now. But I never had a compelling reason to write something. +So even if it messes up a bit with the rigor of coder's comment that should always be constructive, I wanted to express my thanks as your writings have been an invaluable source of information and inspiration to me. Always interesting, always well written, always well presented. Keep up the good work! +Wish you the best for this new year.
+Mikito Takada: Thanks! This comment made my day. 2012 will be a great year!
+Karen: You can check with this: https://github.com/sockjs/sockjs-node ?
+Luc: Hi,
+I've tried to fetch your project on github and when I do "npm install" I've got an error fetching dependencies :
+npm ERR! git clone git@github.com:mixu/nodeunit-runner.git Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
+npm ERR! git clone git@github.com:mixu/nodeunit-runner.git Permission denied (publickey).
+npm ERR! git clone git@github.com:mixu/nodeunit-runner.git fatal: The remote end hung up unexpectedly
+npm ERR! Error: git "clone" "git@github.com:mixu/nodeunit-runner.git" "/tmp/npm-1330952664150/1330952664173-0.6050085364840925" failed with 128
+npm ERR! at ChildProcess. (/usr/lib/nodejs/npm/lib/utils/exec.js:49:20)
+npm ERR! at ChildProcess.emit (events.js:70:17)
+npm ERR! at maybeExit (child_process.js:361:16)
+npm ERR! at Socket. (child_process.js:466:7)
+npm ERR! at Socket.emit (events.js:67:17)
+npm ERR! at Array.0 (net.js:320:10)
+npm ERR! at EventEmitter._tickCallback (node.js:192:40)
Do you have any ideas ?
+rufinus: just change the github rep url to git://github.com/sockjs/sockjs-node.git in the config file for the npm he used his personal read/write url.
+thanks for this article, its exactly what we have seen and couldnt believe it.
+]]>First steps
+dhcpcd eth0 #if you did not add "interface=eth0" in rc.conf during setup
+pacman -SyuFixes:
+http://www.archlinux.org/news/initscripts-update-manual-intervention-required/
+rm /etc/profile.d/locale.shhttp://www.archlinux.org/news/filesystem-upgrade-manual-intervention-required/
+pacman -S filesystem --forcepacman -S sudo
+vim /etc/sudoers # add yourself to sudoers
+sudo vim /etc/pacman.conf # set SigLevel = Never TrustAll
+sudo shutdown-r nowInstall X11:
+pacman -S xorg-server xorg-xinit xorg-utils xorg-server-utils xtermIf virtualized in VirtualBox, make copy-paste work first:
+pacman -S virtualbox-archlinux-additions
+Create a new user
+pacman -S zsh
+useradd -m -g users -G audio,lp,optical,storage,video,games,power,scanner -s /bin/zsh USERNAME
+su USERNAME
+passwdAdd x11
+pacman -S xorg-server xorg-xinit xorg-utils xorg-server-utilsCopy ssh keys over from old machine +Useful packages
+pacman -S base-devel sudo python2 git libev mlocate mercurial nitrogen
+sakura wicd-gtk pcmanfm gnome-icon-theme htop unzip
+openssl chromium flashplugin bash-completion xterm
+epdfview mysql ruby tilda tmux wget redis xcursor-vanilla-dmz
+xarchiver gzip bzip2 zip unzip unrar p7zip
+meld ttf-ubuntu-font-family mpg123 alsa-utils redis mysql ruby libxsltAdd ~/.Xresources:
+Xcursor.theme: vanilla-dmz
+Xcursor.size: 16 ! 32, 48 or 64 may also be good valuesConfiguring git
+git config --global color.ui trueConfiguring sakura
+I want to use ctrl + Page_Up / Page_Down to switch tabs, so edit ~/.config/sakura/sakura.conf:
+switch_tab_accelerator=4 # since <a>GDK_CONTROL_MASK</a> is 1 << 2, e.g. 4.
+prev_tab_key=Page_Down
+next_tab_key=Page_UpSome basic niceties: whatprovides, service and chkconfig
+pacman -S pkgtoolsfunction service() {
+ sudo /etc/rc.d/$1 $2
+}
+
+alias chkconfig='cat /etc/rc.conf | grep DAEMONS && echo "cat + grep /etc/rc.conf"'This makes service an alias for /etc/rc.d/ and prints out the enabled services from /etc/rc.conf. While we're editing .bashrc, might as well add:
+PS1="[W]$ " # my preferred bash prompt (e.g. only the current dirname).
+ulimit -s 16400 # higher stack limit
+# ssh-agent
+SSH_ENV="$HOME/.ssh/environment"
+function start_agent {
+ echo "Initialising new SSH agent..."
+ /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
+ echo succeeded
+ chmod 600 "${SSH_ENV}"
+ . "${SSH_ENV}" > /dev/null
+ /usr/bin/ssh-add;
+}
+# Source SSH settings, if applicable
+if [ -f "${SSH_ENV}" ]; then
+ . "${SSH_ENV}" > /dev/null
+ #ps ${SSH_AGENT_PID} doesn't work under cywgin
+ ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
+ start_agent;
+ }
+else
+ start_agent;
+fiInstalling Node and NPM
+You can just do:
+pacman -S nodejsIf you're OK with that version, which seems to track the Node releases pretty well.
+Arch uses python3 as python. You need to change python to python2 (thanks Rob Searles!)
+# node.js fix for arch (use python2)
+mkdir /tmp/bin
+ln -s /usr/bin/python2 /tmp/bin/python
+export PATH=/tmp/bin:$PATHYou can then do a regular node install:
+git clone git://github.com/joyent/node.git
+git checkout v0.4.12
+./configure
+make
+sudo make install
+Remember to install npm as well:
+curl http://npmjs.org/install.sh | sudo shInstalling my window manager and personal config
+git clone git://github.com/mixu/nwm.git
+cd nwm
+node-waf clean || true && node-waf configure build
+sudo npm link # add a global npm symlink to this repository - so nwm-user can find it (man npm link)
+cd ..
+git clone git://github.com/mixu/nwm-user.git
+cd nwm-user
+npm link nwm # now make a symlink to the nwm installationAdd it to ~/.xinitrc (change paths!!):
+exec /usr/local/bin/node ~/mnt/nwm-user/nwm-user.js 2>~/nwm.err.log 1>~/nwm.logAnd while we're at it, lets add some other stuff:
+VBoxClient-all &
+export PATH=/tmp/bin:$PATH # for node-waf, too lazy to work on a better solution
+xset +fp /usr/share/fonts/local
+xset fp rehashRun "startx" to start X11 with nwm.
+Installing my mp3 player
+First, we need to configure alsa (included by default):
+pacman -S mpg123 alsa-utilsRun:
+alsamixerand turn on Master and PCM channels (by pressing m) as they are muted by default.
+sudo alsactl storeThen continue:
+git clone git://github.com/mixu/nplay.gitRun nplay with
+node nplay.jsTODO: fix directory in source code and change backend from mpg321 to mpg123.
+Switching the keyboard language in X11
+I sometimes need to write emails in Finnish, so here is how to switch the layout:
+<code>setxkbmap -layout fi # revert back </code><span class="Apple-style-span" style="font-family: monospace;">setxkbmap -layout us</span><span class="Apple-style-span" style="font-family: monospace;"> </span>Install yaourt
+Install dependencies
+yaourt libpng12 gtk2-theme-dust
++
Install Sublime Text 2
+Sublime Text needs libpng12, which you have to install from AUR:
+wget http://aur.archlinux.org/packages/li/libpng12/libpng12.tar.gz
+tar -xzvf libpng12.tar.gz
+cd libpng12
+makepkg
+pacman -U ./libpng12-1.2.46-2-x86_64.pkg.tar.xzThen download and run Sublime Text 2.
+Also, you might want to ger http://aur.archlinux.org/packages/gt/gtk2-theme-dust/gtk2-theme-dust.tar.gz.
+Configuring Sublime Text 2
+locate Packages # returns ~/.config/sublime-text-2/Packages
+cd ~/.config/sublime-text-2/Packages
+git clone https://github.com/buymeasoda/soda-theme/ "Theme - Soda"
+cd User
+wget http://blog.mixu.net/files/2010/05/my_themes.zip # Install my themes
+unzip my_themes
+rm my_themes.zipBase File settings
+{
+ // FONTS and COLORS
+ "color_scheme": "Packages/User/Mixu Espresso.tmTheme",
+ "font_size": 11,
+ "tab_size": 2,
+ // WHITESPACE
+ // Set to true to insert spaces when tab is pressed
+Comments
+Kenneth: What are the advantages of your window manager? I'm currently using awesome wm on arch. The javascript configuring sounds cool.
+Mikito Takada: Mostly: configurability and the ability to customize things like layouts in JS. And you don't need any additional tech beyond Node + npm, so if you are already doing Node dev it's a lightweight option.
+jiyinyiyong: As I failed to install Xmonad on Ubuntu 12.04 , I tried NWM, really concise WM. I was supposing to get a WM like Xmonad with Gnome whose fonts and menus look more beautiful(maybe get panels as well..). I've went through the docs on the site, but is there more detail about making NWM look better?
+Mikito Takada: nwm works with both Gnome and KDE apps, but it's a window manager, not a desktop environment.
+http://en.wikipedia.org/wiki/Desktop_environment vs http://en.wikipedia.org/wiki/Window_manager
+E.g.:
+I'd love to write all that, but I'm just one dude. Writing a desktop environment is a bit too much for a for-fun project ;).
+For better looking fonts, I use the Ubuntu font rendering patchset for Arch; for better menus I use a Gnome theme.
+jiyinyiyong: (I'm late.. but didn't received e-mail about the reply.. ) +OK, I'll make effort to get familiar about X11 and things like that. So far I just want to try cool stuffs writtern in Node. Really thanks.
+jsc: You probably found a way by now, but if not, I would like to mention gtk-theme-switch. It's in the default repos of 12.04 and requires no logout to take effect.
+It does what it says on the box: changes your gtk theme to any other one you have installed, which on 12.04 should be at least Ambiance and Radiance.
+]]>The goal here is to:
+Socket.io supports multiple different transports:
+Nginx is generally the first recommendation for Node.js deployments. It's a high-performance server and even includes support for proxying requests via the HttpProxyModule.
+However, -- and this should be made much obvious to people starting with Socket.io -- the problem is that while Nginx can talk HTTP/1.1 to the client (browser), it talks HTTP/1.0 to the server. Nginx's default HttpProxyModule does not support HTTP/1.1, which is needed for Websockets.
+Websockets 76 requires support for HTTP/1.1 as the handshake mechanism is not compatible with HTTP/1.0. What this means is that if Nginx is used to reverse proxy a Websockets server (like Socket.io), then the WS connections will fail. So no Websockets for you if you're behind Nginx.
+There is a workaround, but I don't see the benefit: use a TCP proxy (there is a custom module for this by Weibin Yao, see here ). However, you cannot run another service on the same port (e.g. your main app and Socket.io on port 80) as the TCP proxy does not support routing based on the URL (e.g. /socket.io/ to Socket.io and the rest to the main app), only simple load balancing.
+So the benefit gained from doing this is quite marginal: sure, you can use Nginx for load balancing, but you will still be working with alternative ports for your main app and Socket.io.
+HAProxy is not generally compatible with Websockets, but Socket.IO contains code which works around this issue and allows you to use HAProxy. This means that the alternatives are:
+cert = /path/to/certfile.pem
+; Service-level configuration
+[https]
+accept = 443
+connect = 8443If you only have one Node instance, you can skip setting up HAProxy, since you don't need load balancing.
+Note that we need TCP mode in order to support Flash sockets, which do not speak HTTP.
+Flash sockets are just plain and simple TCP sockets, which will start by sending the following payload: '<policy-file-request/>'. They expect to receive a Flash cross domain policy as a response.
+Since Flash sockets don't use HTTP, we need a load balancer which is capable of detecting the protocol of the request, and of forwarding non-HTTP requests to Socket.io.
+HAProxy can do that, as it has two different modes of operation:
+We accept connections on two ports: 80 (HTTP) and 8443 (Stunnel-terminated HTTPS connections).
+By default, everything goes to the backend app at port 3000. Some HTTP paths are selectively routed to socket.io
+TCP mode is needed so that Flash socket connections can be passed through, and all non HTTP connections are sent to the TCP mode socket.io backend.
+# Main frontend
+frontend app
+ bind 0.0.0.0:80
+ bind 0.0.0.0:8443
+ # Mode is TCP
+ mode tcp
+ # allow for many connections, with long timeout
+ maxconn 200000
+ timeout client 86400000
+
+ # default to webapp backend
+ default_backend webapp
+
+ # two URLs need to go to the node pubsub backend
+ acl is_socket_io path_beg /node
+ acl is_socket_io path_beg /socket.io
+ use_backend socket_io if is_socket_io
+
+ tcp-request inspect-delay 500ms
+ tcp-request content accept if HTTP
+ use_backend sio_tcp if !HTTPPort 843: Flash policy
+Flash policy should be made available on 843.
+# Flash policy frontend
+frontend flashpolicy 0.0.0.0:843
+ mode tcp
+ default_backend sio_tcpDefault backend
+This is just for your main application.
+backend webapp
+ mode http
+ option httplog
+ option httpclose
+ server nginx1s localhost:3000 checkSocket.io backend
+Here, we have a bunch of settings in order to allow Websockets connections through HAProxy.
+backend socket_io
+ mode http
+ option httplog
+ # long timeout
+ timeout server 86400000
+ # check frequently to allow restarting
+ # the node backend
+ timeout check 1s
+ # add X-Forwarded-For
+ option forwardfor
+ # Do not use httpclose (= client and server
+ # connections get closed), since it will close
+ # Websockets connections
+ no option httpclose
+ # Use "option http-server-close" to preserve
+ # client persistent connections while handling
+ # every incoming request individually, dispatching
+ # them one after another to servers, in HTTP close mode
+ option http-server-close
+ option forceclose
+ # just one node server at :8000
+ server node1 localhost:8000 maxconn 2000 checkSocket.io backend in TCP mode
+Tom: How are you handling HTTP requests then?
+Mikito Takada: As configured above, HAProxy listens at two ports:
+80 (e.g. for direct HTTP requests) +8443 (e.g. for SSL-terminted HTTP requests)
+And the default HAProxy backend is the main app.
+HTTP comes in at port 80 to HAproxy. +HTTPS comes in at port 443 -> Stunnel terminates SSL -> 8443
+Andrew: Hi, we've been integrating support for http/1.1 to backends for nginx lately. Would you like to test your setup with http/1.1 development code? Would be much appreciated.
+mikong: Hi Andrew,
+We're working on NodeJS apps that needs Websockets, and thanks to your comment, we'll be taking a look at the development version of Nginx. We'll send you feedback for any problems.
+Patrick: Hi there,
+I'm trying to setup something similar. I have a rails app on port 3000, and a nodejs app on port 3001. The nodejs app doesnt only do sockets though... it also has a little http api using Express.
+I wanted to have a different subdomain for each app, and use haproxy to serve the right thing but I can't seem to see how to do that... seems like when I use tcp mode I can't really do anything regarding the domain that was requested.
+Mikito Takada: Yeah, I found the tcp mode somewhat limited in Haproxy. You might want have a look at node-http-proxy...
+Patrick: I tried that first actually, for some reason I could not get node-http-proxy to work for Chrome PC and Internet Explorer. Or at least, socket.io seems to fall back to polling transports for some browsers when behind node-http-proxy. But maybe my configuration was wrong...
+Joe Lindsay: We need to solve this problem, how can I get the right bytes to test http/1.1 backends to nginx?
+theTestTube: Maybe the following directive can let you deal with "[...] The nodejs app doesnt only do sockets"
+acl websocket hdr(Upgrade) -i WebSocket
+I found this at http://stackoverflow.com/questions/2419346/can-nginx-be-used-as-a-reverse-proxy-for-a-backend-websocket-server
+Luke: This configuration does not work for me. According to HAProxy docs you cannot use layer 7 filtering with TCP mode. On my setup this caused to use random backend.
+I managed to fix this configuration in HTTP mode. The main was flash-policy-file serving - it is not served if socket.io client manage to get the policy from the same server on port 843.
+If you provide policy file on that port then flash will not request policy file and use standard HTTP headers for communication. This makes HAProxy happy.
+My config is here: +http://pastebin.com/g8KQSWTW
+Many thanks for your post - it was the best starter to make websockets, xhr-pooling and flashsockets to work with HAProxy.
+Pau ramon: I use substacks bouncy https://github.com/substack/bouncy
+Mike Lewis: With newer versions of nginx you can use 1.1 for reverse proxying.
+This seems to work for reverse proxying websocket connections:
+location / {
+ chunked_transfer_encoding off;
+ proxy_http_version 1.1;
+ proxy_pass http://localhost:9001;
+ proxy_buffering off;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header Host $host:9001;
+ proxy_set_header Connection "Upgrade";
+ proxy_set_header Upgrade websocket;
+}Jimb Esser: I did a bunch of experimenting and some digging, and it appears there is not currently any way to get nginx to work with websockets using a method like that. WebSockets needs more than just forwarding a request, and the nginx developers say more work would need to be done to get it proxying websockets. You can, however, use nginx with the tcp proxying module to blindly load-balance, and then put stunnel on each of your application servers, though that removes most of the benefit of nginx.
+Ximonn: Why not do it simple and use two servers. Then configure dns to point socket.mydomain.com to the websocket server and mydomain.com to the nginx server. +You use different IP's but the same domain name, sofar I havent seen any issue with that.
+Edgar: Trying to load balance several node.js servers but can't make it work. +When using more than one server, the browser seems to keep reconnecting. +Everything is great when using just one node.
+The haproxy conf I'm using is the following. +Am I missing anything?
+backend socket_io + balance roundrobin
+mode http
+option httplog
+
+# long timeout
+timeout queue 5000
+timeout server 86400000
+timeout connect 86400000
+
+# check frequently to allow restarting
+# the node backend
+timeout check 1s
+
+# add X-Forwarded-For
+option forwardfor
+
+# Do not use httpclose (= client and server
+# connections get closed), since it will close
+# Websockets connections
+no option httpclose
+
+# Use "option http-server-close" to preserve
+# client persistent connections while handling
+# every incoming request individually, dispatching
+# them one after another to servers, in HTTP close mode
+option http-server-close
+option forceclose
+
+
+# balance
+server node1 127.0.0.1:8001 weight 1 maxconn 2000 check
+server node2 127.0.0.1:8002 weight 1 maxconn 2000 checkMikito Takada: Hi Edgar,
+You can't round robin Socket.io - it's a protocol spec limitation.
+I've written a follow up to this post on my book, just skip to the section "Sample deployments: scaling" at http://book.mixu.net/ch13.html
+Edgar: Hi,
+You saved my day. +Thanks.
+James: I believe that would run amok of SOP restrictions
+Ram: How about node-http-proxy - https://github.com/nodejitsu/node-http-proxy
+coryvirok: Great post! I setup the same deployment for https://ratchet.io/ earlier this year. We are, however running into some trouble with stunnel not setting the x-forwarded-for header. Looks like stunnel supports something like this via the transparent=source config option however our server's kernel doesn't have the necessary flags enabled.
+Are you able to get the incoming client IP from your node.js or ruby servers?
+Axel: Another way to deploy Socket.IO is to use Kaazing's HTML5 Gateway. Kaazing will proxy the Socket.IO traffic and it takes care of the scaling, emulation, clustering, security and even provides an SSO integration. The Gateway is basically like a network router, except it's protocol aware. Kaazing does all the emulation if WS is not available in a particular browser so you don't have to worry about getting polling and Flash-Socket to work. In fact, the polling fall back from Socket.IO is really slow, and also seriously increases the battery consumption on mobile apps. And Flash Socket is notoriously insecure. Kaazing will emulate WS all the way back to an old IE6 browser as well, and doesn't have the firewall traversal issues that Socket.IO's alternate transport layers have.
+All you have to do is to put Node.JS behind the Gateway and use only the WS transport. You just use the Kaazing client library below the Socket.IO client library and you make sure the client also uses the WS transport only. The Gateway will readily take care of all production needs from there on. Their Cloud solution is relatively cheap, you can just rent an EC2 instance, the cost is a tiny fraction on top of what EC2 charges, and it adds up to much less than some of the basic publish/subscribe service providers out there. And there is no lock in because the entire Kaazing stack is based on the WS standard, so you just program against the WS APIs.
+Now a disclaimer: I work for Kaazing, but I am not posting this on behalf of Kaazing. I happen to be a major fan and enthousiast of Node.JS, and I would like to see more Node.JS adoption in large enterprises. Kaazing unfortunately doesn't currently market this solution at all. Using Kaazing to deploy Node.JS just makes Node.JS so much more attractive to enterprise shops because it overcomes any and all objections anyone would have against using Node.JS in an enterprise.
+Asbestos: Pound doesn't work. +Nginx should have websocket compatibility by Jan 2012 - http://trac.nginx.org/nginx/roadmap
+suff: HAProxy from version 1.5dev12 (currently 1.5dev16) supports SSL.
+]]># list branches first
+git branch -a
+# * master
+# remotes/origin/branch_name
+git checkout -b local_name remotes/origin/branch_name# switch to master
+git checkout master
+# merge with experimental branch
+git merge experimental# list tags
+git tag
+# add a tag
+git tag tagname
+# push to remote
+git push origin master --tags+
+]]>
So I decided to move to an alternative window manager. DWM (dynamic window manager, http://dwm.suckless.org/) is an extremely lightweight tiling window manager written in C which saves screen space and works pretty well as long as you don't need to connect to wireless networks.
+I've been pretty happy with it. The main drawback is that connecting to wireless networks is a pain in the ass as there are no proper GUI tools to do this. Check out these tips to get started with dwm
+bash
+sudo yum install dwm-user
+
+
+bash
+mkdir ~/.dwm
+
+
+bash
+cp /usr/src/dwm-user-5.8.2-6.fc14/config.def.h ~/.dwm/config.h
+
+E.g. install via yum, then make a ~/.dwm folder, then copy the config.h file and edit it. When you restart, you can choose dwm-user as your window manager which uses you custom version of dwm. For example, I remapped Meta (Cmd/Windows key) + h and meta + l to meta + pg up / pg down and meta + shift + q to meta + shift + end since I'm currently running Fedora on an OSX host.
+
+You will probably make changes to the keyboard shortcuts. To find the keymap:
+
+bash
+sudo updatedb
+
+
+bash
+locate keysymdef.h
+
+Keysymdef.h lists the names of the keys in X11.
+bash
+sudo yum install xfce4-notifyd
+
+Basically you need a notify daemon to allow Guake to print that pretty message "Guake is running", and xfce4-notifyd provides an alternative notifications daemon.
+nautilus --no-desktopbash
+xrandr --output VBOX1 --auto --right-of VBOX0
+
+dwm will now let you have your own workspaces for each screen.
+bash
+feh --bg-tile /path/to/background/image
+
+bash
+<code>xrdb -merge .Xresources</code>
+
+
+bash
+xterm*faceName: monospace:pixelsize=14
+xterm*saveLines: 9999
+xterm*scrollBar: false
+xterm*background: #000000
+xterm*foreground: #dfdfdf
+xterm*color0: #000000
+xterm*color1: #9e1828
+xterm*color2: #aece92
+xterm*color3: #968a38
+xterm*color4: #414171
+xterm*color5: #963c59
+xterm*color6: #418179
+xterm*color7: #bebebe
+xterm*color8: #666666
+xterm*color9: #cf6171
+xterm*color10: #c5f779
+xterm*color11: #fff796
+xterm*color12: #4186be
+xterm*color13: #cf9ebe
+xterm*color14: #71bebe
+xterm*color15: #ffffff
+
+bash
+
+<pre>while true; do
+ xsetroot -name "$( date +"%F %R" )"
+ sleep 1m # Update time every minute
+done
+
+bash
+iwlist scan
+
+> > #wep connect to a wep wifi
+> > #! /bin/sh
+> >
+> > key="grep <span class="hljs-variable">$1</span> /home/pmarin/wep | cut -d' ' -f2"
+> > sudo ifconfig wlan0 up
+> > sudo iwconfig wlan0 essid $1
+> > sudo iwconfig wlan0 key s:$key
+> > sudo dhclient wlan0
+> > #end> > The wep is a plain file with to columms
+> >
+> > essid key> >
+> > #wpa connect to a wpa wifi
+> > #! /bin/sh
+> >
+> > sudo ifconfig wlan0 up
+> > sudo iwconfig wlan0 essid $1
+> > sudo wpa_supplicant -iwlan0 -c/home/pmarin/wpa -B
+> > sudo dhclient wlan0
+> > #end
+> >
+> > the wpa file is similar than /etc/wpa_supplicant.confTo create the wpa file:
+wpa_passphrase your_ssid_of_network your_network_password
Create the file:
+ctrl_interface=/var/run/wpa_supplicant
+#ap_scan=2
+
+network={
+ ssid="your_ssid"
+ scan_ssid=1
+ proto=WPA RSN
+ key_mgmt=WPA-PSK
+ pairwise=CCMP TKIP
+ group=CCMP TKIP
+ psk=your_psk_from_wpa_passphrase
+}
+
+sudo wpa_supplicant -Bw -Dwext -i eth0 -c/etc/wpa_supplicant.confYou can run wpa_supplicant with -dd flag for a detailed debug output.1) If you don't manage to connect to the AccessPoint, try to uncomment line 2 in /etc/wpa_supplicant.conf.
+2) If that doesn't help, try change its value to 0 or 1.
+3) If you get troubles while authenticating, try removing "RSN" and/or"CCMP" strings from /etc/wpa_supplicant.conf.
+Sources for Wifi stuff:
+http://ubuntuforums.org/showthread.php?t=263136
+http://www.mail-archive.com/dwm@suckless.org/msg06800.html
+vimarsh: One tip for the wifi set-up: i found it easier to set up the initial config using nm-connection-editor and then start nm-applet in the dwm launcher script. It will autoconnect to your preferred wifi configuration. (Of course you need NetworkManager daemon running)
+Sample launcher:
+""" +#
+#
+nm-applet --sm-disable& +exec /usr/local/bin/dwm +"""
+Mikito Takada: Thanks for the tip!
+Matt Freeman: In my .xsession I have 'nm-applet &' (or perhaps you can spawn it from the dwm config), if this is setup correctly then it will auto connect to wifi network previous configured (i.e. the one you setup whilst in gnome). Alternatively if you have a tray program such as trayer or tint2 etc.. you can work with the network manager just as you would in Gnome.
+Hardcore Arch users tell me that wicd is better alternative without zero gnome attachments though. - not verified
+Mikito Takada: Thank you, I gave wicd a try and it seems like a really nice solution for going Gnome-free...
+sudo yum install wicd wicd-gtk wicd-curses +sudo service NetworkManager stop # Bad password errors if both are running... +sudo service wicd start +wicd-client -n
+Anton: Hi! Big thanks for tips! +Always wanted to try tiling managers and with releases of unity and gnome 3, the time to do it have come. now i am messing around lxde based fedora + dwm, and your article is really good point to start.
+]]>My new years resolution was to ship more, but I never expected to ship my own ass over to San Francisco! It'll be awesome.
+I flew in on June 3rd, and have been here for two days. So far, everything has been pretty awesome, though I still need to find an apartment rental and get the final paperwork done on this side!
+Since I'll be able to concentrate more on code instead of living the triple life of a doctoral student, individual entrepreneur and open source programmer, I hope to start building a solid streak of open source/fun coding while I'm here. I read something on HN recently which I think will be good to keep in mind:
+"I have a rule: I refuse to go to sleep if I haven’t read and written some code on a given day (this doesn’t include the code I write for work, of course). So far, this rule has had a positive impact on my ability to code."
+I'll try to apply that rule, perhaps using 42goals.com or the Calendar About Nothing...
++]]>
Check out Ahmed Abdo's post on Flash audio stutter for the details. Works perfectly for me!
+Details: https://bugzilla.redhat.com/show_bug.cgi?id=638477
+The bug is triggered by a change in glibc. Who proposed the fix? Linus Torvalds. So I guess the following isn't quite true?
+
I love the pragmatism from his part:
++So in the kernel we have a pretty strict "no regressions" rule, and that if people depend on interfaces we exported having side effects that weren't intentional, we try to fix things so that they still work unless there is a major reason not to. + +So I'm disappointed glibc just closes this as NOTABUG. There's no real reason to do the copy backwards that I can see, so doing it that way is just stupid. + +But whatever. You can do a LD_PRELOAD trick to get a sane memcpy(), and it does indeed fix the sound for me. +[...] +The fact that the glibc people don't do that, and that this hasn't been elevated despite clearly being a big usability problem (normal users SHOULD NOT HAVE TO google bugzillas and play with LD_PRELOAD to have a working system), is just sad. ++ +
Although overall, as an end user it the conversation around this bug and its persistence makes me sad. I know it's selfish not to care about the technical superiority of a solution or about who is to blame here - but I'd just like to have my smooth Flash playback...
+]]>The following image from Kohana 3's docs shows an example:
+ +var Cfs = require('./cfs.js');
+
+// test class loading:
+// e.g. check ./application/classes/test.js
+// ./modules/modulename/classes/test.js
+// ./system/classes/test.js
+var t = Cfs.factory('test');
+t.run();
+
+// test view loading
+// e.g ./application/views/user/index.html
+// ./modules/modulename/views/user/index.html
+// ./system/views/user/index.html
+fs.readFile(Cfs.find_file('views', 'user/index', '.html'), function (err, data) {
+ if (err) throw err;
+ sys.puts(data);
+});To set modules:
+// set only once, before calling any other functions!
+Cfs.modules([
+ "./modules/testmodule/",
+ "./modules/testmodule2/",
+ ]);// test extending class (see code in /application/classes/controller/extend.js
+// to see how extension is achieved)
+// e.g. ./application/classes/controller/extend.js
+// ./modules/modulename/classes/controller/extend.js
+// ./system/classes/controller/extend.js
+var t3 = Cfs.factory('Controller_Extend');
+t3.run();
+t3.run_parent();Note that if you put cfs.js in ~/node_modules/cfs.js, you don't need to specify the path to it... see Modules in node.js docs.
+// in extend.js:
+var ControllerExtend = function () {
+}
+// extend the class
+var util = require('util'), Cfs = require('../../../../cfs.js');
+util.inherits(Controller_Extend, Cfs.load('Controller_Base'));
+
+Controller_Extend.prototype.run = function() {
+ console.log("Controller_Extend from testmodule2.");
+};
+Controller_Extend.prototype.run_parent = function() {
+ // run the parent function
+ Controller_Extend.super.prototype.run();
+};
+
+module.exports = Controller_Extend;shadowhand: Calling this HMVC is highly misleading. The cascading filesystem has absolutely nothing to do with hierarchical model-view-controller. I strongly recommend that you rename your "HMVC" class to something reasonable, such as "CFS".
+Mikito Takada: @shadowhand I agree and apologize if I have misled people. I had greater ambitions for the module at the time, hence the "HMVC style" reference, but I ended up doing other things. I've removed any references to HMVC here (well, except the diagram showing the cascading file system in Kohana but that's CFS rather than HMVC); I'll do github as well next time I actually work on that repo...
+Edit: for clarification if someone ends up here: the title of this post used to be "HMVC -style cascading..."
+]]>