Skip to content

Instantly share code, notes, and snippets.

@bgotink
bgotink / Yarn binaries in FISH.md
Last active January 11, 2021 23:11
Add binaries installed via yarn to the $PATH

Add this script to your fish config.

It sets up a listener. Every time the working directory changes, it checks what binaries are installed and accessible via yarn 2, and makes those accessible on the PATH.

In other words, if you've got a yarn 2 workspace you can run

yarn add -D typescript
tsc --init
@bgotink
bgotink / yarnw.sh
Last active March 30, 2022 18:41
Yarn wrapper script to use checked in yarn version without installing it globally
#!/usr/bin/env bash
#
# Wrapper script that executes the yarn version checked in in a project without
# requiring the global package to be available.
#
# This script uses nvm when a .nvmrc file is found next to it.
#
# Usage:
# - Place yarnw into the folder containing your .yarnrc / .yarnrc.yml file
# pointing to a local yarn version.
@bgotink
bgotink / _Track RxJs subscriptions.md
Last active November 27, 2018 12:19
Track all observable subscriptions

Exmaple usage:

  • Add this piece of code in your angular application's main.ts, above the bootstrap call
  • Execute subscriptions.clear() in the console, because a lot of subscriptions are created at bootstrap time
  • Trigger the actions you want to investigate
  • Copy the subscriptions map to prevent changes while you're investigating
  • Investigate
@bgotink
bgotink / index.html
Created June 19, 2016 22:43
Get paper-buttons to behave as a radio group
<paper-radio-group
class="language-select"
selected-attribute="active"
selectable="paper-button"
selected="{{language}}">
<template is="dom-repeat" items="[[possibleLanguages]]">
<paper-button disabled="[[disabled]]" toggles raised noink name="[[item]]">[[item]]</paper-button>
</template>
</paper-radio-group>

gray2white

This small C++ program converts a grayscale OpenEXR image to an image with transparancy and white colours.

behaviour

  • takes only red channel of RGBA into account, prints message if color isn't gray
  • makes any partially transparent pixel completely transparent
  • makes colours darker than #F0F0F0 white and colors lighter than or equal to #F0F0F0 transparent
@bgotink
bgotink / howto.md
Last active October 17, 2020 03:02
unset a setting if it breaks your android OS

This guide tells you how to reset a system setting in case your OS breaks once you change it. In my case, as soon as I enabled the "force RTL layout" setting, I got "System UI stopped working" over and over again, even in safe mode.

Requirements

  • This guide is written for Android 5.1, it should work for older versions (with remarks, cf. below), it might work for newer versions.
  • You'll need a custom recovery, I recomment TWRP.
  • You'll need adb available, google around to know how to install it on your OS. If you're on windows, ensure you have the drivers for your smartphone!
  • USB debugging should be enabled in the developer menu
  • If you already have root access over ADB on your phone, you can skip the entire "reboot into recovery and mount /system and /data" part. You will probably still need the reboot at the end though.
@bgotink
bgotink / background-example.bash
Created April 22, 2015 14:19
background-example.bash
background() {
local pidfile="$1"
local logfile="$2"
shift; shift;
echo $BASHPID > "$pidfile"
exec "$@" >"$logfile" 2>&1
}
set SSH_ENV $HOME/.ssh/environment
function start_agent
echo "Initializing new SSH agent ..."
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
echo "succeeded"
chmod 600 $SSH_ENV
. $SSH_ENV > /dev/null
ssh-add
end
@bgotink
bgotink / keybase.md
Created March 29, 2015 20:42
keybase.md

Keybase proof

I hereby claim:

  • I am bgotink on github.
  • I am bgotink (https://keybase.io/bgotink) on keybase.
  • I have a public key whose fingerprint is D128 69B0 D750 5125 2312 D9BA B7E1 DF5C AA0E B1A5

To claim this, I am signing this object:

@bgotink
bgotink / exportRole.js
Created November 30, 2014 19:18
Helpers when copying existing roles between litus installations
function exportRole() {
var $actions = $('#actions'),
$name = $('#name'),
$parents = $('#parents');
// TODO change to new selectors for dev-form
var result = {};
// extract the name
if ($name.length > 0) {