Skip to content

Instantly share code, notes, and snippets.

require 'ap'
require 'tsort'
$test_data = {
:b => :a,
:c => :a,
:d => :b,
:e => :b,
:f => :b,
:g => :c,
# Process a color type, returns a function symbol.
#------------------------------------------------------------------------------
def color_func(c)
temp = "fg"
if c.is_a? Array
temp += AwesomePrint::Helpers::rgb(*c)
elsif c.is_a? Fixnum
temp += c >= 0 and c <= 255 ? c.to_s : "255"
elsif c.is_a? String
if (c.length == 7 or c.length == 6) and not (c =~ /#?[0-9A-Fa-f]{6}/).nil?
#!/usr/bin/env ruby
# Processes vim's rgb.txt for colour names!
require 'awesome_print'
def process(s)
s.split(/[A-Z]{1}[a-z]+/).map { |x| x.downcase }.join("_").to_sym
end
SQLite3::SQLException: no such column: tags.article_id: SELECT "tags".* FROM "tags" WHERE "tags"."article_id" = 1
source "git://github.com/loopj/jquery-tokeninput.git" do
asset "styles/token-input-facebook.css", :stylesheet
asset "src/jquery.tokeninput.js", :javascript
end
group :development do
source "git://github.com/loopj/jquery-tokeninput.git" do
asset "holmes.css", :stylesheet
end
end

Long form article

Author

John Smith

Publication Date

2011-06-15 14:28:16 -0400

@basicxman
basicxman / so.rb
Created June 16, 2011 23:45
A horrible script for Stack Overflow Growl notifications
require 'nokogiri'
require 'open-uri'
require 'json/pure'
require 'ruby-growl'
class StackOverflowNotifier
def initialize(*args)
@data = if File.exists? "data.json"
JSON.parse(File.read("data.json"))
# ApplicationController
def render_sidebar_widget(path, item = nil)
locals = {}
locals = self.send(item) unless item.nil?
render_to_string(:partial => path, :locals => locals).html_safe
end
helper_method :render_sidebar_widget
def reading_list
set(:reading_items, ReadingItem.updated_desc.all)
1 ~$ irb
ruby-1.9.2-p136 :001 > require 'net/http'
=> true
ruby-1.9.2-p136 :002 > require 'uri'
=> false
ruby-1.9.2-p136 :003 > res = Net::HTTP.get_print URI.parse('http://www.wordreference.com/enfr/test')
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html >
<head>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Test</title>