Skip to content

Instantly share code, notes, and snippets.

View tadman's full-sized avatar
🤔
Enumerating

Scott Tadman tadman

🤔
Enumerating
View GitHub Profile
twttr.BANNED_PASSWORDS = ["111111","11111111","112233","121212","123123","123456","1234567","12345678","131313","232323","654321","666666","696969","777777","7777777","8675309","987654","aaaaaa","abc123","abc123","abcdef","abgrtyu","access","access14","action","albert","alexis","amanda","amateur","andrea","andrew","angela","angels","animal","anthony","apollo","apples","arsenal","arthur","asdfgh","asdfgh","ashley","asshole","august","austin","badboy","bailey","banana","barney","baseball","batman","beaver","beavis","bigcock","bigdaddy","bigdick","bigdog","bigtits","birdie","bitches","biteme","blazer","blonde","blondes","blowjob","blowme","bond007","bonnie","booboo","booger","boomer","boston","brandon","brandy","braves","brazil","bronco","broncos","bulldog","buster","butter","butthead","calvin","camaro","cameron","canada","captain","carlos","carter","casper","charles","charlie","cheese","chelsea","chester","chicago","chicken","cocacola","coffee","college","compaq","computer","cookie","cooper","corvette","cowbo
# This relates to the issue described at:
# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4709
class String
def %(args)
if args.kind_of?(Hash)
dup.gsub(INTERPOLATION_PATTERN_WITH_ESCAPE) do |match|
if match == '%%'
'%'
else
class Test::Unit::TestCase
alias_method :run_without_transaction, :run
def run(result)
exception = nil
Sequel::Model.db.transaction do
begin
run_without_transaction(result)
rescue => exception
# Capture exception, if raised
#!/bin/sh
MYSQL_USER=root
MYSQL_PASSWORD=<PASSWORD>
MYSQL_OPTS=
RETAIN_PERIOD=5
DUMP_DIRECTORY="$HOME/dumps"
@tadman
tadman / monkeypatch.rb
Created April 15, 2011 20:03
FreeTDS Configuration Monkeypatch
module ActiveRecord
class Base
def self.sqlserver_connection(config) #:nodoc:
config = config.dup.symbolize_keys!
config.reverse_merge! :mode => :dblib, :host => 'localhost', :username => 'sa', :password => ''
mode = config[:mode].to_s.downcase.underscore.to_sym
case mode
when :dblib
# <monkeypatch>
# raise ArgumentError, 'Missing :dataserver configuration.' unless config.has_key?(:dataserver)
@tadman
tadman / rubygems-warning.patch
Created May 11, 2011 04:28
Rubygems 1.8.1 Deprecate Warning Patch
diff --git a/Manifest.txt b/Manifest.txt
index 6e79ebd..6a2f480 100644
--- a/Manifest.txt
+++ b/Manifest.txt
@@ -121,6 +121,7 @@ test/rubygems/rubygems_plugin.rb
test/rubygems/sff/discover.rb
test/rubygems/simple_gem.rb
test/rubygems/test_config.rb
+test/rubygems/test_deprecate.rb
test/rubygems/test_gem.rb
#!/usr/bin/env ruby
require 'benchmark'
LETTERS = ('a'..'z').to_a.freeze
def random_customer_name
name = [ ]
(rand(10) + 1).times do
@tadman
tadman / hstore.js
Last active December 18, 2015 11:38
module.exports = {
stringifyPart: function(part) {
switch(typeof part) {
case 'boolean':
case 'number':
return String(part)
case 'string':
return '"' + part.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"'
case 'undefined':
return 'NULL'
#!/usr/bin/env ruby
require 'benchmark'
count = 10e6.to_i
Benchmark.bm do |x|
x.report(:mod) { count.times { |n| n % 2 == 0 } }
x.report(:and) { count.times { |n| n & 1 == 0 } }
x.report(:odd) { count.times { |n| n.even? } }

Please, before you write any more SQL interfacing code, you must read up on proper SQL escaping to avoid severe SQL injection bugs like the ones you have here. Also, mysql_query should not be used in new applications. It's a deprecated interface that's being removed from future versions of PHP. A modern replacement like PDO is not hard to learn and is a safer way to compose queries. $_POST data never goes directly in a query.