Skip to content

Instantly share code, notes, and snippets.

View mislav's full-sized avatar

Mislav Marohnić mislav

View GitHub Profile
@mislav
mislav / promote.sh
Created October 3, 2016 21:16
Publish a git branch and open a tmux split that reports the outcome of CI
#!/bin/bash
# Pushes the current branch to origin and opens a tiny tmux split to track
# the CI status. Upon completion, speaks the status aloud using `say`.
set -e
if [ "$1" != "--wait" ]; then
git push -u origin HEAD
tmux split-window -dv -l 2 "'$0' --wait"
else
ref="$(git rev-parse -q HEAD)"
@mislav
mislav / update.sh
Created August 14, 2016 11:13
Script to keep your Twitter archive up to date
#!/bin/bash
set -e
cd "${0%/*}"
export GEM_HOME="${PWD}/.gem"
export GEM_PATH="$GEM_HOME"
if [ ! -x "${GEM_HOME}/bin/grailbird_updater" ]; then
/usr/bin/gem install grailbird_updater --no-rdoc --no-ri
fi
@mislav
mislav / netflix.sh
Last active February 21, 2024 16:56
Watch Netflix as if you were in the US by proxying DNS through a DigitalOcean instance.
#!/bin/bash
set -e
droplet=netflix
interface=Wi-Fi
us_regions=( nyc1 nyc2 nyc3 )
random_region() {
echo ${us_regions[RANDOM % ${#us_regions[@]}]}
}
@mislav
mislav / git-recently-checkout-branches.sh
Created November 19, 2015 15:35
Show list of recently checked-out branches in reverse-chronological order
#!/bin/bash
set -e
git reflog -n100 --pretty='%cr|%gs' --grep-reflog='checkout: moving' HEAD | {
seen=":"
git_dir="$(git rev-parse --git-dir)"
while read line; do
date="${line%%|*}"
branch="${line##* }"
if ! [[ $seen == *:"${branch}":* ]]; then
@mislav
mislav / poor_promise.js
Last active May 21, 2021 21:52
Poor man's Promise is a minimal but complete implementation of Promises/A+ spec.
(function(self){
if (self.Promise) return
// Implements https://promisesaplus.com
function isFunction(fn) {
return typeof fn == 'function'
}
// Values that should never be checked for presence of a `then` method
function simpleValue(fn) {
@mislav
mislav / spotify-remote-patch.sh
Last active May 4, 2023 11:09
Patch installer for OS X `rcd` daemon to make headset remote buttons start/stop Spotify instead of iTunes. The pause/resume functionality still doesn't work unless iTunes is running in the background, for some inexplicable reason.
#!/bin/bash
# Run once to patch `rcd` daemon after creating a backup.
# Run again to restore the backup and revert back to original functionality.
set -eu
if [ "$USER" != "root" ]; then
exec sudo "$0" "$@"
fi
rcd="/System/Library/CoreServices/rcd.app/Contents/MacOS/rcd"
@mislav
mislav / setTimeout.js
Last active September 23, 2023 09:51
Overwrite setTimeout so it optionally accepts the delay as 1st argument
(function(){
var _ = window.setTimeout
window.setTimeout = function(delay, fn) {
return (typeof delay == "number") ? _(fn, delay) : _(delay, fn)
}
})()
@mislav
mislav / licenses-api.sh
Created June 25, 2015 06:11
An example of using the GitHub Licenses API, currently in preview.
$ curl -s -H 'Accept: application/vnd.github.drax-preview+json' \
https://api.github.com/orgs/github/repos?per_page=100 | \
grep -A1 '"license"' | grep '"key"' | cut -d'"' -f4 | \
sort | uniq -c
5 apache-2.0
1 bsd-3-clause
2 cc0-1.0
1 gpl-2.0
56 mit
@mislav
mislav / license-audit.sh
Created June 25, 2015 00:41
Simple tool to do rudimentary dependency license auditing using Licensee library.
#!/bin/bash
# Usage: license-audit [<project-dir>]
#
# Scans gems from the current project's bundle, Bower components and npm
# packages, and prints their license.
#
# Requires:
# - licensee >= 4.5.0
# - ruby with Bundler (for Gemfiles)
set -e
@mislav
mislav / rbenv-forks.tsv
Last active December 14, 2016 01:59
List of projects that are forks of rbenv
repo stars created updated authors
yyuu/pyenv 3592 2012-08-31 2015-12-23 @yyuu (136), @joshfriend (41), @makotosasaki (31), @blueyed (30), @jasonkarns (12)
gcuisinier/jenv 904 2013-01-24 2015-12-23 @gcuisinier (56)
CHH/phpenv 426 2011-08-05 2015-04-14 @CHH (54)
riywo/anyenv 368 2013-06-11 2015-12-24 @riywo (14)
tokuhirom/plenv 275 2010-03-20 2015-12-11 @tokuhirom (188)
kylef/swiftenv 211 2015-12-15 2015-12-24 @kylef (67)
riywo/ndenv 143 2013-06-20 2015-10-28 @riywo (6)
mururu/exenv 138 2012-11-10 2015-09-28 @mururu (6)
OiNutter/nodenv 125 2013-03-10 2015-12-04 @jasonkarns (29), @OiNutter (22)