Skip to content

Instantly share code, notes, and snippets.

View johnthethird's full-sized avatar

John Lynch johnthethird

View GitHub Profile
@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
#!/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
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();
}
}
@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.
%% -*- 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
# 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'
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
# 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
#!/bin/bash
# ubuntu @ ec2 (canonical official ubuntu-images-us - I grabbed 64bit)
# then login as 'ubuntu' & start working - however this should be reproducable
# anywhere you have tip riak installed...
sudo perl -p -i -e 's/universe$/universe multiverse/g' /etc/apt/sources.list
sudo apt-get update
sudo apt-get upgrade -y
# This patch to the Ripple gem will properly escape key names with slashes and + signs
# in them. Nice for trying to store a file directory structure in Riak.
module Riak
class Client
class HTTPBackend
def path(*segments)
query = segments.extract_options!.to_param
uri = root_uri.merge(URI.escape(segments.join("/").gsub(/\/+/, "/").sub(/^\//, ''))).tap do |u|
u.query = query if query.present?
end