Skip to content

Instantly share code, notes, and snippets.

View raine's full-sized avatar

Raine Virta raine

View GitHub Profile
@somebox
somebox / redis-graphite.sh
Last active July 18, 2016 00:37
graphite-redis : monitor redis statistics with graphite across several hosts
#!/usr/bin/env ruby
require 'socket'
# This script runs every minute, captures stats about redis
# and forwards them to graphite as counter values.
# Graphite/carbon settings
GRAPHITE_HOST="graphite.intra.local.ch"
GRAPHITE_PORT=8125
@raine
raine / README.md
Last active December 22, 2015 02:39

Dropbox deploy script

Useful when working with static web pages.

Put this in the directory you're working in and running the script will copy the directory under ~/Dropbox/Public.

Accepts an optional argument that overrides the name of the directory when copied to Public/.

@egonSchiele
egonSchiele / reader.hs
Created June 10, 2013 20:51
Reader monad example
import Control.Monad.Reader
hello :: Reader String String
hello = do
name <- ask
return ("hello, " ++ name ++ "!")
bye :: Reader String String
bye = do
name <- ask
@raine
raine / .gitconfig
Last active December 17, 2015 16:09
A git alias for fixing (or "amending") an earlier commit in the history.
; 1. Stage the changes you want to have amended to the earlier commit
; 2. `$ git fix <revision>` (e.g. `git fix HEAD~4`or `git fix bbfba98`)
[alias]
fix = "!_() { c=$(git rev-parse $1) && git commit --fixup $c && if grep -qv \"No local changes\" <<<$(git stash); then s=1; fi; git -c core.editor=cat rebase -i --autosquash $c~; if [[ -n "$s" ]]; then git stash pop; fi; }; _"
BIN = ./node_modules/.bin
SRC = $(wildcard src/*.coffee)
LIB = $(SRC:src/%.coffee=lib/%.js)
build: $(LIB)
lib/%.js: src/%.coffee
@mkdir -p $(@D)
@$(BIN)/coffee -bcp $< > $@
@seejohnrun
seejohnrun / random_k.js
Last active October 9, 2018 22:40
Select (n) random elements from a weighted set randomly
// ported from:
http://stackoverflow.com/questions/2140787/select-random-k-elements-from-a-list-whose-elements-have-weights
// each node in the heap has a value, weight, and totalWeight
// the totalWeight is the weight of the node plus any children
var Node = {};
var newNode = function (value, weight, totalWeight) {
var node = Object.create(Node);
node.value = value;
node.weight = weight;
@lmullen
lmullen / .slate
Created February 8, 2013 04:19
My configuration file for the Slate window manager
# GLOBAL CONFIGURATIONS
# -------------------------------------------------------------------
# See https://github.com/jigish/slate/wiki/Global-Configs
config defaultToCurrentScreen true
config secondsBeforeRepeat 0.4
config secondsBetweenRepeat 0.1
config keyboardLayout "qwerty"
config nudgePercentOf screenSize
config resizePercentOf screenSize
@callumj
callumj / README.md
Created November 18, 2012 10:30
Use rtmpdump and ffmpeg to download BBC Radio 1 shows

This script will use the tools rtmpdump and ffmpeg to download and convert a BBC Radio 1 show into a m4a file.

It is capable of either downloading a show direct, or finding the latest show from a webpage.

Requirements

  • nokogiri (Ruby gem)
  • rtmpdump (binary)
  • ffmpeg (binary)
#!/bin/bash
set -x verbose #echo on
coffee --bare -c */**.coffee
rsync --delete-excluded \
--exclude '.git*' \
--exclude 'deploy.sh' \
--exclude '*.coffee' \
-va $(pwd) ~/Dropbox/Public
@scttnlsn
scttnlsn / README.md
Created July 30, 2012 22:16
Pub/sub with MongoDB and Node.js

Pub/sub with MongoDB and Node.js

Setup:

$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})