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 'activesupport' | |
| class String | |
| def emphasize substrings | |
| highlight self, substrings | |
| end | |
| end |
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
| # Detect rss feed, parse it, and report number of posts per date. | |
| require 'rubygems' | |
| require 'hpricot' | |
| require 'open-uri' | |
| # First find the rss | |
| url = ARGV[0] || "http://twitter.com/burnto" | |
| doc = Hpricot(open(url)) |
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
| #!/usr/bin/env ruby | |
| # calculate average uptime of my machine | |
| require 'rubygems' | |
| require 'activesupport' | |
| times = `last | grep ^shutdown` | |
| times = times.map { |l| Time.parse l[/shutdown\s+~\s+(.*)/, 1] } | |
| times = times.map { |t| t > Time.now ? t - 1.year : t } | |
| diffs = times.zip(times[1 .. -1]).map { |(a, b)| a - b if b }.compact |
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
| #!/bin/sh | |
| # Configure your desired options here | |
| DESIRED_HOSTNAME="lazeroids.com" | |
| # Ensure hostname is configured | |
| if [ -z "$DESIRED_HOSTNAME" ]; then | |
| echo DESIRED_HOSTNAME must be set. | |
| exit 1 | |
| fi |
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
| # in application.js | |
| document.cookie = '_swivel_time_zone=' + new Date().getTimezoneOffset()*-60; | |
| # in application_controller.rb: | |
| before_filter { |controller| Time.zone = ActiveSupport::TimeZone[controller.cookies[:_swivel_time_zone].to_i] if controller.cookies[:_swivel_time_zone] } |
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
| #!/usr/bin/env ruby | |
| require 'open-uri' | |
| require 'rubygems' | |
| require 'rack' | |
| out = nil | |
| query = ARGV.map do |o| | |
| k, v = o.split '=' | |
| out = v if k == '--out' | |
| "#{k.sub /^--/, ''}=#{Rack::Utils.escape v}" |
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 'sass' | |
| # | |
| # fix sass color math | |
| # | |
| class Sass::Script::Color | |
| def hsl | |
| rgb = @value.map { |c| c / 255.0 } | |
| min_rgb = rgb.min |
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
| $ dig @8.8.8.8 visnup.com | |
| ; <<>> DiG 9.6.0-APPLE-P2 <<>> @8.8.8.8 visnup.com | |
| ; (1 server found) | |
| ;; global options: +cmd | |
| ;; Got answer: | |
| ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23373 | |
| ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 | |
| ;; QUESTION SECTION: |
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
| (function your(node) { | |
| if (node.nodeType == 3) { // text-node | |
| node.nodeValue = node.nodeValue.replace(/\b(you)(r)\b/ig, "$1'$2e"); | |
| } else { | |
| var c = node.childNodes; | |
| for (var i = 0; i < c.length; i++) | |
| your(c[i]); | |
| } | |
| })(document.body); |