Skip to content

Instantly share code, notes, and snippets.

View lin's full-sized avatar

Albert Lin lin

View GitHub Profile
@lin
lin / window_url.js
Created February 23, 2015 19:33
Javascript Modify the window url
window.history.pushState("", "", '/newpage');
@lin
lin / devise-routes.rb
Last active August 25, 2020 20:57
Rails Basic
devise_for :people, skip: [:sessions, :passwords, :confirmations, :registrations]
as :person do
# session handling
get '/login' => 'devise/sessions#new', as: 'new_person_session'
post '/login' => 'devise/sessions#create', as: 'person_session'
delete '/logout' => 'devise/sessions#destroy', as: 'destroy_person_session'
# joining
get '/join' => 'devise/registrations#new', as: 'new_person_registration'
post '/join' => 'devise/registrations#create', as: 'person_registration'
@lin
lin / imagemagick.md
Created February 26, 2015 04:28
Install imagemagick

Stackoverflow page

  1. sudo brew install imagemagick
  2. brew link --overwrite imagemagick

use which convert and which identify to check whether it is well installed.

@lin
lin / model_subfolder_load.md
Created February 26, 2015 17:26
Rails tricks

To let the application to load all the files in app/models/folder,

In application.rb add following line:

config.autoload_paths += Dir[ Rails.root.join('app', 'models', '**/') ]
@lin
lin / 1_aws.md
Last active August 29, 2015 14:16
A Rails Project

It should be as simple as possible.

1, ssh to the site

$ ssh philly

2, cd to the folder

<script>
var options = {
zoomType: 'standard',
lens:true,
preloadImages: false,
alwaysOn:false,
zoomWidth: 500,
zoomHeight: 500,
xOffset:30,
yOffset:0,
Product.where(:title => Regexp.new( ".*" + params[:term].to_s + ".*", true ) )
@lin
lin / better.rb
Created March 6, 2015 23:58
Better ruby
# if nil set value after ||
tweets = timeline.tweets || []
def sign_in
current_session || sign_user_in
end
set_or_not_var ||= 2
options[:country] ||= 'us'
@lin
lin / 1 setup.md
Last active August 29, 2015 14:17
Ruby testing

1, add to gem file

gem "rspec-rails", :group => [:test, :development]
group :test do
  gem "factory_girl_rails"
  gem "capybara"
  gem "guard-rspec"
end
@lin
lin / 1 setup test env.md
Last active August 29, 2015 14:17
Testing

Gem file

group :development, :test do
  gem "rspec-rails"
end

group :test do
  gem "factory_girl_rails"
  gem "capybara"
 gem "guard-rspec"