Skip to content

Instantly share code, notes, and snippets.

View marfarma's full-sized avatar

Pauli Price marfarma

View GitHub Profile
@matthutchinson
matthutchinson / fakeout.rake
Created February 10, 2010 16:49
fakeout.rake - a simple/configurable rake task that generates some random fake data for the app (using faker) at various sizes
# a simple/configurable rake task that generates some random fake data for the app (using faker) at various sizes
# NOTE: requires the faker or ffaker gem
# sudo gem install faker - http://faker.rubyforge.org
# OR
# sudo gem install ffaker - http://github.com/EmmanuelOga/ffaker
require 'faker'
class Fakeout
@lizconlan
lizconlan / CouchDB security - prevent non-admins from editing
Created July 26, 2010 12:37
CouchDB security - prevent non-admins from editing
function(newDoc, oldDoc, userCtx) {
if (userCtx.roles.indexOf('_admin') !== -1) {
return;
} else {
throw({forbidden: 'Only admins may edit the database'});
}
}
@shapeshed
shapeshed / monit.conf
Created November 12, 2010 10:21
Upstart script for monit on Ubuntu 10.04
# This is an event.d (upstart) script to keep monit running.
# To install disable the old way of doing things:
#
# /etc/init.d/monit stop && update-rc.d -f monit remove
#
# then put this script here:
#
# /etc/init/monit.conf
#
# and reload upstart configuration:
@briancavalier
briancavalier / simple-promise-retry.js
Created February 24, 2011 18:35
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@chrislwade
chrislwade / redcar-wrapper.bash
Created March 21, 2011 04:40
This function wraps the Redcar launcher to set different options based on the current directory. I use this to detect when I'm working on Redcar itself or a plugin for Redcar and launching with debug log output redirected to STDOUT. Otherwise I launch
function redcar {
if [ -f plugin.rb ]; then
echo "Found 'plugin.rb'!"
echo "Assuming this directory is a Redcar plugin."
echo "Running with --show-log, --log-level=debug, and without --fork."
wrapped_redcar --show-log --log-level=debug $*
elif [ -f lib/redcar.rb ] && [ -f bin/redcar ]; then
echo "Found 'lib/redcar.rb' and 'bin/redcar'!"
echo "Assuming this is the Redcar application directory."
echo "Running with --show-log, --log-level=debug, and without --fork."
@tomislav
tomislav / deploy.rb
Created July 13, 2011 13:12
Capistrano recipe for Wordpress
default_run_options[:pty] = true
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
require 'capistrano'
require 'rubygems'
require 'railsless-deploy'
set :application, "vault42.org"
set :deploy_to, "/usr/local/www/#{application}"
set :backup_dir, "/home/tomislav/backup"
set :use_sudo, false
@richardvenneman
richardvenneman / _html5boilerplate.css.sass
Created September 25, 2011 16:18
HTML5 Boilerplate HAML & SASS
/*
* HTML5 ✰ Boilerplate
*
* What follows is the result of much research on cross-browser styling.
* Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
* Kroc Camen, and the H5BP dev community and team.
*
* Detailed information about this CSS: h5bp.com/css
*
* ==|== normalize ==========================================================
@Raynos
Raynos / weak-map.js
Last active September 18, 2019 07:49 — forked from Gozala/weak-map.js
Harmony WeakMap shim for ES5
// Original - @Gozola. This is a reimplemented version (with a few bug fixes).
window.WeakMap = window.WeakMap || (function () {
var privates = Name()
return {
get: function (key, fallback) {
var store = privates(key)
return store.hasOwnProperty("value") ?
store.value : fallback
},
@g3d
g3d / gist:2709563
Last active February 7, 2024 15:21 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan
@timyates
timyates / rdp.coffee
Created June 8, 2012 11:03 — forked from rhyolight/rdp.js
Ramer-Douglas-Peucker line filtering algorithm in JavaScript
findPerpendicularDistance = ( point, line ) ->
[pointX,pointY] = point[0..1]
lineStart = x: line[0][0], y: line[0][1]
lineEnd = x: line[1][0], y: line[1][1]
slope = ( lineEnd.y - lineStart.y ) / ( lineEnd.x - lineStart.x )
intercept = lineStart.y - ( slope * lineStart.x )
Math.abs( slope * pointX - pointY + intercept ) / Math.sqrt( Math.pow( slope, 2) + 1)
douglasPeucker = ( points, epsilon ) ->
maxIndex = maxDistance = 0