Skip to content

Instantly share code, notes, and snippets.

View javmorin's full-sized avatar

Mike Javorski javmorin

View GitHub Profile
require 'rack'
# Released under MIT license, see tests / example.ru for usage
module Rack
class APIVersionMapper
ERROR_TEXT = '<html><head><title>Unknown API Version</title></head><body>Unknown API Version v%s</body></html>'.freeze
EMPTY_RESPONSE = [404, {'Content-Type' => 'text/html', 'Content-Length' => '0'}, ['']].freeze
VERSION_ENV_KEY = 'x-rack.api_mapper.version'.freeze
QUERY_STRING = "QUERY_STRING".freeze
@tmm1
tmm1 / gist:329682
Created March 11, 2010 21:31
EM Chat Server Demo
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
class String
def bold
"\033[1m#{self}\033[0m"
end
end
!function() {
var doc = document,
htm = doc.documentElement,
lct = null, // last click target
nearest = function(elm, tag) {
while (elm && elm.nodeName != tag) {
elm = elm.parentNode;
}
return elm;
};
@mdub
mdub / chef-bootstrap.rb
Created October 29, 2010 01:08
bootstrap a remote machine as a Chef server/client
#!/usr/bin/env ruby
require "rubygems"
require "erb"
require "fileutils"
require "json"
require "net/ssh"
require "net/scp"
require "optparse"
@mpasternacki
mpasternacki / update_dns.rake
Created February 1, 2011 13:36
Rake task to update Amazon Route53 DNS from by Chef node search
# -*- ruby -*-
# Needs following parameters configured in rake.rb:
# DNS_DOMAIN: domain for which to set entries, including trailing dot
# (e.g. "example.com.")
# DNS_ATTRIBUTE: attribute containing hostname to CNAME to, defaults
# to 'fqdn'; for EC2, use "ec2.public_hostname"
# DNS_ENTRIES: hash mapping hostname to node search query,
# e.g. {'buildbot' => 'recipes:buildbot', 'monitoring' =>
# 'roles:monitoring'}
@kcbraunschweig
kcbraunschweig / chef-api-ha
Created July 22, 2011 01:41
chef and unicorn and nginx
Just to get you started.
https://github.com/blog/517-unicorn
http://unicorn.bogomips.org/index.html
http://wiki.nginx.org/Configuration
http://blog.tomkersten.com/2010/11/14/nginx-unicorn-rvm-server-setup.html
http://nginx.org/en/docs/http/configuring_https_servers.html
http://nginx.org/en/docs/http/request_processing.html
https://github.com/merb/merb/wiki/HOWTO-Use-Unicorn
@octplane
octplane / check_mongo_replica_member.rb
Created August 31, 2011 08:32
MongoDb Replica Nagios and Munin checks
#!/usr/bin/env ruby
# Copyright (c) 2011 Fotonauts
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
@jcf
jcf / email_validator.rb
Created September 2, 2011 10:48 — forked from stauntonknight/email_validator.rb
Rails 3 Email Validator
require 'mail'
class EmailValidator < ActiveModel::EachValidator
attr_reader :record, :attribute, :value, :email, :tree
def validate_each(record, attribute, value)
@record, @attribute, @value = record, attribute, value
@email = Mail::Address.new(value)
@tree = email.__send__(:tree)
@miketheman
miketheman / set_environment.rb
Created December 29, 2011 16:12 — forked from nstielau/set_environment.rb
A Knife plugin to set node environment
## Knife plugin to set node environment
# See http://wiki.opscode.com/display/chef/Environments
#
## Install
# Place in .chef/plugins/knife/set_environment.rb
#
## Usage
# Nick-Stielaus-MacBook-Pro:chef-repo nstielau$ knife node set_environment mynode.net my_env
# Looking for mynode.net
# Setting environment to my_env
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.