Skip to content

Instantly share code, notes, and snippets.

View raine's full-sized avatar

Raine Virta raine

View GitHub Profile
@raine
raine / README.md
Created February 18, 2015 12:57
git alias for removing merged branches
git config --global alias.remove-merged-branches '!git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'
```sh
#!/usr/bin/env ruby
#
# NIEC BENCHMARKER:
#
# == Usage
#
# 1. Create a ruby source file containing methods with arbitrary names.
# Those are the methods that will be benchmarked.
# For example, contents of my-benchmarks.rb:
#
const cachedReadFile = (function() {
const cache = new Map();
return (p) => {
if (cache.has(p)) return Promise.resolve(cache.get(p));
else return readFile(p).tap((file) => cache.set(p, file));
}
}());
@chriseppstein
chriseppstein / dry_inner_content_using_capture.haml
Created May 23, 2011 19:07
This gist shows some approaches for using haml without repeating inner content
- content_for(:inner_content) do
= render :partial => "inner_content"
- if some_condition
%outertag1= yield :inner_content
- else
%outertag2= yield :inner_content
#!/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
@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; }; _"
@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/.

Install

npm install funcoffee

Require

require('funcoffee').expose global
@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
@fritzy
fritzy / pushmaxlist.lua
Last active April 19, 2017 21:07
Appending to a Redis List, deleting entries to the left past a maximum size.
--EVAL "this script" 1 key_name new_item max_size
local key = KEYS[1];
local item, max = unpack(ARGV);
redis.call('RPUSH', key, item);
redis.call('LTRIM', key, -max, -1);