Skip to content

Instantly share code, notes, and snippets.

View mislav's full-sized avatar

Mislav Marohnić mislav

View GitHub Profile
@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)
@mislav
mislav / Gemfile
Last active August 29, 2015 14:18 — forked from janko/benchmark.rb
source "https://rubygems.org"
gem "minitest"
gem "rspec"
@mislav
mislav / labler.js
Last active September 13, 2016 00:25
My simpler alternative to OctoGAS labler; more aggressive caching to avoid Gmail rate limits
/* Scans Gmail inbox for new GitHub notifications and:
*
* - labels threads that @-mention me with "Direct Mention";
* - labels threads for issues/PRs that I've opened with "Direct Mention";
* - labels threads that @-mention my teams with "Team Mention".
*
* To install: visit https://script.google.com/intro to enable Apps Script.
* Then copy this script over, edit the first few regular expressions. You'll
* have to allow Apps Script access to your Gmail. Finally, use the time icon
* in the menubar to create a trigger that will run `processInbox` at scheduled
@mislav
mislav / .gitconfig
Created January 30, 2015 22:06
My pristine git config
[user]
name = Mislav Marohnić
email = [email protected]
[color]
ui = true
[push]
default = simple
@mislav
mislav / fuzzy.coffee
Created January 20, 2015 01:47
Fuzzy scoring algorithm adopted from Selecta as used on GitHub.com
# Get the shortest match (least distance between start and end index) for all
# the query characters in the given text.
#
# Returns an array in format [firstIndex, matchLength, [matchIndexes]]
shortestMatch = (text, queryChars) ->
starts = allIndexesOf(text, queryChars[0])
return if starts.length is 0
return [starts[0], 1, []] if queryChars.length is 1
@mislav
mislav / port-finder.rb
Last active August 29, 2015 14:10
Check if TCPServer's port-finding ability is safe with parallelism via fork
# ruby port-finder.rb | cut -f1 -d: | sort -n | uniq -c
#
# Verdict: it seems to be safe on Mac OS X, but it's *not safe* on Linux,
# where causal testing confirms that two subprocesses could pick the same port.
require 'socket'
module PortFinder
def self.call
server = TCPServer.new('127.0.0.1', 0)
@mislav
mislav / diff-gems.rb
Created October 29, 2014 20:35
Script to diff contents of gems vendored in `vendor/cache` between branches
#!/bin/bash
# Usage: diff-gems <branch>
#
# Shows diff between unpacked cached gems that changed on a branch.
set -e
branch="${1?}"
base_branch="origin/master"
merge_base="$(git merge-base "$base_branch" "$branch")"
@mislav
mislav / arch.md
Last active January 11, 2022 11:33
How to create a base Vagrant box using VirtualBox

Create the partition:

sgdisk --zap-all /dev/sda
cgdisk /dev/sda
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt

Edit the mirror list to bring the preferred mirror to the top:

@mislav
mislav / backfill-releases.sh
Created February 5, 2014 17:37
Script to migrate releases from CHANGELOG.md to GitHub Releases
#!/bin/bash
# Usage: OAUTH_TOKEN="..." backfill-releases CHANGELOG.md [<project-title>]
set -e
log="${1?}"
project_name="${2}"
repo="$(git config remote.origin.url | grep -oE 'github\.com[/:][^/]+/[^/]+' | sed 's/\.git$//' | cut -d/ -f2-3)"
[ -n "${project_name}" ] || project_name="${repo#*/}"
@mislav
mislav / mac-randomize.sh
Last active September 5, 2024 01:46
Randomize MAC address (e.g. unlimited wifi access on airports)
#!/bin/bash
set -e
current_mac() {
ifconfig en0 ether | awk '/ether / { print $2 }'
}
current_mac_wifi() {
networksetup -getmacaddress Wi-Fi | awk '{ print $3 }'
}