Skip to content

Instantly share code, notes, and snippets.

@fffx
fffx / how.md
Created November 1, 2017 01:01
Rails load additional gem without modify your project gemfile

bundler load gemfile by look up ENV["BUNDLE_GEMFILE"] , so your can set this enviromental variable to another gemfile , let say local_gemfile, and then in your local_gemfil, first load the project gemfile, and then add your additional ges.


# local_gemfile

 eval File.read('Gemfile')
 
 gem 'other_gems'
@fffx
fffx / irb_require_without_bundler_hack.rb
Created October 31, 2017 08:18 — forked from skojin/irb_require_without_bundler_hack.rb
workaround to load irb specific gem (loaded in .irbrc) in bundler environment, like rails3 console
# Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler
if defined?(::Bundler)
$LOAD_PATH.concat Dir.glob("#{ENV['rvm_path']}/gems/#{ENV['rvm_ruby_string']}@global/gems/*/lib")
end

Keybase proof

I hereby claim:

  • I am fffx on github.
  • I am fangxing (https://keybase.io/fangxing) on keybase.
  • I have a public key ASBV9mFRZbdxkDQ6xtf1PP2bAUF8ScN04_Dh670V3uag5go

To claim this, I am signing this object:

@fffx
fffx / routes.md
Created July 7, 2017 02:14 — forked from dideler/routes.md
Rails Routes

A summary of the Rails Guides on Routes, plus other tips.

The Rails router recognizes URLs and dispatches them to a controller's action. It can also generate paths and URLs, avoiding the need to hardcode strings in your views.

Examples

# Redirects /orders/report to orders#report.
get 'orders/report', to: 'orders#report'
@fffx
fffx / Rakefile
Created July 5, 2017 05:12 — forked from schickling/Rakefile
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
# Using these pry gems
# gem "pry"
# gem "pry-rails"
# gem "pry-byebug"
# gem "pry-stack_explorer"
# gem "pry-doc"
# gem "pry-state"
# gem "pry-toys"
# gem "pry-rescue"
@fffx
fffx / .zsh.md
Last active June 4, 2017 02:23
My zsh configure structure
  • .oh-my-zsh
  • .zshrc # for load other files
  • .zsh
    • env # for my enviroments
    • env_private # private enviroments
    • alias # for alias
  • function # custom functions
@fffx
fffx / readme.md
Created June 3, 2017 07:27
install crouton in chrome book c720

Install crounton

Enable Developer Mode

  1. Hold Esc + Refresh and then press the power button. The Chromebook will restart and give a warning about the OS being missing or damaged Press Ctrl + D to bypass this message. It will now ask if you want to turn os verification off. Press Return to continue into developer mode
  2. The Chromebook will now prepare the os for developer mode. Just leave this to run for a good few minutes. It will boot backup to chrome when finished. Everytime you restart you chromebook from now on you will get an OS verification warning. you can either wait 30 seconds and the Chromebook will boot, or you can skip this message by pressing Ctrl + D
@fffx
fffx / zshrc
Created May 23, 2017 01:36
tmux auto start sesion
if [[ -z "$TMUX" ]]
then
ID="`tmux ls | grep -vm1 attached | cut -d: -f1`"
if [[ -z "$ID" ]]
then
tmux new-session
else
tmux attach-session -t "$ID"
fi
fi
@fffx
fffx / spacemacs-cheshe.md
Created May 22, 2017 09:39
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers