Skip to content

Instantly share code, notes, and snippets.

@ilake
ilake / tips_for_asset_pipeline.md
Last active August 29, 2015 14:01
12 Tips for the Rails Asset Pipeline

http://www.reinteractive.net/posts/116-12-tips-for-the-rails-asset-pipeline

The asset pipeline is not quite your assets folder

  • Every file that is not a Javascript file or CSS file that is in the app/assets folder will be copied by Rails into the public/assets folder when you compile your assets.

Don't fall back in staging or production

  • config.assets.compile
  • If it is set to "true" (which it is by default in development) then Rails will try to find a Javascript or CSS file by first looking in the public/assets directory and if it can't find it, will hunt through your app/assets folder looking for the file. If it finds it in app/assets it will go ahead and compile on the fly and then serve this asset up.
@ccckmit
ccckmit / gist:b0a90a7bd9d3d3e5baa8
Last active August 29, 2015 14:16
javascript version of enigma machine (in world war II)
// 原始程式來源: http://practicalcryptography.com/ciphers/enigma-cipher/ 網頁內的 javascript 程式碼
var c = console;
var plaintext = 'ABCDEF';
c.log('>> plaintext2 : '+plaintext);
var ciphertext = Encrypt(plaintext, 'AAA', 'AAA', '123', 'POMLIUKJNHYTGBVFREDC');
c.log('>> ciphertext : '+ciphertext);
var plaintext2 = Encrypt(ciphertext, 'AAA', 'AAA', '123', 'POMLIUKJNHYTGBVFREDC');
c.log('>> plaintext2 : '+plaintext);
# Projects
Project.all # get all projects
@project = Project.find('84948') # get specific project
# Members
@project.members.all # access a project's members
@project.members.add!(:role => 'Owner', :name => 'John Doe', :initials => 'JD', :email => 'john.doe@mymail.com') # add user to project
@member = @project.members.find('3747') # get specific member
@member.remove!
@markbates
markbates / date_time.coffee
Created May 11, 2011 19:07
Example: Rails-style date/time helpers in CoffeeScript
Number::seconds = ->
@ * 1000
Number::minutes = ->
@seconds() * 60
Number::minute = Number::minutes
Number::hours = ->
@minutes() * 60
@taiansu
taiansu / .bash_profile
Created August 8, 2011 07:01 — forked from ihower/gist:897951
bash_profile setting
export CLICOLOR=1;
export LSCOLORS=ExFxCxDxBxegedabagacad;
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
now=`date +%s`;
@joshed-io
joshed-io / dzello.conf
Created September 27, 2011 23:41
Add a directory to your Mac OSX web sharing server by editing apache conf
#substitute 'dzello' in these examples with your OSX account's username
#substitute the illustrative repository path (preview_markdown_locally) with your repository path
#add these lines to the file at /etc/apache2/users/dzello.conf
Alias /~dzello/preview_markdown_locally "/Users/dzello/workspace/preview_markdown_locally"
<Directory "/Users/dzello/workspace/preview_markdown_locally">
Order allow,deny
Allow from all
</Directory>
@rc1021
rc1021 / gist:3736213
Created September 17, 2012 08:41
Issues with RMagick on RubyStack 3.2.1-1
// will be error.
$ sudo gem install rmagick -v '2.13.1'
// If you want to compile or install your own RMagick, you should install the following libraries in your system:
$ sudo apt-get install libbz2-dev libxt-dev libxext-dev
// Then remove the following file if exists:
$ sudo rm /opt/bitnami/common/lib/libbz2.a
// And finally you can install RMagick
@maylogger
maylogger / gist:3759884
Created September 21, 2012 05:31
貓假圖
module ViewHelpers
def placekitten(size, options={})
domain = options[:domain] || "http://placekitten.com"
src = "#{domain}/#{size}?image=#{rand(16)+1}"
g = options[:g]
if options[:g]
src = "#{domain}/g/#{size}?image=#{rand(16)+1}"
end
@mig
mig / init.el
Created January 18, 2011 21:00
Simple Emacs 24 configuration for Rails development
;; emacs configuration
(push "/usr/local/bin" exec-path)
(add-to-list 'load-path "~/.emacs.d")
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
@othree
othree / .vimrc
Last active December 19, 2015 08:19
let &t_8f="^[[38;2;%lu;%lu;%lum"
let &t_8b="^[[48;2;%lu;%lu;%lum"