Skip to content

Instantly share code, notes, and snippets.

View grough's full-sized avatar

Gavin Rough grough

  • Toronto, Canada
View GitHub Profile
@jakemhiller
jakemhiller / post-checkout
Created May 26, 2016 19:25
git post-checkout hook for npm installing if package.json has changed between branches
#/usr/bin/env bash
changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_run npm-shrinkwrap.json "npm prune && npm install"
# check_run package.json "npm prune && npm install"
@alex7kom
alex7kom / README.md
Last active July 15, 2022 16:15
Steam Donation Bot

Steam Donation Bot

A Steam bot that accepts item donations.

Basically, it accepts any offer that doesn't ask for any items from its inventory.

Feel free to use if you want to accept item donations for your project, or modify it as you see fit.

This bot does not support mobile auth as of yet.

#!/bin/bash
# vim:set ts=4 sw=4 et ai:
# Retrieve SSH public keys from GitHub and install to authorized_keys.
GITHUB_USERS=(USER1 USER2)
INSTALL_FILE=/home/USER/.ssh/authorized_keys
TMP_KEY=/tmp/ssh.key
CURL=/usr/bin/curl
CURLOPTS="--retry 3 --retry-delay 2 --silent --fail -o $TMP_KEY"
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active June 16, 2024 13:44
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@ryantology
ryantology / hipchat-notify.js
Last active December 28, 2015 20:29
MineCraft + HipChat notification though nodejs. This is a quick little snippet that will let people in your hipchat server know that users have joined the minecraft server. Not sure what happens when the log file rotates.
Tail = require('tail').Tail;
tail = new Tail("latest.log");
HipChatClient = require('node-hipchat')
hipchat = new HipChatClient("*************************");
var loginPattern = /.*\[Server thread\/INFO\]: (.*) joined the game/;
tail.on("line", function(data) {
var loginMatch = data.match(loginPattern);
@joates
joates / index.js
Created September 16, 2013 18:56
linspace(a, b, n) from Numeric Javascript by Sébastien Loisel (https://github.com/sloisel/numeric/blob/master/src/numeric.js#L922)
numeric.linspace = function linspace(a,b,n) {
if(typeof n === "undefined") n = Math.max(Math.round(b-a)+1,1);
if(n<2) { return n===1?[a]:[]; }
var i,ret = Array(n);
n--;
for(i=n;i>=0;i--) { ret[i] = (i*b+(n-i)*a)/n; }
return ret;
}
@lelandbatey
lelandbatey / gifConvert.sh
Last active February 5, 2016 09:29
Convert video to .gif really easily. See this commit to my help files as an example: https://github.com/lelandbatey/configDebDev/blob/master/helpFiles.txt#L113
#!/bin/bash
#Alright, so this should automatically convert a given video into a gif called optimized_output.gif
# See here for explanation: https://github.com/lelandbatey/configDebDev/blob/master/helpFiles.txt#L113
ffmpeg -i $1 out%04d.gif # Extracts each frame of the video as a single gif
convert -delay 4 out*.gif anim.gif # Combines all the frames into one very nicely animated gif.
convert -layers Optimize anim.gif optimized_output.gif # Optimizes the gif using imagemagick
# vvvvv Cleans up the leftovers
@ryantology
ryantology / snatch.php
Created August 14, 2012 18:02
Grab embed id for youtube / vimeo videos
<?php if (preg_match('/http:\/\/www.youtube.com\/watch.*/', $this->request->data['Upload']['embed'], $matches)) {
parse_str(parse_url($this->request->data['Upload']['embed'],PHP_URL_QUERY),$vars);
$videoid = $vars['v'];
if (!$videoid) { break; }
$this->request->data['Upload']['type'] = 'youtube';
$this->request->data['Upload']['attribution'] = $videoid;
$videoThumb = $this->_getThumbYoutube($videoid);
}
if (preg_match('/http:\/\/(www\.)?vimeo.com\/(\d+)/', $this->request->data['Upload']['embed'], $matches)) {
$videoid = $matches[2];
@jboner
jboner / latency.txt
Last active June 21, 2024 17:41
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD