Skip to content

Instantly share code, notes, and snippets.

@iangreenleaf
iangreenleaf / rsync-retry.sh
Created January 18, 2010 07:12
rsync with retries
#!/bin/bash
### ABOUT
### Runs rsync, retrying on errors up to a maximum number of tries.
### Simply edit the rsync line in the script to whatever parameters you need.
# Trap interrupts and exit instead of continuing the loop
trap "echo Exited!; exit;" SIGINT SIGTERM
MAX_RETRIES=50
@iangreenleaf
iangreenleaf / yaml.vim
Created March 15, 2011 17:38
Dumb-smart indentation for Yaml
" Vim indent file
" Language: Yaml
" Author: Ian Young
" Get it bundled for pathogen: https://github.com/avakhov/vim-yaml
if exists("b:did_indent")
finish
endif
"runtime! indent/ruby.vim
"unlet! b:did_indent
@iangreenleaf
iangreenleaf / lychee_tag.rb
Last active April 7, 2021 04:48 — forked from tobru/lychee_tag.rb
A Liquid tag for Jekyll sites that allows embedding Lychee albums. See https://tobrunet.ch/articles/jekyll-meets-lychee-a-liquid-tag-plugin/
# Connects Jekyll with Lychee (http://lychee.electerious.com/)
#
# # Features
#
# * Generate album overview and link to image
# * Caching of JSON data
#
# # Usage
#
# {% lychee_album <album_id> %}
@iangreenleaf
iangreenleaf / shotwell_metadata_fix.sh
Last active January 8, 2019 17:41
Shotwell RAW metadata migrator - rescue your data from Shotwell
#!/bin/bash
# Shotwell RAW metadata migrator
#
# This software is provided WITHOUT WARRANTY OF ANY KIND
#
# Shotwell doesn't write metadata to RAW files. This was a problem when I wished to migrate all my data out of Shotwell.
# This script pulls data out of Shotwell's database and writes it to the files using exiftool.
# This is not elegant, performant, or well-tested. However, it seems to get the job done!
#
@iangreenleaf
iangreenleaf / Gemfile
Last active January 25, 2018 17:49
Usage example of the Bundler plugin I built for testing with JSON fixtures
source "test/fixtures/my_rubygems_fixture", type: "json_fixture" do
gem "whatever"
gem "foobar", "~> 1.0.1"
end
#
#= dump database to yaml for fixtures
#
# originated by elm200 <http://d.hatena.ne.jp/elm200/20070928/1190947947>
#
#== install
#
# move this file to RAILS_ROOT/lib/tasks/extract_fixtures.rake
#
namespace :db do
Here are the version numbers available for Handlebars.js
+--------------+------------------+------------------+--------------+
| npm versions | Official website | GitHub downloads | Git tags |
+--------------+------------------+------------------+--------------+
| 1.0.2beta | 1.0.0-rc.3 | 0.9.0.pre.2 | 0.9.0.pre.4 |
| 1.0.4beta | | 0.9.0.pre.3 | 1.0.0.beta.1 |
| 1.0.5beta | | 0.9.0.pre.4 | 1.0.0-rc.3 |
| 1.0.6 | | 0.9.0.pre.5 | 1.0.rc.1 |
| 1.0.6-2 | | 0.9.0.pre.js | 1.0.rc.2 |
@iangreenleaf
iangreenleaf / Makefile
Last active December 15, 2015 10:58
Ruby-style mixins in JavaScript.
test:
for f in test-*.coffee; do coffee "$$f"; done
.PHONY: test
@iangreenleaf
iangreenleaf / a_b_helper.rb
Created November 27, 2012 19:59
Helper to provide alternate configuration syntax for Split, the A/B testing tool.
module ABHelper
def split_test(name)
experiment = YAML.load_file("config/experiments.yml")[name]
given_probability, num_with_probability = experiment[:variants].inject([0,0]) do |a,v|
p, n = a
if v.kind_of?(Hash) && v[:percent]
[p + v[:percent], n + 1]
else
a
def with_var(variable, value, &block)
old_value = eval variable
eval "#{variable} = #{value.inspect}"
ret = block.call
eval "#{variable} = #{old_value.inspect}"
ret
end
# Usage
# =====