This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I stole this code from em-mysql (tmm1 <3) | |
module Sequel | |
class Database | |
attr_accessor :_async | |
end | |
class Dataset | |
def async_insert *args, &cb | |
db._async.insert insert_sql(*args), &cb | |
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Temporary middleware for your APIs to immediately support a /v1/some/path.json prefix to | |
# all route calls. | |
# | |
# When you decide to freeze a current API and provide a /v2/ route then | |
# you will cease using this middleware and implement /v1/ and /v2/ routing as appropriate | |
# to your app. | |
# | |
# This middleware provides a placeholder until then so users can be told to use /v1/some/path routes | |
# immediately. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
# | |
# RefererControl is a Rack middleware app which restricts access to paths | |
# based on the Referer header. Using RefererControl you can make sure | |
# users follow the intended flow of a website. If a controlled path is | |
# visited with an unacceptable Referer URI, then a simple 307 Redirect | |
# response is returned. | |
# | |
# RefererControl should also make Cross Site Request Forgery (CSRF) a | |
# little more difficult to exploit; but not impossible using JavaScript. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ipaddr' | |
module Rack | |
# | |
# BanHammer is a Rack middleware app that restricts access to your server | |
# using a black-list of IPv4/IPv6 addresses and ranges. | |
# | |
# MIT License - Hal Brodigan (postmodern.mod3 at gmail.com) | |
# | |
class BanHammer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env jruby | |
# | |
# | |
require 'rubygems' | |
require 'spoon' | |
EXEC = '/tmp/exec.rb' | |
PID_PATH = '/tmp/exec.pid' | |
WORK_PATH = '/tmp/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This all assumes you have the process running in | |
# a terminal screen and you're on Linux-like system. | |
# First off, suspend the process and background it | |
ctrl-z # suspend the process | |
bg # restart/continue the process in the background | |
# Now create files to log to. They can be called anything, | |
# Personally I would end the in .log. E.g. could be | |
# /var/logs/myprocess-stdout.log, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include_recipe "postgresql::server90" | |
# inspiration from | |
# https://gist.github.com/637579 | |
execute "create-root-user" do | |
code = <<-EOH | |
psql -U postgres -c "select * from pg_user where usename='root'" | grep -c root | |
EOH | |
command "createuser -U postgres -s root" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# List all keys stored in memcache. | |
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place. | |
require 'net/telnet' | |
headings = %w(id expires bytes cache_key) | |
rows = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Prepare ################################################################### | |
# Remove RVM | |
rvm implode | |
# Ensure your homebrew is working properly and up to date | |
brew doctor | |
brew update | |
## Install ################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations) | |
# By Peter Cooper | |
# | |
# MIT license | |
# | |
# * Not advised to use in your production environment! ;-) | |
# * Requires Ruby 1.9 | |
# * Supports A and CNAME records | |
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance | |
# * All records get the same TTL |
OlderNewer