Skip to content

Instantly share code, notes, and snippets.

@benolee
benolee / command.rb
Created April 22, 2013 23:46
simple example of using pipe, fork, and exec
class Command
attr_accessor :pull, :push
def initialize(name, *args)
@name, @args, @pull, @push = name, args, *IO.pipe
end
def exec
fork do
pull.close

N.B. to run his examples in emacs, you'll want these aliases:

(defalias 'plus #'+)
(defalias 'quotient #'/)
(defalias 'times #'*)
(defalias 'difference #'-)

Lisp: Atoms and Lists

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

Ruby 2.0.0 in detail

Keyword arguments

def wrap(string, before: "<", after: ">")
  "#{before}#{string}#{after}" # no need to retrieve options from a hash
end

# optional
.DS_Store
tmp/
#!/usr/bin/env PeanutButterJellyTime
# -----------------------------------------------------------------------------
# keyword => C equiv (description)
# -----------------------------------------------------------------------------
# peanut => ++*ptr (increase value of cell)
# PEANUT => ++ptr (move to next cell)
# butter => --*ptr (decrease value of cell)
# BUTTER => --ptr (move to previous cell)
# jelly => putchar(*ptr) (print character value of cell)
# JELLY => *ptr=getchar() (store numeric value of char input in cell)
@benolee
benolee / readme.md
Created April 14, 2013 02:01 — forked from liluo/readme.md

init

mkdir proj
cd proj
git init

config

git config user.name 'username'
# slide 77 from waza talk
# method definition with static scope, class eval'd in a string
# Environment
class Foo
hello = "world!"
define_method("foo") { hello }
class_eval "def bar; hello; end"
@benolee
benolee / _.md
Created February 25, 2013 20:56
General Update Pattern, III
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')