Skip to content

Instantly share code, notes, and snippets.

Chen Chia Yang Unayung

Block or report user

Report or block Unayung

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:6156570
[[ -s /Users/Unayung/.rvm/scripts/rvm ]] && source /Users/Unayung/.rvm/scripts/rvm
alias pro='cd ~/Dropbox/projects'
alias ll='ls -l'
alias mou='open -a Mou'
alias blog='cd ~/projects/octopress'
alias linode='ssh root@106.186.18.211'
alias rhodes='ssh root@106.187.88.48'
alias mini='ssh rocodev@rocodevtekiMac-mini.local'
alias aeus='ssh -i ~/Downloads/ae-us-east.pem ubuntu@ec2-107-22-15-86.compute-1.amazonaws.com'
alias github='open http://github.com/unayung'
View gist:6147134
[
{ "keys": ["super+."], "command": "open_file", "args": {"file": "/Users/Unayung/TODO"} },
{ "keys": ["super+ctrl+m"], "command": "list_rails_models" },
{ "keys": ["super+ctrl+c"], "command": "list_rails_controllers" },
{ "keys": ["super+ctrl+v"], "command": "list_rails_views" },
{ "keys": ["super+ctrl+j"], "command": "list_rails_javascripts" },
{ "keys": ["super+ctrl+s"], "command": "list_rails_stylesheets" },
{ "keys": ["ctrl+shift+r"], "command": "reindent" , "args": {"single_line": false} },
// swap the keybindings for paste and paste_and_indent
{ "keys": ["super+v"], "command": "paste_and_indent" },
View gist:6147132
/*
On OS X, basic text manipulations (left, right, command+left, etc) make use of the system key bindings,
and don't need to be repeated here. Anything listed here will take precedence, however.
*/
[
{ "keys": ["super+shift+n"], "command": "new_window" },
{ "keys": ["super+shift+w"], "command": "close_window" },
{ "keys": ["super+o"], "command": "prompt_open" },
{ "keys": ["super+shift+t"], "command": "reopen_last_file" },
{ "keys": ["super+alt+up"], "command": "switch_file", "args": {"extensions": ["cpp", "cxx", "cc", "c", "hpp", "hxx", "h", "ipp", "inl", "m", "mm"]} },
View gist:6147113
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"draw_minimap_border": true,
"font_face": "Source Code Pro Light",
"font_size": 16.0,
"ignored_packages":
[
"Vintage"
],
"tab_size": 2,
View gist:6118957
  1. rails generate devise:install
  2. rails generate devise user
  3. rake db:migrate
  4. powder restart
  5. Gemfile 裡的 jquery-rails 行,改為 gem 'jquery-rails', '~> 2.3.0'

這樣就可以開啟專案了. 但 facebook 登入會有問題. 建議是先用 rvm install 1.9.3, rvm use 1.9.3 使用 ruby 1.9.3 版 然後 gem install bootstrappers 用一般版本的 bootstrappers 產生專案, 專案網站可以開啟之後再手動去 Gemfile 裡切換成 Rails 4

View posts_controller_spec.rb
require 'spec_helper'
describe PostsController do
describe "GET show" do
post = Post.create(:title => "blog title", :body => "blog body")
it "should have assign a post and render show" do
get :show, :id => post
assign(:post).should == post
@Unayung
Unayung / parser.rb
Created Feb 26, 2013
kanmeiju parser
View parser.rb
require "nokogiri"
require "open-uri"
url = ARGV[0]
list = Nokogiri::HTML(open(url))
list = list.css('div.vpl').first
File.open("result.txt", "w") do |file|
list.css("a").each do |a|
link = a.attr('href')
file.puts link
View gist:4547283
def render_submenu_root(roots)
s = ""
roots.each do |root|
s += content_tag("li", link_to(root.name, root.link , :class => "dropdown-toggle", :data => { :toggle => "dropdown"} )+render_submenu_children(root), :class => "dropdown")
end
s.html_safe
end
@Unayung
Unayung / gist:3772442
Created Sep 23, 2012
omniauth_callbacks_controller.rb
View gist:3772442
# -*- encoding : utf-8 -*-
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def self.provides_callback_for(*providers)
providers.each do |provider|
class_eval %Q{
def #{provider}
if !current_user.blank?
current_user.bind_service(env["omniauth.auth"])#Add an auth to existing
redirect_to setting_path, :notice => "Bind #{provider} account successfully."
else
@Unayung
Unayung / gist:3772406
Created Sep 23, 2012
omniauth_callbacks.rb
View gist:3772406
# -*- encoding : utf-8 -*-
class User
module OmniauthCallbacks
["facebook"].each do |provider|
define_method "find_or_create_for_#{provider}" do |response|
uid = response["uid"]
data = response["info"]
if user = User.where( :fb_id => uid).first
You can’t perform that action at this time.