Skip to content

Instantly share code, notes, and snippets.

View iGEL's full-sized avatar

Johannes Barre iGEL

View GitHub Profile
@iGEL
iGEL / pentadactyl_usage.md
Last active August 29, 2015 13:57
Some stuff I learned about Pentadactyl

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!

Copy & paste

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.

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']]
@iGEL
iGEL / lazy.rb
Created June 29, 2014 15:18
lazy Ruby 2.0
# 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
@iGEL
iGEL / wtf.rb
Last active August 29, 2015 14:03
From classes, you can reference toplevel constants even with a namespace! It'll just issue warnings. From modules, you get a NameError
C = 1
CA = 1
CB = 1
class A
CA = 2
class B
CB = 3
def c
@iGEL
iGEL / fix_nl_at_eol.sh
Last active August 29, 2015 14:03
Fix all missing newline at EOL recursively
find -name '*.rb' -exec sed -i -e '$a\' {} \;
@iGEL
iGEL / check_out_spec.rb
Last active April 14, 2022 16:10
RSpec version of the tests for Kata 09
# This is a reimplementation of the tests of this kata:
# http://codekata.com/kata/kata09-back-to-the-checkout/
# Original implementation by Dave Thomas
RSpec.describe CheckOut do
# Item Unit Special
# Price Price
# --------------------------
# A 50 3 for 130
# B 30 2 for 45
@iGEL
iGEL / webmock_curl.rb
Last active September 9, 2015 14:16
Patch WebMock to print the curl command on disabled net connect. Just copy & paste it to execute.
module WebMock
class NetConnectNotAllowedError < Exception
alias_method :stubbing_instructions_without_curl, :stubbing_instructions
private
def stubbing_instructions(request_signature)
[
stubbing_instructions_without_curl(request_signature),
CurlInstructions.new(request_signature).instructions
@iGEL
iGEL / keybase.md
Last active February 8, 2018 23:18

Keybase proof

I hereby claim:

  • I am igel on github.
  • I am igelei (https://keybase.io/igelei) on keybase.
  • I have a public key ASDx5e08AAwZryDHFw8SUstrqXo7r9JFyYuYES17Xmqw2Ao

To claim this, I am signing this object:

@iGEL
iGEL / mail_patch.rb
Created March 3, 2017 09:15
Safe monkey patched mail 2.6.4 deprecation warnings for Ruby 2.4
# frozen_string_literal: true
unless Mail::VERSION.version == "2.6.4"
raise "Please delete #{__FILE__}, it's not required anymore"
end
# This file monkey patches away the new deprecation warnings from Ruby 2.4.
# Lifted here:
# * https://github.com/mikel/mail/pull/1053
# * https://github.com/mikel/mail/pull/1058