This file contains 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 'maruku' # or use config.gem "maruku" in environment.rb | |
module ApplicationHelper | |
# Replacement for Rails' default Markdown helper which uses Maruku instead | |
# of BlueCloth. | |
def markdown(text) | |
text.blank? ? "" : Maruku.new(text).to_html | |
end | |
end |
This file contains 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 | |
mkdir -p /usr/local/src && cd /usr/local/src | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.bz2 | |
tar -xjvf ruby-1.9.1-p0.tar.bz2 | |
cd ruby-1.9.1-p0 | |
./configure --prefix=/usr --program-suffix=19 --enable-shared | |
make && make install |
This file contains 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
# For the queasy, this is MIT licensed. See comment at the end. | |
module MySQLEncryption | |
# Mimics MySQL's AES_ENCRYPT() and AES_DECRYPT() encryption functions | |
def mysql_encrypt(s, key) | |
encrypt(s, mysql_key(key)) | |
end | |
def mysql_decrypt(s, key) |
This file contains 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' | |
get '/' do | |
"Hello from Sinatra running on Java!" | |
end |
This file contains 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 'ostruct' | |
def objectify(val) | |
if val.is_a?(Hash) | |
result = {} | |
val.each_pair { |k,v| result[k] = objectify(v) } | |
result = OpenStruct.new(result) | |
elsif val.is_a?(Array) | |
result = [] | |
val.each { |v| result << objectify(v) } |
This file contains 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
config = {} | |
group = nil | |
File.foreach("#{ENV['HOME']}/.gitconfig") do |line| | |
line.strip! | |
if line[0] != ?# and line =~ /\S/ | |
if line =~ /^\[(.*)\]$/ | |
group = $1 | |
else | |
key, value = line.split("=") |
This file contains 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 'rubygems' | |
require 'octopi' | |
require 'choice' | |
include Octopi | |
Choice.options do | |
header '' |
This file contains 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
# NAME: recaptcha | |
# VERSION: 1.0 | |
# AUTHOR: Peter Cooper [ http://www.rubyinside.com/ github:peterc twitter:peterc ] | |
# DESCRIPTION: Sinatra plugin to provide CAPTCHA support through recaptcha.net | |
# COMPATIBILITY: 0.3.2 /and/ latest rtomayko Hoboken builds! | |
# LICENSE: Use for what you want, just don't claim full credit unless you make significant changes | |
# | |
# INSTRUCTIONS: | |
# 0. Check out an extended client code example at the footer of this file | |
# 1. Ensure _this_ file is lib/recaptcha.rb within your app's directory structure |
This file contains 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 'time' | |
class PeriodicExecutor | |
attr_reader :next_time_to_run | |
def initialize(secs, &block) | |
@secs = secs | |
@block = block | |
@next_time_to_run = Time.now.to_f |
This file contains 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
module Awesome | |
def baz | |
puts "baz" | |
end | |
end | |
class Foo | |
end |
OlderNewer