Skip to content

Instantly share code, notes, and snippets.

View rap1ds's full-sized avatar

Mikko Koski rap1ds

View GitHub Profile
@rap1ds
rap1ds / gist:5509080
Created May 3, 2013 13:20
Daily allowance calculation by country, city and start and end dates
(def country-list
{:fi {:default {:full 3900 :big 2600 :small 1300}}
:de {:default {:full 2400 :big 1200 :small 600}}
:uk {:default {:full 4200 :big 2800 :small 1400}
:london {:full 5700 :big 3800 :small 1900}}})
(defn country-allowance
([country]
(country-allowance country "default"))
([country city]
## Yield
def try
yield if block_given?
end
## Call
def try(&block)
block.call if block
@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) }
}
@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 / 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
Credit card: 5105105105105100
CVV: 555
language: ar
days:
sunday: "الأحد"
monday: "الاثنين"
tuesday: "الثلاثاء"
wednesday: "الأربعاء"
thursday: "الخميس"
friday: "الجمعة"
saturday: "السبت"
#!/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:
@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.
@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