Skip to content

Instantly share code, notes, and snippets.

Mathias Lynnerup Jakobsen mathiasjakobsen

Block or report user

Report or block mathiasjakobsen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mathiasjakobsen
mathiasjakobsen / foo_type.rb
Created Apr 3, 2018 — forked from tanguyantoine/foo_type.rb
New Relic GraphQL Ruby instrumentation
View foo_type.rb
Types::FoosType = GraphQL::ObjectType.define do
field :foos, !types[Types::FooType] do
timed true # enable New Relic trace_execution_scoped
description "Returns foos"
argument :per, types.Int, default_value: 20
argument :page, types.Int, default_value: 1
# Moving to cursor pagination would be better
resolve(...)
end
end
View big-bang-theory.txt
Our whole universe was in a hot dense state,
Then nearly fourteen billion years ago expansion started. Wait...
The Earth began to cool,
The autotrophs began to drool,
Neanderthals developed tools,
We built a wall (we built the pyramids),
Math, science, history, unraveling the mystery,
That all started with the big bang (bang)!
"Since the dawn of man" is really not that long,
@mathiasjakobsen
mathiasjakobsen / gist:0b0c1bc1b1b62307fd7c3c262d17060b
Created Dec 14, 2017 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
View gist:0b0c1bc1b1b62307fd7c3c262d17060b
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
View tricks.js
// { "-70": "", "-69": "", ... "-1": "" }
Object.assign(...Array(70).fill().map((_, i) => -(i + 1)).reverse().map(i => ({[i]: ''})))
@mathiasjakobsen
mathiasjakobsen / onion.sh
Created Dec 15, 2016
'tor' wrapper for macOS, that automatically SOCKS proxy on the active network interface before lift off 🚀
View onion.sh
#!/usr/bin/env bash
# This is a modified version of @kremalicious's original script (https://kremalicious.com/simple-tor-setup-on-mac-os-x/)
# The script was hardcoded to a specific network interface. Now it's not ¯\_(ツ)_/¯
# Resolve the current network interface identifier
SERVICES=$(networksetup -listnetworkserviceorder | grep 'Hardware Port')
while read line; do
@mathiasjakobsen
mathiasjakobsen / twitter.js
Created Jul 26, 2016 — forked from cjoudrey/twitter.js
Lazy-rendering in PhantomJS
View twitter.js
// This example shows how to render pages that perform AJAX calls
// upon page load.
//
// Instead of waiting a fixed amount of time before doing the render,
// we are keeping track of every resource that is loaded.
//
// Once all resources are loaded, we wait a small amount of time
// (resourceWait) in case these resources load other resources.
//
// The page is rendered after a maximum amount of time (maxRenderTime)
@mathiasjakobsen
mathiasjakobsen / binary_search_tree.rb
Created Feb 3, 2016
An implementation of a binary search tree data structure, in Ruby.
View binary_search_tree.rb
module BinarySearchTree
class Node
attr_reader :value
attr_accessor :left, :right, :count
def initialize(v)
@value = v
@count = 1
end
@mathiasjakobsen
mathiasjakobsen / tricks.rb
Last active Feb 3, 2016
A collection of some useful Ruby methods and (partly) dirty tricks.
View tricks.rb
# Initilize an array containing plucked property of each hash in array
array_of_hashes = [] << array_of_hashes.map(&:hash_property)
# Generate a random alphanumeric string, with a fixed length
[*('a'..'z'), *('0'..'9')].sample(15).join
# Find average of list of intergers, read from STDIN
avg, n = 0.0, 1.0
arr = STDIN.read.split("\n").map(&:to_i)
arr.each { |i| avg = (n - 1) / n * avg + i / n; n += 1.0 }
View keybase.md

Keybase proof

I hereby claim:

  • I am mathiasjakobsen on github.
  • I am mathiasjakobsen (https://keybase.io/mathiasjakobsen) on keybase.
  • I have a public key whose fingerprint is 32FF 91BD 81D8 8D52 B192 2A12 196B FB80 362C 6EE2

To claim this, I am signing this object:

You can’t perform that action at this time.