Skip to content

Instantly share code, notes, and snippets.

View drnic's full-sized avatar
🏆
Platinum Status Level

Dr Nic Williams drnic

🏆
Platinum Status Level
View GitHub Profile
export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_RED='\e[0;31m'
@drnic
drnic / filename.rb
Created July 25, 2008 01:27
Filename class for Ruby
##
# Simple class that makes File.* class methods available on a
# Filename object
#
# doctest: Can call File’s class methods on a Filename object
# >> Filename.new ("/tmp/myfile.png").dirname
# => "/tmp"
#
# doctest: Can create a Filename from another Filename object
# >> path = "/tmp/myfile.png"

Hello World example for V8

It includes generic Rakefile for other projects

Usage

class PonyList
def initialize(ponies = [])
@ponies = ponies
end
def empty?
@ponies.empty?
end
def add(pony)
@drnic
drnic / .inputrc
Created October 9, 2008 01:48
Put this file in your home folder to get history search via up/down keys
# from http://www.pixelbeat.org/settings/.inputrc
# By default up/down are bound to previous-history
# and next-history respectively. The following does the
# same but gives the extra functionality where if you
# type any text (or more accurately, if there is any text
# between the start of the line and the cursor),
# the subset of the history starting with that text
# is searched (like 4dos for e.g.).
#!/usr/bin/env ruby
$:.unshift(File.dirname(__FILE__) + "/../lib")
require "rubygems"
begin
require "gist"
rescue LoadError
puts "Please install rubygem 'gist' to use this command"
exit
end
require "hpricot"
Shoes.app do
# Just a simple app, yes?
@title = title "..."
download "https://github.com/?login=drnic&token=mytoken",
# download "https://github.com", :body => { "login" => 'drnic', "token" => '6c131adb79448cb80d166b448c446fb2' }, :method => "GET",
:start => proc { |dl| para "starting..." },
:finish => proc { |dl|
doc = Hpricot(dl.response.body)
@drnic
drnic / gist:38843
Created December 22, 2008 02:50 — forked from peterc/gist:33337
template for rails
# SUPER DARING APP TEMPLATE 1.0
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
require 'hotcocoa'
include HotCocoa
class Application
def start
application :name => "Download And Scrape Html" do |app|
app.delegate = self
window :frame => [100, 100, 500, 500], :title => "Download And Scrape Html" do |win|
win << label(:text => "Hello from HotCocoa", :layout => {:start => false})
class SpeechController
# from - (void)speechSynthesizer:(NSSpeechSynthesizer *)sender willSpeakWord:(NSRange)wordToSpeak ofString:(NSString *)text
def speechSynthesizer(sender, willSpeakWord: wordToSpeak, ofString: text)
end
# from speechSynthesizer:willSpeakWord:ofString:
def speechSynthesizer(speechSynthesizer, willSpeakWord: speakWord, ofString: string)
end