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:

### Keybase proof
I hereby claim:
* I am fffx on github.
* I am fangxing (https://keybase.io/fangxing) on keybase.
* I have a public key ASDS_sbZwBFaD7R-1L_SJfYfw1Gupc35i6YpvOoluiQ7Qgo
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 / The Technical Interview Cheat Sheet.md
Created July 6, 2017 04:48 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@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"
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
@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