Skip to content

Instantly share code, notes, and snippets.

View tonytonyjan's full-sized avatar
🪲
Making bugs

簡煒航 (Weihang Jian) tonytonyjan

🪲
Making bugs
View GitHub Profile
@tonytonyjan
tonytonyjan / hooks.md
Created September 5, 2014 08:04
All hook in Rails 4.2.0
run_load_hooks(:action_mailer, self)
run_load_hooks(:action_controller, self)
run_load_hooks(:action_view, self)
run_load_hooks(:active_record, Base)
run_load_hooks(:i18n)
run_load_hooks(:active_record, ActiveRecord::Base)
run_load_hooks(:basic_hook)
run_load_hooks(:basic_hook_with_two, FakeContext.new(2))
run_load_hooks(:basic_hook_with_two, FakeContext.new(5))
@tonytonyjan
tonytonyjan / rails_env.sh
Last active August 29, 2015 14:07
OSX Rails 環境配置懶人包
#!/usr/bin/env bash
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install caskroom/cask/brew-cask rbenv ruby-build
brew tap caskroom/versions
brew cask instal iterm2 sublime-text3
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
rbenv install 2.1.3
rbenv global 2.1.3
gem update --system
@tonytonyjan
tonytonyjan / Vagrantfile
Last active August 29, 2015 14:10
Vagrantfile Rails development.
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision :shell, path: "bootstrap.sh"
config.vm.network :forwarded_port, guest: 3000, host: 3000
end
@tonytonyjan
tonytonyjan / keybase.md
Created January 18, 2015 20:15
keybase.md

Keybase proof

I hereby claim:

  • I am tonytonyjan on github.
  • I am tonytonyjan (https://keybase.io/tonytonyjan) on keybase.
  • I have a public key whose fingerprint is F30B 53C9 A9CC B71C A034 4E2A 055A F90B C74E 4F4C

To claim this, I am signing this object:

# ~/.config/fish/functions/fish_prompt.fish
set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_hide_untrackedfiles 1
set -g __fish_git_prompt_color_branch magenta bold
set -g __fish_git_prompt_showupstream "informative"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_prefix ""
@tonytonyjan
tonytonyjan / indexer.rb
Created May 1, 2012 05:07
A plugin for Octopress to generate IDs in header tags and index list aside. It helps you easily build a tutorial page with many chapters.
=begin
## Description
A tool for Octopress to generate IDs in header tags and index list aside. It helps you easily build a tutorial page with many chapters.
## Features
* Support all languages.
## Syntax
@tonytonyjan
tonytonyjan / Rakefile
Created May 2, 2012 07:25
A useful rake task of Octopress for listing published or unpublished posts.
# usage rake new_page[my-new-page] or rake new_page[my-new-page.html] or rake new_page (defaults to "new-page.markdown")
desc "List all posts with an asterisk if it's published. Advanced usage: 'rake list_posts[pub|unpub]'"
task :list_posts, :type do |t, args|
type = args.type
result = ""
Dir.glob("#{source_dir}/#{posts_dir}/*.markdown").sort.each do |post|
file = File.read(post)
file =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
data = YAML.load($1)
@tonytonyjan
tonytonyjan / tj_rails_template.rb
Last active October 12, 2015 10:07
tonytonyjan's rails template
# Usage:
# > rails new myapp -m https://gist.github.com/raw/4010690/d9106a1c3af695d1ed4ef8d16e3c8a06b5e3c7f3/tj_rails_template.rb
config = {}
puts "Gems:"
config[:install_devise_cancan_rolify] = yes? "install devise, cancan, rolify?"
config[:install_form_helpers] = yes? "install simple_form, dynamic_form, nested_form?"
config[:install_bootstrap_tjstyle] = yes? "install bootstrap, tjstyle?"
config[:install_rspec_spork] = yes? "install rspec, spork?"
#include <stdio.h>
#define SWAP(a,b) do{ typeof(a) tmp = a; a = b; b = tmp; }while(0)
void permutate(int* v, int n, int i) {
int j;
if (i == n) {
for(j = 0; j < n; j++) printf("%d ", v[j]);
printf("\n");
}else
for(int j = i; j < n; j++) {
@tonytonyjan
tonytonyjan / README.md
Last active December 15, 2015 18:33
Taiwanese gem contributors 2015

方法

  1. https://github.com/orgs/rubytaiwan/teams/rubyists 取得 GitHub 帳號。
  2. 使用 GitHub API 取得個別帳號下的所有 public repo,尋找 *.gemspec,並取得 gem name。
  3. 透過 RubyGems API 用 gem name 尋找 gem owner。

聲明

  • 有些 gem 有複數個 owner,可能會有老外混進去。
  • 有的人會把知名專案用 fork 以外的方式 push 到自己的帳號,導致 repo 真正的作者與 repo 帳號擁有者不一致。