Skip to content

Instantly share code, notes, and snippets.

View newtonapple's full-sized avatar

David Dai newtonapple

  • Tobiko Data
  • San Francisco
View GitHub Profile
module M
module ClassMethods
def foo
self.bar
end
private
def bar
'bar'
end
end
@newtonapple
newtonapple / gist:15168
Created October 6, 2008 22:55
Flip Mode
module Flip; $KCODE = "u"
FLIP_MAP = Hash.new{|h,k| k}
{ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz' =>
'∀ᗺↃᗡƎℲ⅁HIᒋʞ⅂ƜNOdԾᖈS⊥ႶΛMX⅄Zɐqɔpǝɟɓɥᴉʞ│ɯuodbɹsʇnʌʍxʎz',
'123456890~!@$%^&*()_+{}:|<>?"#`[],./-=\\' =>
'|ᘔᗴhᔕ9860~¡Ꭷ$%⋁⅋*)(‾+}{:|><¿„#ˎ][‘˙/-=\\'
}.each {|from,to| from.split(//).zip(to.split(//)).each {|f,t| FLIP_MAP[f]=t }}
FLIP_MAP.merge!("'"=>',', '7'=>'/̲', 'j'=>'⌠̣', ';'=>':́')
#
# .autotest
# Autotest Growl Notifications for Rspec and Test::Unit
#
# Created by Rein Henrichs on 2007-09-12.
# Copyright 2007 Rein Henrichs.
# http://pastie.caboo.se/96573/download
#
require "autotest/redgreen"
@newtonapple
newtonapple / newtonapple.github.com
Created December 17, 2008 08:52
Instruction for setting a github page
Instructions for setting up username.github.com *
Create a repo named username.github.com
Push a `master` branch to GitHub and enjoy!
Instructions for setting up username.github.com/repo-name *
Caution: make your working directory clean before you do this (either stash or commit), otherwise this will lose any changes you've made to your project since the last commit.
cd /path/to/repo-name
@newtonapple
newtonapple / Cookie.js
Created January 21, 2009 01:29
JS Cookie Library
@newtonapple
newtonapple / Cookie.js
Created January 21, 2009 02:18
JS Cookie Library V2
@newtonapple
newtonapple / .bash_profile
Created February 6, 2009 10:55 — forked from bcardarella/.bash_profile
Git Autocompletion
source ~/.git-completion.sh
alias gco='git co'
alias gci='git ci'
@newtonapple
newtonapple / Bash Command Shortcuts
Created April 7, 2009 17:57
Bash key binding and shortcuts
# CURSOR MOVEMENT
ctrl-a # go to beginning of the line
ctrl-e # go to end of the line
ctrl-x # (2 times) to remember current cursor location and move to the previous cursor location
# cycle this command to move between current and previous cursor location
ctrl-c # leave current line intact, and move cursor to a new line (return but don't execute command)
ctrl-j/ctrl-m # (less useful) return and execute command
esc-b # move cursor one WORD to the left
@newtonapple
newtonapple / chromium_updater.rb
Created August 14, 2009 05:51
An automated Ruby script for grabbing the latest Mac Chromium build
#!/usr/bin/env ruby
# A simple Ruby script to update Chromium from dev build.
# Currently only works on Mac. You should be able extend it to Linux and Windows without much fuzz.
# If you want progress bar, sudo gem install ruby-progressbar
# Usage:
# ruby chromium_updater.rb
require 'fileutils'
require 'open-uri'
@newtonapple
newtonapple / rails_template.rb
Created August 27, 2009 22:50
A Rails Template: JQuery, Rspec, WillPaginate, BoilerPlate CSS, SQL Schema, NO Time Stamped Migration
## ENV
environment do
<<-ENV_CODE
config.active_record.timestamped_migrations = false
config.active_record.schema_format = :sql
# ENV['RAILS_ASSET_ID'] = '' # turn off assets timestamp
ENV_CODE
end