Skip to content

Instantly share code, notes, and snippets.

View tansengming's full-sized avatar
🏠
Working from home

SengMing Tan tansengming

🏠
Working from home
View GitHub Profile
@tansengming
tansengming / download.rake
Created August 13, 2012 09:28
download.rake
namespace :download do
DownloadPath = Pathname.new('Downloads')
ListFile = DownloadPath + 'list'
task :all do
ListFiles = Pathname.glob('Downloads/**/list')
next if ListFiles.empty?
ListFiles.each do |listfile|
list = listfile.read.split.compact.reject(&:empty?)
function mkdev; rm -f ~/dev; and ln -vs $PWD ~/dev; end
javascript:(function(){function%20hex_md5(p){return%20binl2hex(core_md5(str2binl(p),p.length*8));}function%20core_md5(x,len){x[len>>5]|=0x80<<((len)%2532);x[(((len+64)>>>9)<<4)+14]=len;var%20a=1732584193;var%20b=-271733879;var%20c=-1732584194;var%20d=271733878;for(var%20i=0;i<x.length;i+=16){var%20olda=a;var%20oldb=b;var%20oldc=c;var%20oldd=d;a=md5_ff(a,b,c,d,x[i+0],7,-680876936);d=md5_ff(d,a,b,c,x[i+1],12,-389564586);c=md5_ff(c,d,a,b,x[i+2],17,606105819);b=md5_ff(b,c,d,a,x[i+3],22,-1044525330);a=md5_ff(a,b,c,d,x[i+4],7,-176418897);d=md5_ff(d,a,b,c,x[i+5],12,1200080426);c=md5_ff(c,d,a,b,x[i+6],17,-1473231341);b=md5_ff(b,c,d,a,x[i+7],22,-45705983);a=md5_ff(a,b,c,d,x[i+8],7,1770035416);d=md5_ff(d,a,b,c,x[i+9],12,-1958414417);c=md5_ff(c,d,a,b,x[i+10],17,-42063);b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);a=md5_ff(a,b,c,d,x[i+12],7,1804603682);d=md5_ff(d,a,b,c,x[i+13],12,-40341101);c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);b=md5_ff(b,c,d,a,x[i+15],22,1236535329);a=md5_gg(a,b,c,d,x[i+1],5,-165796510);d=md5_gg(d,a,b,c,
@tansengming
tansengming / sublime.json
Last active October 7, 2015 12:07
Default Sublime
{
"auto_complete": true,
"color_scheme": "Packages/User/Monokai Soda.tmTheme",
"draw_white_space": "all",
"font_face": "Monaco",
"font_size": 13.0,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
@tansengming
tansengming / .gitconfig
Last active October 7, 2015 10:17
Default gitconfig
[user]
name = SengMing Tan
email = [email protected]
[alias]
b = branch
c = commit .
co = checkout
stat = status
s = status
h = log --pretty=format:'%Cblue%h %Cgreen %ar%Creset %s'
@tansengming
tansengming / configure.rb
Created July 9, 2012 07:37
Ruby configure blocks
# How Clearance / Hoptoad does it
module Clearance
class << self
attr_accessor :configuration
end
def self.configure
self.configuration ||= Configuration.new
yield(configuration)
end
@tansengming
tansengming / production.rb
Created June 18, 2012 01:20
Carrierwave S3 settings
CarrierWave.configure do |config|
config.storage = :s3
config.s3_access_key_id = "s3_access_key_id"
config.s3_secret_access_key = "s3_secret_access_key"
config.s3_bucket = "s3_bucket"
# config.s3_access_policy = :authenticated_read
config.s3_cnamed = true
end
@tansengming
tansengming / spec_helper.rb
Created May 3, 2012 06:31
Default spec helper with Factory girl
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
@tansengming
tansengming / pivotal.rake
Created February 20, 2012 05:59
rake task to deliver all finished using the pivotal API
PIVOTAL = {
:token => 'your_token',
:project_id => 'your_project_id'
}
namespace :pivotal do
task :deliver_all_finished => :environment do
line = Cocaine::CommandLine.new("curl", "-H 'X-TrackerToken: #{PIVOTAL[:token]}' -X PUT https://www.pivotaltracker.com/services/v3/projects/#{PIVOTAL[:project_id]}/stories/deliver_all_finished -d ''")
puts "Running #{line.command}"
line.run
@tansengming
tansengming / secure_endpoint_helper.rb
Created January 25, 2012 01:33
Put this file into the spec/support dir and then include it into any controller spec that requires support for Devise
module SecureEndpointHelper
extend ActiveSupport::Concern
included do
include Devise::TestHelpers
before do
request.env["devise.mapping"] = Devise.mappings[:user]
setup_controller_for_warden
end
end