Skip to content

Instantly share code, notes, and snippets.

View mathiasjakobsen's full-sized avatar
🚀
Making Voice Over Great Again

Mathias Lynnerup Jakobsen mathiasjakobsen

🚀
Making Voice Over Great Again
View GitHub Profile
@mathiasjakobsen
mathiasjakobsen / foo_type.rb
Created April 3, 2018 11:43 — forked from tanguyantoine/foo_type.rb
New Relic GraphQL Ruby instrumentation
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
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 December 14, 2017 15:36 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
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
// { "-70": "", "-69": "", ... "-1": "" }
Object.assign(...Array(70).fill().map((_, i) => -(i + 1)).reverse().map(i => ({[i]: ''})))
@mathiasjakobsen
mathiasjakobsen / onion.sh
Created December 15, 2016 23:06
'tor' wrapper for macOS, that automatically SOCKS proxy on the active network interface before lift off 🚀
#!/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 July 26, 2016 15:09 — forked from cjoudrey/twitter.js
Lazy-rendering in PhantomJS
// 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 February 3, 2016 20:34
An implementation of a binary search tree data structure, in Ruby.
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 February 3, 2016 21:05
A collection of some useful Ruby methods and (partly) dirty tricks.
# 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 }
@mathiasjakobsen
mathiasjakobsen / keybase.md
Last active August 29, 2015 14:01
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: