Skip to content

Instantly share code, notes, and snippets.

if Rails.version == '2.3.8' && Gem.available?('mongrel', Gem::Requirement.new('~>1.1.5')) && self.class.const_defined?(:Mongrel)
# Pulled right from latest rack. Old looked like this in 1.1.0 version.
#
# def [](k)
# super(@names[k] ||= @names[k.downcase])
# end
#
module Rack
# Unused Variable Checker
#
# Usage: ruby varcheck.rb test-src.rb
#
#
module VarCheck
class InstSeqTree
Headers = %w(magic major_version minor_version format_type
misc name filename filepath line type locals args
exception_table)
@mala
mala / memcachedos.pl
Created August 13, 2010 11:49
DoS for memcached
#!/usr/local/bin/perl
# DoS tool for memcached
# ulimit -n 15000; perl memcachedos.pl 127.0.0.1 11211 3
# original: http://gist.github.com/522741
# This is Public Domain Software
use strict;
use warnings;
use AnyEvent;
# Our own variable where we deploy this app to
deploy_to = "/srv/example.com"
current_path = "#{deploy_to}/current"
shared_path = "#{deploy_to}/shared"
shared_bundler_gems_path = "#{shared_path}/bundler_gems"
# See http://unicorn.bogomips.org/Sandbox.html
# Helps ensure the correct unicorn_rails is used when upgrading with USR2
Unicorn::HttpServer::START_CTX[0] = "#{shared_bundler_gems_path}/bin/unicorn_rails"
@mislav
mislav / sessions_patch.rb
Created September 8, 2010 13:56
Sessions fix for Rails 2.3.9 apps
# patch for Rails 2.3.9 (ticket #5581)
# (drop in your config/initializers/ dir)
affected = %w[ActiveRecord::SessionStore ActionController::Session::MemCacheStore]
target = Rails.configuration.middleware.detect do |mid|
mid.klass.is_a? Class and affected.include? mid.klass.to_s
end
if target
class RailsCookieMonster
@gravis
gravis / readme
Created September 26, 2010 17:26
tcp syslog logger for rails draft
tcp_syslog is now a gem :
https://github.com/tech-angels/tcp_syslog
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@Craftworks
Craftworks / mymemcheck
Created December 8, 2010 15:14
MySQL memory configuration check tool
#!/usr/bin/env perl
use strict;
use warnings;
my @GLOBAL_BUFFERS = qw(
key_buffer_size
innodb_buffer_pool_size
innodb_log_buffer_size
innodb_additional_mem_pool_size
@kawaguchi
kawaguchi / flymake-growl.el
Created December 25, 2010 15:45
FlymakeのエラーメッセージをGrowlで通知する
(require 'flymake)
(setq flymake-growl-warning-priority 1)
(setq flymake-growl-error-priority 2)
(setq flymake-growl-warning-sticky t)
(setq flymake-growl-error-sticky t)
(setq flymake-growl-sticky-list nil)
@masayoshi
masayoshi / spec_helper.rb
Created March 21, 2011 04:39
spec_helper for rspec, spork and guard
# -*- coding: utf-8 -*-
require 'rubygems'
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)