Skip to content

Instantly share code, notes, and snippets.

View rap1ds's full-sized avatar

Mikko Koski rap1ds

View GitHub Profile

Upgrading from Rails 4.1 to Rails 4.2

Web Console [1/1]

First, add gem 'web-console', '~> 2.0'= to the =:development group in your Gemfile and run bundle install (it won’t have been included when you upgraded Rails). Once it’s been installed, you can simply drop a reference to the console helper (i.e., <% console %>=) into any view you want to enable it for. A console will also be provided on any error

@rap1ds
rap1ds / rails_41_upgrade_notes.org
Created February 2, 2016 08:31
Rails 4.1 upgrade notes

Upgrading from Rails 4.0 to Rails 4.1

CSRF protection from remote <script> tags [1/1]

Or, “whaaat my tests are failing!!!?” or “my <script> widget is busted!!”

Cross-site request forgery (CSRF) protection now covers GET requests with JavaScript responses, too. This prevents a third-party site from

@rap1ds
rap1ds / projectile_keyboard.md
Created October 2, 2014 11:45
Projectile keyboards

Interactive Commands

Here's a list of the interactive Emacs Lisp functions, provided by projectile:

Keybinding Description
C-c p f Display a list of all files in the project. With a prefix argument it will clear the cache first.
C-c p F Display a list of all files in all known projects.
C-c p 4 f Jump to a project's file using completion and show it in another window.
C-c p d Display a list of all directories in the project. With a prefix argument it will clear the cache first.
#!/usr/local/bin/python
"""
To use this script, you must be in the root directory of a Rails project that
is using git. You should also make sure that your directory does not contain any
uncommitted changes. Then run:
$ python rails_switch_branch.py name_of_another_branch
Running the above will do the following:
language: ar
days:
sunday: "الأحد"
monday: "الاثنين"
tuesday: "الثلاثاء"
wednesday: "الأربعاء"
thursday: "الخميس"
friday: "الجمعة"
saturday: "السبت"
Credit card: 5105105105105100
CVV: 555
@rap1ds
rap1ds / gist:c72e3c736ef1bceb8353
Last active August 29, 2015 14:01
Mavericks update
I just updated to #mavericks, and here are notes (in case someone else is doing the update):
#mavericks
1. Terminal stopped working, might be because of ZSH. I had to go to Terminal -> Preferences -> Startup -> Shells open with: Command: /bin/zsh
2. Xcode needs to be updated to get RVM working. Update Xcode and run it once to finalize the update.
3. Remove all rubies `rvm list ; rvm remove ... ;`
4. Remove RVM `rvm implode`
5. Update brew `brew update`
6. Run `brew doctor` and resolve all issues
@rap1ds
rap1ds / clean-branches
Created April 28, 2014 05:58
Clean branches merged to the current branch
[alias]
clean-branches = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
@rap1ds
rap1ds / stripspace.rb
Last active August 29, 2015 13:57
Remove all whitespaces from Rails project: Run the script in Rails console
Dir.glob("app/**/*").select { |filename| ["rb", "js", "css", "scss", "erb", "haml", "yml"].include? filename.split(".").last }.each { |filename|
stripped = `git stripspace < #{filename}`
File.open(filename, 'w') { |file| file.write(stripped) }
}
## Yield
def try
yield if block_given?
end
## Call
def try(&block)
block.call if block