Skip to content

Instantly share code, notes, and snippets.

@cloud8421
cloud8421 / gist:968286
Created May 12, 2011 10:19
Quick and dirty fix for annotate-models and Rails 3.1 beta

Not sure where the problem is but with Rails 3.1 I can't use annotate-models.

If I run annotate the error trace suggests that the script isn't detecting Rake.

A temporary fix is simple:

  • open annotations.rake. If you're using RVM, the full path is different from mine, so it's useless to paste it here.
  • Add require 'rake' at the beginning of the file and save.
  • Now it should work properly.
@cloud8421
cloud8421 / gist:1018400
Created June 10, 2011 07:44
Rails 3.1.rc4 temporary fix for production :scss error (replicated in Heroku)

Rails 3.1.rc4

If you find this error in production env:

ActionView::Template::Error (undefined method compress' for :scss:Symbol (in /app/app/assets/stylesheets/application.css))`

You can temporarily comment out the following line in config/environments/production.rb

config.assets.css_compressor = :scss

@cloud8421
cloud8421 / timeout.coffee
Created June 29, 2011 09:01
setTimeout and anonymous functions
If you want to run an anonymous function inside a setTimeout, just do:
setTimeout ( -> alert 'Hello world' ), 3000
Which will result in:
setTimeout((function() {
return alert('Hello world');
}), 3000);
@cloud8421
cloud8421 / array_presence.coffee
Created July 1, 2011 08:59
Check for the presence of a value inside an array
# If you have an array and want to check the presence of a value inside it, there’s a very fast way:
arr = ['foo', 'bar', 'baz']
is_present = 'foo' in arr #returns true
isnt_present = 'hello' in arr #returns false
# Compiles down to:
`var arr, is_present, isnt_present;
var __indexOf = Array.prototype.indexOf || function(item) {
@cloud8421
cloud8421 / redcarpet
Created October 9, 2011 14:00
Custom RedCarpet script to use in Marked.app
Not really a big magic here, just a slight modification of the default redcarpet executable file included in the RedCarpet gem. It just enables fenced code blocks. I'll probably revise it to have Albino powered syntax highlight as well.
#!/usr/bin/env ruby
# Usage: redcarpet [<file>...]
# Convert one or more Markdown files to HTML and write to standard output. With
# no <file> or when <file> is '-', read Markdown source text from standard input.
if ARGV.include?('--help')
File.read(__FILE__).split("\n").grep(/^# /).each do |line|
puts line[2..-1]
end
@cloud8421
cloud8421 / gist:1547138
Created January 1, 2012 11:57
Command line memo
# Wrap a specific gem binary to use in a different gemset (requires RVM)
rvm wrapper 1.9.3@{gemset-name} --no-prefix {binary-name}
@cloud8421
cloud8421 / .vimrc
Created January 7, 2012 12:31
Minimal .vimrc configuration for server use
set nocompatible " Use Vim settings, rather then Vi settings
set nobackup
set nowritebackup
set history=50
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set laststatus=2 " Always display the status line
" Switch syntax highlighting on, when the terminal has colors
@cloud8421
cloud8421 / devise.it.yml
Created February 16, 2012 13:45 — forked from ilpeste/devise.it.yml
I18n for Devise >= 2.0
# Italian translation for Devise >= 2.0
# Date: 2011-08-25
# Author: cloud8421
# Note: Thanks to mcanato (https://gist.github.com/1170644) for the first translation
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
it:
errors:
messages:
@cloud8421
cloud8421 / gist:1958373
Created March 2, 2012 13:28
Vim bubbling text with Tmux compatibility fix
"Bubble single lines (kicks butt)
"http://vimcasts.org/episodes/bubbling-text/
nmap <C-Up> ddkP
nmap <C-Down> ddp
nmap <C-Left> <<
nmap <C-Right> >>
"Horizontal bubbling
vnoremap < <gv
vnoremap > >gv
@cloud8421
cloud8421 / .vimrc
Created March 7, 2012 08:26 — forked from napcs/.vimrc
Set up Vim on Mac or Linux. curl https://raw.github.com/gist/532968/vim.sh | sh
" this is the configuration file for linux and mac systems
" symlink this to your home folder as .vimrc
" It loads pathogen and loads all modules from ~/.vim/bundles.
" It then loads ~/.vimrc_main which has the main
" configuration that works across all systems.
call pathogen#runtime_prepend_subdirectories(expand('~/.vim/bundles'))
call pathogen#helptags()
source ~/.vimrc_main