Skip to content

Instantly share code, notes, and snippets.

View geekontheway's full-sized avatar

geekontheway geekontheway

  • Shanghai,China
View GitHub Profile
@geekontheway
geekontheway / gfm.rb
Created November 27, 2011 15:22 — forked from mojombo/gfm.rb
highlighting
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
@geekontheway
geekontheway / gist_tag.rb
Created November 27, 2011 15:38 — forked from imathis/gist_tag.rb
A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers.
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
@geekontheway
geekontheway / newpost.rb
Created November 28, 2011 12:31
Nifty automagical post generation script for Jekyll
#!/usr/bin/env ruby
# *********************************************
# Jekyll Post Generator Awesomeness
# by Cody Krieger (http://codykrieger.com)
# edited by Tao Zhang (http://ztnote.com)
# *********************************************
# Usage:
# % ./newpost.rb POST NAME
@geekontheway
geekontheway / newpost.rb
Created November 28, 2011 12:31
Nifty automagical post generation script for Jekyll
#!/usr/bin/env ruby
# *********************************************
# Jekyll Post Generator Awesomeness
# by Cody Krieger (http://codykrieger.com)
# edited by Tao Zhang (http://ztnote.com)
# *********************************************
# Usage:
# % ./newpost.rb POST NAME
@geekontheway
geekontheway / README.md
Created December 7, 2011 05:29 — forked from napcs/README.md
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

@geekontheway
geekontheway / devise.rb
Created February 8, 2012 11:05 — forked from kulbirsaini/devise.rb
Devise configuration to allow username or email address for sign_in, confirmation, unlock, forgot password instructions.
################################################################
# For views/migrations etc. check http://tinyurl.com/3xfx3zm #
################################################################
# File : RAILS_APP/config/initializers/devise.rb
# Change the following only. Rest can stay same
# NOTE : You must use devise master or any version released after Mar 13, 2011 to get everything mentioned here working.
config.authentication_keys = [ :login ]
config.confirmation_keys = [ :login ]
config.unlock_keys = [ :login ]
@geekontheway
geekontheway / devise_migration.rb
Created April 14, 2012 07:12 — forked from iwarshak/devise_migration.rb
Migrating to a new password encryption in devise, coming from authlogic
class MigrateUserToDevise < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.string :encrypted_password, :null => false, :limit => 128
# ...
end
end
def self.down
end
@geekontheway
geekontheway / devise_migration.rb
Created April 14, 2012 07:12 — forked from iwarshak/devise_migration.rb
Migrating to a new password encryption in devise, coming from authlogic
class MigrateUserToDevise < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.string :encrypted_password, :null => false, :limit => 128
# ...
end
end
def self.down
end
gemcutter => redis downloads spec
=================================
keys
----
downloads => global counter for all gem downloads
downloads:today => sorted set for downloads from today
downloads:rubygem:rails => counter for all rails downloads
downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads
@geekontheway
geekontheway / deploy.rb
Created May 30, 2012 05:53 — forked from markoa/deploy.rb
Ingredients to monitor Resque with God automatically via Capistrano (on Ubuntu)
namespace :deploy do
desc "Hot-reload God configuration for the Resque worker"
task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}"
sudo "god start resque"
end
end
# append to the bottom: