Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am eric-hu on github.
  • I am cci_eric_hu (https://keybase.io/cci_eric_hu) on keybase.
  • I have a public key ASBg9AMrCHIevEvNhbc_TCm9-8TtfxFlStOKR_549jj2mgo

To claim this, I am signing this object:

@eric-hu
eric-hu / LSP presentation.md
Last active August 29, 2015 14:10
Liskov Substitution Principle

"If S is a subtype of T, then objects of type S should be able to replace objects of type T without altering desireable properties of the program"

=====

Goals of SOLID:

  • Address problems of rotting design
    • Rigidity
  • small changes take a long time
@eric-hu
eric-hu / invalid slim
Created July 21, 2013 03:59
Invalid slim file generated from erb2slim + devise
- - if controller_name != 'sessions'
= link_to "Sign in", new_session_path(resource_name)
br
- end -
- - if devise_mapping.registerable? && controller_name != 'registrations'
= link_to "Sign up", new_registration_path(resource_name)
br
- end -
- - if devise_mapping.recoverable? && controller_name != 'passwords'
= link_to "Forgot your password?", new_password_path(resource_name)
@eric-hu
eric-hu / erb2slim bug
Last active June 8, 2016 09:53
Steps to reproduce invalid slim code from fresh Rails/Devise install
rails new test_app
cd test_app
echo "gem 'devise', '~> 3.0.0'" >> Gemfile
bundle install
rails g devise:views
gem install html2slim
for file in app/views/devise/**/*.erb; do erb2slim $file ${file%erb}slim; done
@eric-hu
eric-hu / Open iterm tab here
Last active March 11, 2022 02:45
Apple script to open an iterm2 tab from right-clicking on a file or folder in Finder. To use: (1) Open Automator (2) Create a new service (3) Change "Service receives selected" drop downs to "Files or folders" in "Finder" (4) Select "Run applescript" from the sidebar, then paste this script in and save
-- Adapted from these sources:
-- http://peterdowns.com/posts/open-iterm-finder-service.html
-- https://gist.github.com/cowboy/905546
--
-- Modified to work with files as well, cd-ing to their container folder
on run {input, parameters}
tell application "Finder"
set my_file to first item of input
set filetype to (kind of (info for my_file))
-- Treats OS X applications as files. To treat them as folders, integrate this SO answer:
@eric-hu
eric-hu / more debugger output.rb
Created May 25, 2013 07:46
More "rake test" output for debugger #80
Run options: --seed 10083
# Running tests:
..............................................................S...........................S...................S...........SS.......................................SS...S.S....~> Console extensions: wirble hirb ap pm
.S......S.................F.FF.FFF...F.FF...F......................................................F...........................................................................S......S..............F.F..F.F..................F.
Finished tests in 1.732956s, 230.8195 tests/s, 249.2850 assertions/s.
1) Failure:
@eric-hu
eric-hu / debugger_failing_tests.rb
Created May 24, 2013 18:42
rake test output of debugger gem
1) Failure: test_0001_must_display_current_backtrace_with_last_callstyle(Frame
Command::display backtrace with callstyle)
[/Users/erichu/Dropbox/ruby_apps/gem_development/debugger/lib/debugger/test/test_dsl.rb:94]:
Expected
["/Users/erichu/Dropbox/ruby_apps/gem_development/debugger/test/examples/frame.rb:3\n@should_break
= false", "", "[-2, 7] in
/Users/erichu/Dropbox/ruby_apps/gem_development/debugger/test/examples/frame.rb",
"1 debugger", "2", "=> 3 @should_break = false", "4", "5 t = Thread.new
do", "6 while !@should_break", "7 A.new.a", "Frame call-display style
is last", "Breakpoint 103 file
@eric-hu
eric-hu / TiDocs.sh
Created February 14, 2013 11:36
Getting offline version of Titanium mobile docs on Ubuntu
#! /bin/sh
# Run this from the folder you want to be the parent of your docs
# By default, generated docs go into
# titanium_mobile/dist/apidoc/ti_mobile_docs/
#
# This can be changed below
git clone https://github.com/appcelerator/titanium_mobile.git
cd titanium_mobile
sudo apt-get install python-setuptools python-dev
@eric-hu
eric-hu / session_vim_error_log
Created February 6, 2013 01:52
session.vim :RestartVim error log
Searching for "autoload/xolox/misc/timer.vim" in "/Users/erichu/.vim,/Users/erichu/.vim/bundle/NERDcommenter,/Users/erichu/.vim/bundle/YouCompleteMe,/Users/erichu/.vim/bundle/fugitive,/Users/erichu/.vim/bundle/mustache.vim,/Users/erichu/.vim/bundle/nerdtree,/Users/erichu/.vim/bundle/tabular,/Users/erichu/.vim/bundle/vim-coffee-script,/Users/erichu/.vim/bundle/vim-haml,/Users/erichu/.vim/bundle/vim-jst,/Users/erichu/.vim/bundle/vim-powerline,/Users/erichu/.vim/bundle/vim-rails,/Users/erichu/.vim/bundle/vim-session,/Users/erichu/.vim/bundle/vim-surround,/Users/erichu/.vim/bundle/vimclojure,/usr/local/Cellar/macvim/7.3-66/MacVim.app/Contents/Resources/vim/vimfiles,/usr/local/Cellar/macvim/7.3-66/MacVim.app/Contents/Resources/vim/runtime,/usr/local/Cellar/macvim/7.3-66/MacVim.app/Contents/Resources/vim/vimfiles/after,/Users/erichu/.vim/bundle/tabular/after,/Users/erichu/.vim/bundle/vim-coffee-script/after,/Users/erichu/.vim/after"
Searching for "/Users/erichu/.vim/autoload/xolox/misc/timer.vim"
Searching for "/Us
@eric-hu
eric-hu / ec2-unbundle bug
Created January 3, 2013 21:43
ec2-unbundle error output
1.9.3-p286 Eric-Mac:~ erichu $ ec2-unbundle
/usr/local/Library/LinkedKegs/ec2-ami-tools/jars/lib/ec2/platform/current.rb:43:in `initialize': ["/usr/local/Library/LinkedKegs/ec2-ami-tools/jars/lib/ec2/platform/current.rb:53:in `<module:Platform>'", "/usr/local/Library/LinkedKegs/ec2-ami-tools/jars/lib/ec2/platform/current.rb:16:in `<module:EC2>'", "/usr/local/Library/LinkedKegs/ec2-ami-tools/jars/lib/ec2/platform/current.rb:15:in `<top (required)>'", "/Users/erichu/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'", "/Users/erichu/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'", "/usr/local/Library/LinkedKegs/ec2-ami-tools/jars/lib/ec2/amitools/unbundle.rb:14:in `<main>'"] (EC2::Platform::Unsupported)
from /usr/local/Library/LinkedKegs/ec2-ami-tools/jars/lib/ec2/platform/current.rb:53:in `<module:Platform>'
from /usr/local/Library/LinkedKegs/ec2-ami-tools/jars/lib/ec2/platform/current.rb:16:in `<module:EC2>'
f