Skip to content

Instantly share code, notes, and snippets.

View wongyouth's full-sized avatar

Ryan Wang wongyouth

View GitHub Profile
[1b48e12162c413113097936bc1ea80c4 ed260550-1bfe-0130-71d7-282066022989] SQL (1.5ms) INSERT INTO "error_reports" ("comments", "updated_at", "http_env", "user_id", "subject", "account_id", "backtrace", "email", "data", "created_at", "during_tests", "category", "url", "user_agent", "zendesk_ticket_id", "request_method", "request_context_id", "message") VALUES(NULL, '2012-11-29 03:00:59.936051', NULL, NULL, NULL, NULL, '/Users/ryan/.rbenv/versions/1.8.7-p370/lib/ruby/gems/1.8/gems/redis-3.0.1/lib/redis/client.rb:262:in `establish_connection''
/Users/ryan/.rbenv/versions/1.8.7-p370/lib/ruby/gems/1.8/gems/redis-3.0.1/lib/redis/client.rb:63:in `connect''
/Users/ryan/.rbenv/versions/1.8.7-p370/lib/ruby/gems/1.8/gems/redis-3.0.1/lib/redis/client.rb:276:in `ensure_connected''
/Users/ryan/.rbenv/versions/1.8.7-p370/lib/ruby/gems/1.8/gems/redis-3.0.1/lib/redis/client.rb:167:in `process_without_conn_error''
/Users/ryan/.rbenv/versions/1.8.7-p370/lib/ruby/gems/1.8/gems/redis-3.0.1/lib/redis/client.rb:242:in `logging''
@wongyouth
wongyouth / mongoid3_id_monkey_patch.rb
Created February 3, 2013 08:03
This is a workaround for Mongoid3 and Emberjs or Backbonejs. Make `to_json` return id key the same value as _id which will be used as a primary key for ember-data.
module Mongoid
module Serialization
def serializable_hash_with_id(options = nil)
json = serializable_hash_without_id options
json['id'] = json['_id'] if json.has_key? '_id'
json
end
alias_method_chain :serializable_hash, :id
end
end
@wongyouth
wongyouth / .irbrc
Created June 7, 2013 14:36
rails2 show sql log in console
def change_log(stream)
ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(stream)
#ActiveRecord::Base.logger = Logger.new(stream)
#ActiveRecord::Base.clear_active_connections!
end
def show_log
change_log(STDOUT)
end
@wongyouth
wongyouth / .zshrc
Created August 29, 2013 06:09
.zshrc file for rails development
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="robbyrussell"
#ZSH_THEME="random"
ZSH_THEME="jonathan"

Install ImageMagick for image conversion:

brew install imagemagick

Install tesseract for OCR:

brew install tesseract --all-languages

Or install without --all-languages and install them manually as needed.

@wongyouth
wongyouth / deploy.rb
Created March 28, 2014 09:45
A deploy.rb works with Capistrano v3. By default only scm can be used, deployment by uploading is not supported. Here is a script hacked to deploy a yeoman project by Capistrano 3, with no scm needed.
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'frontend'
#set :repo_url, ''
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# Default deploy_to directory is /var/www/my_app
description "Mailcatcher"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
pre-start script
bash << "EOF"
mkdir -p /var/log/mailcatcher
@wongyouth
wongyouth / gist:177881131706db679a63
Last active August 29, 2015 14:10
1.9.3-p484-railsexpress.patch
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index f5e4e92..77ab4e4 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -2206,7 +2206,7 @@ def init_mkmf(config = CONFIG, rbconfig = RbConfig::CONFIG)
$LOCAL_LIBS = ""
$cleanfiles = config_string('CLEANFILES') {|s| Shellwords.shellwords(s)} || []
- $cleanfiles << "mkmf.log"
+ $cleanfiles << "mkmf.log .*.time"
@wongyouth
wongyouth / dabblet.css
Created October 23, 2015 06:58
Untitled
.something-meaningful {
margin: 2em;
overflow: hidden;
width: 15em;
padding: 1em;
background: tan;
border-radius: .7em;
box-shadow: 0 0 0 1em #655;
outline: 1em solid #655;
}

Geometry 释义

logo.png 640x480

convert logo: -resize '200%' bigWiz.png                     => 1280x960
convert logo: -resize '200x50%' longShortWiz.png            => 1280x240
convert logo: -resize '100x200' notThinWiz.png              => 100x72
convert logo: -resize '100x200^' biggerNotThinWiz.png       => 267x200
convert logo: -resize '100x200!' dochThinWiz.png            => 100x200