Skip to content

Instantly share code, notes, and snippets.

View Overbryd's full-sized avatar

Lukas Rieder Overbryd

View GitHub Profile
@Overbryd
Overbryd / benchmark.rb
Created April 1, 2016 20:38
Ruby named params benchmark
require "benchmark/ips"
# Run instructions
#
# gem install benchmark-ips
# ruby benchmark.rb
def with_named_params(a:, b:)
a + b
end
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFgb++kuk9Aoea7waDAoBm+g9y2d3yd4TAVuNxX35tN8LBYam8Y0+97s6vHH/hk4BD1CrB2N02UX7f05JoypmvQicqxsVN97KxKK7yxfwqZMG836Cokq8TkqfPhhBCLidSI+zJVc8n3rGJlxG0vh+cr7XSd2hs4b0HgdZtUZg6GcOnh4vc1kQSFOpdDeAusQFCyJ0NEYe8vgWSEDU2QMWSRUQpZ8H/Rftn+YbcfQFgXS7/vc0K+pi/Ayj241vUQJ9eXMaw7e0TXYmr8/USwonN3xm31zCryWQN4zZlEayIuD86d7lo60ommEBK3hn3VqQb/M9WA6cbMY3Ffjv3XoHJ lukasrieder
@Overbryd
Overbryd / adyen.md
Last active December 16, 2015 20:37

1. Creating a recurring contract with the clients encrypted credit card:

There I am using an amount with value: 0 to ensure the clients card is valid without creating an actual charge. The request is like any payment request, but explicitly states a shopper reference and the recurring contract.

Request:

POST https://pal-test.adyen.com/pal/servlet/Payment/v12/authorise
Content-Type: application/json; charset=utf-8
Pragma: process-retry
@Overbryd
Overbryd / budda.rb
Created December 15, 2015 21:47
Gives you one german wisdom by Budda.
require "open-uri"
# Public: Gives you one german wisdom by Budda.
def wise_saying
open("http://zitatezumnachdenken.com/buddha/page/#{1 + Date.today.yday % 5}")
.read
.scan(%r{<a href="http://zitatezumnachdenken.com/buddha/\d+"><p>.+})
.map { |line| line =~ %r{<p>(.+)</p>} && $1 }
.compact
.sample
@Overbryd
Overbryd / repair.md
Last active April 4, 2016 08:06
MacBook Pro repair level: Christmas Cookies

Issue

My display stopped working, showed weird patterns and shut off at random. My graphics basically looked like striped christmas wrapping. I got a 15" MacBook Pro Late 2011 model.

Solution

Some googling for the issue on my iPad showed that baking my logic board, as weird as it sounds, might actually be the solution. Since it was a dead logic board in my eyes, I was willing to give it a try. Correctly put, this process should reflow some of the solder on the logic board and connect it properly.

And later I found out these video issues are a thing, thus Apple offering a repair for these models. If you happen to have this video problems: You might want to turn it in at your local Apple repair store.

@Overbryd
Overbryd / assert_raises_transaction_safe.rb
Last active December 12, 2015 07:17
Minitest assert_raises with Sequel, safe for transactions
# A module that allows DatabaseCleaner users to use assert_raises without breaking the transaction.
#
# Use with Module#prepend in a MiniTest::Spec class.
# You may need to adapt `DB` to your Sequel connection.
module AssertRaisesTransactionSafe
def assert_raises(*args)
if DB.in_transaction? && DB.supports_savepoints?
super(*args) do
DB.transaction(savepoint: true) { yield }
end
@Overbryd
Overbryd / index.html
Last active November 25, 2015 10:52
object_constancy_in_visualisations (see http://bl.ocks.org/Overbryd/raw/a93ddc3ea2ccff05f438/)
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.axis text {
font: 1.1em sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
@Overbryd
Overbryd / 0_usage.md
Last active November 14, 2015 03:39
Auto-refreshing XOAuth token system for Google

Usage

Simple as XOauthSession.access_token.

First time usage, either create a yaml file yourself or:

Setup your app at Google developer console. There you follow the menu "APIs & auth" > "Credentials". Click "Create new Client ID" and select "Installed Application" and then "Other". Download oauth2.py and execute the following with the credentials of the Google Developer console.

require "json"
require "turbotlib"
require "mechanize"
require "pdf-reader"
require "pry"
agent = Mechanize.new
agent.max_history = nil # unlimited history
agent.pluggable_parser.pdf = Mechanize::Download
@Overbryd
Overbryd / pajax.js
Created May 26, 2015 16:34
This gives pajax functionality
// pajax functionality
function pajaxForm(form) {
var url = form.attr("action");
var target = form.data("pajax");
form.ajaxSubmit({
type: "POST",
url: url,
target: "*[data-pajax-target=" + target + "]"
});
};