Skip to content

Instantly share code, notes, and snippets.

@rektide
rektide / promiseOriginMonkeypatch.js
Last active June 28, 2017 20:27
monkeypatch tracking origins onto Promise
var promiseSource = new WeakMap()
(function(){
const promiseConstructor = Promise.constructor
Promise.constructor = function(fn){
console.log("monkeypatch successful")
promiseConstructor.call(this, fn)
promiseSource.set(this, new Error().stack)
}
}())
var sample = new Promise(x => x(42)) // expecting: "monkeypatch successful"
@rektide
rektide / pain.md
Last active May 2, 2017 23:36
Post Ansible 2.1 Pain

In the releases after Ansible 2.1, a vast amount of the expressivitiy in Ansible went away or broke.

I was in pain and hurting. I started trying to to upstream things I needed to continue on, but the templating situation post 2.1 was really bad with no signs of recovery to the once pristine state.

I somewhat dramatically opined, about what felt like a world I had built upon shattering,

Damnit Ansible could you have done any more to ruin it all.

Your fall has cast a horrible pall over all good things in this world. The birds no longer chirp. The grass is dead.

@rektide
rektide / cloudformation.user.js
Last active February 8, 2017 20:28
Userscript to add a "term" parameter in the url to allow filtering of CloudFormation listings
// ==UserScript==
// @name CloudFormation Filter
// @namespace http://tampermonkey.net/
// @version 0.99a
// @description add filterability to the CloudFormation URL template via a "term" query parameter in the hash
// @author rektide
// @match https://console.aws.amazon.com/cloudformation/home*
// @grant none
// ==/UserScript==
@rektide
rektide / gmusicapi-ifl-random.py
Last active January 9, 2017 01:41
GMusicAPI playing IFL
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import, unicode_literals
from builtins import * # noqa
from getpass import getpass
from gmusicapi import Mobileclient
@rektide
rektide / mssculpt.xinput
Created December 30, 2016 02:19
Microsoft Sculpt Comfort Mouse properties
$ xinput --list-props 17
Device 'ThinkPad Compact Bluetooth Keyboard with TrackPoint':
Device Enabled (139): 1
Coordinate Transformation Matrix (141): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix (300): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix Default (301): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Accel Speed (283): 0.000000
libinput Accel Speed Default (284): 0.000000
libinput Accel Profiles Available (596): 1, 1
libinput Accel Profile Enabled (597): 1, 0
@rektide
rektide / README.md
Created November 10, 2016 19:40
ruby rescue cost

What/Why

I as concerned about whether the presence of rescue in Ruby had significant performance impact.

In JavaScript for example try/catch historically has had significant impact itself, even when no exceptions were being thrown.

Based on these benchmarks though, I can see Ruby doesn't seem to have significant cost for defining exception handlers.

Results

@rektide
rektide / README.md
Last active August 25, 2016 20:33
Use `direnv` instead of systemd

Direnv-launch

Systemd is supposed to be the swiss army knife of starting things and keeping them going. For the most part, it works really really well. It has a very flexible developer-friendly way of letting one specify EnvironmentFile's providing environmental variables for programs it's launching.

The major pitfall is that it does not in any way support multi-line values. If you want to pass in a normal boring certificate to your applicatino (because you are a good respectful 12factor dev practicing proper config), you may be S.O.L (shit out of luck).

Thie horrible helper, direnv-launch, lets one use direnv-ish files when launching programs. Direnv's .envrc files can be multi-line, which is great. This is also going to be compatible and useful with your fellow Mac & Windows developers. Note that variables must be declared as export in envrc, as in export FOO=bar, which is different, but closely mimics how everything

@rektide
rektide / become.yml
Last active July 28, 2016 14:56
become changes ansible_ssh_user
---
- hosts: all
tasks:
# this is created with my username in my homedir
- file: path=~/ansible-become-test state=directory owner="{{ansible_ssh_user}}"
# this is owned by root
- file: path=/opt/ansible-become-test state=directory owner="{{ansible_ssh_user}}"
become: True
@rektide
rektide / battery-one-oh.prom
Created July 25, 2016 01:03
battery charge, battery voltage, current drain, voltage*current (power)
http://localhost:9090/graph#%5B%7B%22range_input%22%3A%222h%22%2C%22end_input%22%3A%22%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3A%22%22%2C%22expr%22%3A%22node_power_supply_charge_now%22%2C%22tab%22%3A0%7D%2C%7B%22range_input%22%3A%222h%22%2C%22end_input%22%3A%22%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3A%22%22%2C%22expr%22%3A%22node_power_supply_voltage_now%22%2C%22tab%22%3A0%7D%2C%7B%22range_input%22%3A%222h%22%2C%22end_input%22%3A%22%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3A%22%22%2C%22expr%22%3A%22node_power_supply_current_now%22%2C%22tab%22%3A0%7D%2C%7B%22range_input%22%3A%222h%22%2C%22end_input%22%3A%22%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3A%22%22%2C%22expr%22%3A%22node_power_supply_current_now*node_power_supply_voltage_now%22%2C%22tab%22%3A0%7D%5D
@rektide
rektide / direnv-launch
Created July 21, 2016 15:14 — forked from mfowlewebs/direnv-launch
~/.bin/direnv-launch
#!/bin/zsh
. ./.envrc
eval $*