View heartbeat.rb
# we're using the TmpIO class
# -*- encoding: binary -*-
# :stopdoc:
require 'tmpdir'
# some versions of Ruby had a broken Tempfile which didn't work
# well with unlinked files. This one is much shorter, easier
# to understand, and slightly faster.
class TmpIO < File
# creates and returns a new File object. The File is unlinked
View io_pipe.rb
require 'json'
# r, w = IO.pipe
# w << 'secret'
# w << ' message'
# w.close_write
# r.read #=> "secret message"
# if fork
# wr.close
View ebooks.md
View visualization_in_js.md

Data visualization in one of three most important steps in data mining (https://github.com/entaroadun/hnpickup). Often times, it's impossible to understand data without proper visualization. I went looking for great tools to do that.

Two website list recent JS visualization frameworks:

Most of them are available on Github. My three favorite:

View useful_windows_7_tweaks.md

Windows 7 Tweaks

The analysis will take 60 seconds (which you can change with the optional - duration switch), after which powercfg will save its report as an HTML file on your desktop. Just double-click output.html to view the report.

powercfg -energy -output %userprofile%\desktop\output.html

Enabling this setting will prevent Windows from paging certain system processes to disk

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
DisablePagingExecutive // Values: 0 = disabled (default), 1 = enabled.
View lithp.rb
class Lisp
def initialize
@env = {
:label => lambda { |(name,val), _| @env[name] = val },
:quote => lambda { |sexpr, _| sexpr[0] },
:car => lambda { |(list), _| list[0] },
:cdr => lambda { |(list), _| list.drop 1 },
:cons => lambda { |(e,cell), _| [e] + cell },
:eq => lambda { |(l,r), _| l == r },
:if => lambda { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) },
View for_vs_each.rb
# For vs. each
# Results:
#
# user system total real
# 0.340000 0.000000 0.340000 ( 0.341422)
# 0.310000 0.000000 0.310000 ( 0.326168)
require 'benchmark'
n = 500000
View rvm_lion_x_code_4_2_1.md

Install RVM

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 
function' >> ~/.bash_profile

Install GCC 4.2

Grab and unpack the tarball
$ mkdir ~/tmp && cd ~/tmp
View mac_tips.md

Disable dashboard (free ram and stuff)

defaults write com.apple.dashboard mcx-disabled -boolean YES
killall Dock

Purge RAM (tip: install xcode 1st)

In terminal > purge # then wait
View eventmachine.rb
require 'amqp'
module HiringThingEM
def self.start
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
# for passenger, we need to avoid orphaned threads
if forked && EM.reactor_running?
EM.stop
end
Thread.new {