Skip to content

Instantly share code, notes, and snippets.

View fcoury's full-sized avatar

Felipe Coury fcoury

View GitHub Profile
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
@fcoury
fcoury / build_ruby19.sh
Created February 18, 2009 20:59 — forked from postmodern/build_ruby19.sh
Shameless copy of the script to deploy ruby 1.9 alonside with 1.8
#!/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
# 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)
require 'rubygems'
require 'sinatra'
get '/' do
"Hello from Sinatra running on Java!"
end
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) }
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("=")
@fcoury
fcoury / ghkey.rb
Created April 27, 2009 01:47
Automates the generation and inclusing of a SSH Public Key to GitHub
#!/usr/bin/env ruby
require 'rubygems'
require 'octopi'
require 'choice'
include Octopi
Choice.options do
header ''
# 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
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
module Awesome
def baz
puts "baz"
end
end
class Foo
end