This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find -name '*.rb' -exec sed -i -e '$a\' {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C = 1 | |
CA = 1 | |
CB = 1 | |
class A | |
CA = 2 | |
class B | |
CB = 3 | |
def c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Evaluate everything in the array and then find the result: | |
[1,2,3,4,5,6].map { |z| | |
puts "Expensive operation with #{z}" | |
z.to_s | |
}.find { |s| s.to_i > 1 } | |
Expensive operation with 1 | |
Expensive operation with 2 | |
Expensive operation with 3 | |
Expensive operation with 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExceptionHandler | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
@app.call(env) | |
rescue ActionController::ParameterMissing, ActionController::BadRequest => e | |
Rails.logger.info "Handled #{e.class}: #{e.message} with 400 Bad Request" | |
[400, {}, ['400 Bad Request']] |
Pentadactyl is VIM for your Firefox. If you think that the mouse is a productive way to control your browser, think again! It's awesome.
Here some stuff I've learned about it (Still WIP). Please write a comment or message for improvements!
To copy the URL of the current page, press y
. Open a copied URL in the current tab, press p
(P
for a new tab).
To select text, press i
. A cursor appears and you can move to the position you want with the usual commands like (h
, j
,k
,l
etc) (maybe you want to search in the page to get to the approximate position). With v
you change to select mode and then press Y
to copy it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'json' | |
require 'uri' | |
class Light | |
GREEN_ID = 4762304 | |
RED_ID = 4762303 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Xft.dpi: 96 | |
URxvt.font: xft:DejaVu\ Sans\ Mono:size=11 | |
URxvt.scrollBar: off | |
URxvt.saveLines: 4096 | |
URxvt.perl-ext-common: default,url-select,keyboard-select,font-size,clipboard | |
URxvt.urlLauncher: xdg-open |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Takes the last token of the branch name (separated with an underscore) | |
# takes adds is into the commit message. | |
# | |
# Note: If you want to about committing from the editor, remove the tag and save the file | |
# | |
# 1) Put this file into .git/hooks/prepare-commit-msg | |
# 2) Make it executable: chmod +x .git/hooks/prepare-commit-message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Date | |
# Returns the monday of the given week number | |
def self.by_iso_weekno(year, weekno) | |
# January 4th is always in the first week according to ISO 8601 | |
date = Date.civil(year, 1, 4) + (weekno - 1) * 7 | |
date - (date.wday != 0 ? date.wday - 1 : 6) % 7 | |
end | |
end |