This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lines = `git log --oneline`.split("\n") | |
| lines.map! do |line| | |
| sha, *msg = line.split | |
| msg = msg.join(' ') # unused | |
| color = '#' + sha[0..-2] | |
| %{<div class="box" style="background:#{color}"></div>} | |
| end | |
| File.open('colors.html', 'w') do |f| | |
| f.puts <<-HTML |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| USER = 'github' | |
| require 'open-uri' | |
| user_id = open("http://twitter.com/followers/ids/#{USER}.xml").read.scan(/\d+/).sort_by { rand }.first | |
| user_name = open("http://twitter.com/users/show.xml?user_id=#{user_id}").read[/screen_name>(\w+)/, 1] | |
| puts user_name | |
| `open http://twitter.com/#{user_name}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias gb='for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cblue%cr%Creset" $k|head -n 1`\\t$k;done' | |
| # Output | |
| # ------ | |
| # ~/Development/github(master)$ gb | |
| # 4 weeks ago config-gem | |
| # 9 days ago dropdown | |
| # 5 weeks ago faucet | |
| # 3 weeks ago health |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://www.jamesbritt.com/2007/12/18/sending-mail-through-gmail-with-ruby-s-net-smtp | |
| # http://d.hatena.ne.jp/zorio/20060416 | |
| require "openssl" | |
| require "net/smtp" | |
| Net::SMTP.class_eval do | |
| private | |
| def do_start(helodomain, user, secret, authtype) | |
| raise IOError, 'SMTP session already started' if @started |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ~$ gem list -r -s http://gems.rubyforge.org | wc -l | |
| 4760 | |
| ~$ gem list -r -s http://gems.github.com | wc -l | |
| 4766 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'sinatra' | |
| require 'open-uri' | |
| def strip_header(text) | |
| prefix = %{ | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| <base href="http://github.com/"<div style="width"<!DOCTYPE | |
| } | |
| text.sub(/.+<!DOCTYPE/m, prefix) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Numeric | |
| def commify | |
| to_s.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, '\1,') | |
| end | |
| end | |
| Numeric.new.commify(500000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Fixnum | |
| {"years" => 31536000,"weeks" => 604800,"days" => 86400,"hours" => 3600,"minutes" => 60, "seconds" => 1}.each do |key,val| | |
| define_method key do | |
| self * val | |
| end | |
| end | |
| %w(year week day hour minute second).each do |method| | |
| define_method method do | |
| 1.send("#{method}s".to_sym) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # simple memory profiler | |
| # can't remember where I found it (thanks whomever wrote it) | |
| class MemoryProfiler | |
| DEFAULTS = {:delay => 10, :string_debug => false} | |
| def self.start(opt={}) | |
| opt = DEFAULTS.dup.merge(opt) | |
| Thread.new do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript==// | |
| // @name Hacker News Top Bar Colorer | |
| // @description Change the top bar color to whatever you want | |
| // @include http://news.ycombinator.com/* | |
| // ==/UserScript== | |
| document.getElementsByTagName('td')[0]["bgColor"] = '#f6f6ef' |
NewerOlder