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
# Like OpenStruct but raises for anything not passed into the constructor. | |
# Unlike Struct in that it's built from a hash, and you don't need to define your own class. | |
# | |
# By Henrik Nyh <http://henrik.nyh.se> 2009-04-16. Public domain. | |
require 'ostruct' | |
class ClosedStruct < OpenStruct | |
def method_missing(symbol, *args) | |
raise(NoMethodError, "undefined method `#{symbol}' for #{self}") | |
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
# GitHub Flavored Markdown Layer | |
def fix_markdown_quirks(text) | |
# prevent foo_bar_baz from ending up with an italic word in the middle | |
text.gsub!(/(\w+_\w+_\w[\w_]*)/) do |x| | |
x.gsub('_', '\_') if x.split('').sort.to_s[0..1] == '__' | |
end | |
# in very clear cases, let newlines become <br /> tags | |
text.gsub!(/(\A|\n\n)(^\w[^\n]*\n)(^\w[^\n]*\n)+/m) do |x| | |
x.gsub(/^(.+)\n/, "\\1 \n") |
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
# Illustrates an RDiscount issue. | |
# | |
# Seen in the wild in Jekyll (http://github.com/mojombo/jekyll) blog posts | |
# where <div><pre> is used for syntax highlighting. | |
require 'rubygems' | |
require 'rdiscount' | |
require 'maruku' | |
md = DATA.read |
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
RewriteEngine On | |
# Map http://henrik.nyh.se to /jekyll. | |
RewriteRule ^$ /jekyll/ [L] | |
# Map http://henrik.nyh.se/x to /jekyll/x unless there is a x in the web root. | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_URI} !^/jekyll/ | |
RewriteRule ^(.*)$ /jekyll/$1 |
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 'sequel' | |
require 'fileutils' | |
require 'cgi' | |
# NOTE: This converter requires Sequel and the MySQL gems. | |
# The MySQL gem can be difficult to install on OS X. Once you have MySQL | |
# installed, running the following commands should work: | |
# $ sudo gem install sequel | |
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>beforeRunningCommand</key> | |
<string>nop</string> | |
<key>bundleUUID</key> | |
<string>5A9D4FC6-6CBE-11D9-A21B-000D93589AF6</string> | |
<key>command</key> | |
<string>#!/usr/bin/env ruby |
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/bash | |
ssh mini "osascript -e 'tell app \"Spotify\" to activate' -e 'tell app \"System Events\" to keystroke (ASCII character 29) using {command down}'" |
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
shared: &shared | |
# Use different adapters with JRuby vs. MRI | |
adapter: <%= defined?(JRuby) ? "jdbcmysql" : "mysql" %> | |
encoding: utf8 | |
username: root | |
password: | |
host: localhost | |
socket: /opt/local/var/run/mysql5/mysqld.sock | |
<% |
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
# Recursively diff two hashes, showing only the differing values. | |
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license. | |
# | |
# Example: | |
# | |
# a = { | |
# "same" => "same", | |
# "diff" => "a", | |
# "only a" => "a", | |
# "nest" => { |
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
You are here: | |
<%= trail.to_html(response) %> |