Skip to content

Instantly share code, notes, and snippets.

View johnthethird's full-sized avatar

John Lynch johnthethird

View GitHub Profile
# Riak / Ripple code to use a regex to find keys
results = Riak::MapReduce.new(client)
.add("my_bucket")
.map("function(value,keyData,arg) {
var re = new RegExp(arg);
return value.key.match(re) ? [value.key] : [];
}", :keep => true, :arg => "^foo").run
Rails CMS alternatives
======================
Note: project activity was checked on 11/26/09 for most of these projects, and the "last update" field has not been kept up to date since then.
Active projects:
---------------
adva-cms
repo: http://github.com/svenfuchs/adva_cms/
site: http://adva-cms.org/
Last update: 11/24/09
# Tee with Sinatra
# http://rigelgroupllc.com/wp/blog/tee-with-sinatra
# This proxy script will accept HTTP requests meant for Riak
# and in addition to passing them on to Riak will send a duplicate
# request to an ElasticSearch cluster
# -- John Lynch, www.rigelgroupllc.com
#
require 'rubygems'
require 'sinatra'
%% -*- mode: erlang -*-
[
%% Riak config
{riak, [
%% storage_backend specifies the Erlang module defining the storage mechanism
%% that will be used on this node.
%% {storage_backend, riak_dets_backend},
{storage_backend, innostore_riak},
%% Different storage backends can use other configuration variables. For
@johnthethird
johnthethird / http_client_with_cache.coffee
Created September 1, 2010 03:38
HTTPClientWithCache for Titanium in CoffeeScript
###
------> HTTPClientWithCache <------
This class is a wrapper around the standard Titanium.Network.HTTPClient(), but it adds a
few nice features:
* A cache backed by a SQLite database. All HTTPClientWithCache instances use the same database table, with
the primary cache key being a hash of the full URL (and any data parameters in a POST)
* The cache is automatically pruned before each query
* A retry mechanism, so that you can retry a particular query a number of times before failing.
function ensureDigits(e) {
e = e || window.event;
var charCode = parseInt(e.keyCode);
var allowableCodes = [48,49,50,51,52,53,54,55,56,57,68,80,96,97,98,99,100,101,102,103,104,105,110,37,39,13,8,188,190,46,113,114,115,116,117,118,119,120,121,122,123, 67, 86];
$('log').update("Ensure Digits:" + charCode);
if (allowableCodes.indexOf(charCode) === -1) {
e.stop();
}
}
#!/bin/bash
echo "Automated VPS Setup for Ubuntu 10.04 LTS (Lucid) - Rails with Nginx"
echo "-------------------------------------------------------------------"
echo "Set Hostname"
echo "------------"
echo "mail.redecoletiva.com.br" | sudo tee /etc/hostname
@johnthethird
johnthethird / nginx
Created November 25, 2010 20:02
Init script nginx centos default
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@johnthethird
johnthethird / memcached
Created February 2, 2011 00:25
CentOS /etc/init
#! /bin/sh
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached
# pidfile: /var/run/memcached/memcached.pid
# Standard LSB functions
#. /lib/lsb/init-functions
@johnthethird
johnthethird / nginx
Created February 2, 2011 00:47
init script
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid