Skip to content

Instantly share code, notes, and snippets.

View TiddoLangerak's full-sized avatar

Tiddo Langerak TiddoLangerak

  • Sage Earth
  • Estonia
View GitHub Profile
Suppose you've branched from master like this:
```
master: a --- b --- c
\
feature: d - e
\
feature-patch: f - g
`````
@TiddoLangerak
TiddoLangerak / unhandledPromiseRejection.js
Created July 20, 2016 08:19
Angular module that monkey patches $q to detect and log unhandled promise rejection. Only tested with 1.4 and highly likely to break in newer releases. Note that this functionality is build in starting from Angular 1.6.
import angular from 'angular';
/**
* Angular doesn't yet have build in support to detect rejected promises without rejection handlers.
* This module monkey patches $q in order to implement such handling. The code below will contain
* many anti-patterns, unfortunately this is the only way to get this detection to work.
*
* Usage: depend on this module, the rest will be done for you
*
* Note that this is specifically written for angular 1.4.x and it is likely to break in later versions.
@TiddoLangerak
TiddoLangerak / watchCounter.js
Last active April 4, 2016 12:58
Functions to get the number of watchers for elements
//getWatchers function from: https://medium.com/@kentcdodds/counting-angularjs-watchers-11c5134dc2ef#.uh88feqpr
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
@TiddoLangerak
TiddoLangerak / fa-migration.js
Last active March 11, 2016 13:46
FA3->FA4 migration
import glob from 'glob';
import fs from 'fs';
import path from 'path';
//We don't want ng-class, so we need to make sure to have the \s stuff
const CLASS_REGEXP = /\sclass="(.*?)"/g;
const ICON_PREFIX_REGEXP = /^icon-/;
const replacements = {
"ban-circle": "ban",
//Simple, without $await
//In the simple variant $async/yield works like async/await. That is, yield "awaits" a promise,
//and an $async function still returns a promise
const init = $async(function*() {
const user = yield $http.get('/users/me');
$scope.user = user;
const messages = yield messageService.getMessagesFor(user);
$scope.messages = messages;
});
#!/bin/bash
# See https://gist.github.com/TiddoLangerak/c61e1e48df91192f9554 for the getCurrentWindowCWD
CWD=$(getCurrentWindowCWD)
if [ -z "$CWD" ]
then
CWD=$HOME
fi
urxvt256c-ml -cd $CWD
@TiddoLangerak
TiddoLangerak / getCurrentWindowCWD.sh
Last active February 19, 2022 08:07
Script to get the CWD of the current active window, with support for shells running tmux. This can be used to launch new terminals in the same cwd as the current one.
#!/bin/bash
# i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152
# Inspired by https://gist.github.com/viking/5851049 but with support for tmux
CWD=''
# Get window ID
ID=$(xdpyinfo | grep focus | cut -f4 -d " ")
# Get PID of process whose window this is