Skip to content

Instantly share code, notes, and snippets.

View gonglexin's full-sized avatar

Lexin Gong gonglexin

View GitHub Profile
@runlevel5
runlevel5 / lotus_console.md
Last active August 29, 2015 14:02
A simple rake task that replicates the `rails console` for Lotus Framework

Lotus Console

A simple rake task that replicates the rails console for Lotus Framework

How to?

I assume that your config/application.rb is the place where you initialize all Lotus boot config

below is my config/application.rb for your interest

@eddiefisher
eddiefisher / _form.html.slim
Created March 22, 2015 15:16
refile multiply file upload
= semantic_nested_form_for @gallery, multipart: true do |form|
= form.input :file_multiple, as: :file, input_html: { multiple: true }
= form.actions do
= form.action :submit
@huacnlee
huacnlee / will_paginate.js
Created August 24, 2011 01:41
使 WillPaginate 支持用左右键翻页
// Keyboard shortcuts for browsing pages of lists
(function($) {
$(document).keydown(handleKey);
function handleKey(e) {
var left_arrow = 37;
var right_arrow = 39;
if (e.target.nodeName == 'BODY' || e.target.nodeName == 'HTML') {
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) {
var code = e.which;
@fxn
fxn / Action Mailer
Created January 26, 2012 23:26
Ruby on Rails v3.2.1 CHANGELOGs
## Rails 3.2.1 (January 26, 2012) ##
* No changes.
I'd like some clarification about Ruby 2.0:
* Is it intended to be a development release?
* If it is not a development release, why are experimental features included?
* Whether or not it is a development release, what process will be used to remove
features after release? (For example, we still have $' and friends years after
Matz has repeatedly said he wouldn't add them in retrospect.)
* Why are APIs like IO.readlines not being fixed to use keyword arguments?
* Why are API changes not being added to RubySpec?
* Is Ruby 2.0 expected to pass RubySpec before release? (This does not allow for
@JEG2
JEG2 / struct.md
Created June 3, 2013 21:50
Thinking out loud about the merits and drawbacks of two different usages of Struct…

How Should We Use Struct?

The Choice

It's common in Ruby to see some code setup a Struct like this:

class Specialized < Struct.new(:whatever)
  # ... define custom methods here...
end
@pedro
pedro / Gemfile
Last active December 18, 2015 03:18
Testing ActiveRecord performance
source "https://rubygems.org"
gem "pg"
gem "sqlite3"
unless version = ENV["AR"]
abort("specify ActiveRecord version with AR. eg: AR=2 bundle install")
else
gem "activerecord", "~> #{version}", require: "active_record"
end
@nightire
nightire / Rails 4 - Active Record Associations.md
Last active March 27, 2016 12:40
Rails 4 - Active Record Associations

Rails 4 - Active Record Associations

has_one

一对一关系:有 A 和 B,A 拥有且仅拥有一个 B

has_one

belongs_to

@ryanb
ryanb / railscasts_episodes.txt
Created June 29, 2011 21:41
List of all RailsCasts episode names with numbers
001-caching-with-instance-variables
002-dynamic-find-by-methods
003-find-through-association
004-move-find-into-model
005-using-with-scope
006-shortcut-blocks-with-symbol-to-proc
007-all-about-layouts
008-layouts-and-content-for
009-filtering-sensitive-logs
010-refactoring-user-name-part-1