Skip to content

Instantly share code, notes, and snippets.

@bgotink
bgotink / ._what.md
Last active July 26, 2022 14:13
A small C++ program that converts grayscale EXR to transparent EXR

gray2transparent

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

behaviour

  • takes only red channel of RGBA into account, prints message if color isn't gray
  • ignores pixels with transparancy already set tot a non-opaque value
  • makes lighter colors more transparant: alpha = 1 - red
@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 / 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 / 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 / _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 / mount_tmpfs.sh
Created August 6, 2012 19:16 — forked from koshigoe/mount-ram.sh
Like tmpfs in Mac OS X. This code is public domain.
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size>
#
@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>
@bgotink
bgotink / ._what.md
Last active December 25, 2015 06:29 — forked from barijaona/._what.md

Badass git pull alternative

Add this in your path as git-up and git-reup (symbolic link) and it amps up your git pull by means of git up

  1. Adds in a list of the commits you're pulling down
  2. Auto-prunes remote branches
  3. Defaults to pull --rebase - gets rid of unnecessary merge commits. If you don't know what rebase does, this is probably safe for you. If you know what rebase does, you should know where this will not be safe for you.

Kyle Neath, Ryan Tomayko and then Zach Holman basically figured out how to do this. TheSpyder found a small error on case sensitive file systems.

@bgotink
bgotink / collatz.c
Created September 7, 2012 02:02
Collatz conjecture program in C, depends on libgmp
#include <stdio.h>
#include <string.h>
#include <gmp.h>
/*
* Dependency: libgmp
* Compile using:
* gcc -o collatz -l gmp collatz.c
*/
@bgotink
bgotink / brew.log
Created August 16, 2012 21:37
"brew install --HEAD e2fsprogs" log
bram:~/Downloads/backup$ brew install --HEAD e2fsprogs
==> Cloning https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
Cloning into '/Library/Caches/Homebrew/e2fsprogs--git'...
remote: Counting objects: 33824, done.
remote: Compressing objects: 100% (7500/7500), done.
remote: Total 33824 (delta 27272), reused 32257 (delta 26058)
Receiving objects: 100% (33824/33824), 16.32 MiB | 139 KiB/s, done.
Resolving deltas: 100% (27272/27272), done.
==> Downloading patches
######################################################################## 100.0%