Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
;; inspired by suggestion in THE doc: http://java.ociweb.com/mark/clojure/article.html | |
(ns bootcamp.multi-method) | |
(defn measure-it [size] | |
(cond | |
(< size 3) :small | |
(< size 6) :medium | |
(< size 12) :large | |
:else :hard-to-measure )) |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
#Graylog2 Upstart
A basic set of Upstart jobs to get Graylog2 up and running quickly. Assumes MongoDB and Graylog2 installed in /opt/
. Tested on Ubuntu Server 10.04 LTS, MongoDB 2.0.0, graylog2-server-0.9.5p1, and graylog2-web-interface-0.9.5p2.
#Usage
Place job definitions in /etc/init/
and then use service [job] [command]
to start/stop/restart/status the services manually. On boot, the services flow into each other, only starting if dependent services have started. For more on controlling jobs or Upstart in general (a replacement for System-V init
), see the cookbook.
#Author
var http = require('http'), | |
request = require('request'), // request module from https://github.com/mikeal/request | |
url = require('url'); | |
http.createServer(function (req, res) { | |
var href = url.parse(req.url,true).href; | |
request('http://127.0.0.1:5984' + href).pipe(res); | |
}).listen(1337); | |
// now try something like http://127.0.0.1:1337/your_db_name/_all_docs/?limit=10 |
var gistPrefix = 'https://gist.github.com/', | |
cachedWrite = document.write, | |
body = $('body'), | |
gists = $('p.gist').map(function(n, p) { | |
p = $(p); | |
var a = $('a', p), | |
href = a.attr('href'); | |
if (a.length && href.indexOf(gistPrefix) == 0) { |
#!/usr/bin/env bash | |
# call like this on the target server: | |
# NODENAME='foo' CHEF_ENV='production' RUNLIST='["role[foo]","recipe[bar]"]' CHEFREPO='[email protected]:repo.git' bash <( curl -L https://raw.github.com/gist/1026628 ) | |
# You will need to ensure that the ssh key is already set up on the server. | |
set -e | |
export CHEF_DIR="${HOME}/chef" | |
sudo rm -rf $CHEF_DIR | |
mkdir -p "$CHEF_DIR" |
# This is a nginx config snippet showing how to inherit an http header | |
# or defaulting it to a specific value. This is useful because it allows | |
# upstream load balancers to set specific headers, but if they're missing | |
# the app LB will know how to default it. | |
# This will inherit the previously set X-Scheme variable, or otherwise | |
# default it to the current `$scheme`. Requires nginx 0.9.0+. | |
# | |
# Docs: http://wiki.nginx.org/HttpMapModule#map | |
map $http_x_scheme $x_scheme { |
Copyright (c) 2011 Simon Walker
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Implementation of the Luhn 10 algorithm to check validity of credit card numbers. See http://en.wikipedia.org/wiki/Luhn_algorithm for details on the algorithm.
var validCreditCard = function(a,b,c,d,e){for(d=+a[b=a.length-1],e=0;b--;)c=+a[b],d+=++e%2?2*c%10+(c>4):c;return!(d%10)};
validCreditCard('378282246310005'); //=> true
validCreditCard('378282246310006'); //=> false
// some numbers to test with
// 378282246310005 371449635398431 378734493671000
class Stub(object): | |
def __init__(self, **kwargs): | |
for key in kwargs: | |
setattr(self, key, kwargs[key]) |