Skip to content

Instantly share code, notes, and snippets.

# encoding: UTF-8
require 'rubygems'
require 'bundler/setup'
require 'active_support/inflector'
require 'iconv'
puts %[
This is why String#encode does not replace Iconv, and neither
does ActiveSupport::Inflector#transliterate:
require 'yaml'
case RUBY_VERSION[0,3]
when "1.9"
YAML::ENGINE.yamler = 'syck'
yaml_engine = YAML::ENGINE.yamler
when "1.8"
yaml_engine = 'syck'
end
@bradland
bradland / probe-redacted.txt
Created January 11, 2013 17:39
Rails vuln probe
Started POST "/" for 74.219.112.36 at 2013-01-11 12:19:49 -0500
Processing by HomeController#show as HTML
Parameters: {"probe"=>"\nhello\n"}
WARNING: Can't verify CSRF token authenticity
'tNP0fR/248lmaZccj/WleU2JCvcd1ctijY4LEgIwJ6s=' does not match: '' or ''
User ID:
CSRF Token: wzLcrQko1DJyQ+gh5gCTYGXRs0uNRuUUqvQyADf+Ejs=
Redirected to http://<server_ip>/login
Completed 302 Found in 2ms (ActiveRecord: 0.0ms)
Started POST "/" for 74.219.112.36 at 2013-01-11 12:19:50 -0500
@bradland
bradland / proctagbench.rb
Last active December 10, 2015 12:59
Benchmark two types of log tags
#!/usr/bin/env ruby
require 'benchmark'
require 'date'
require 'securerandom'
Benchmark.bm(15) do|b|
ITERATE = 100_000
timestamp = Proc.new {Time.now.strftime('%Y-%m-%d %H:%M:%S.%L')}
b.report("proc time call") do
@bradland
bradland / data_validations.rb
Last active November 11, 2022 17:01
Data validations with axlsx gem
#!/usr/bin/env ruby -w -s
# -*- coding: utf-8 -*-
require 'axlsx'
## Some documentation ##
### Axlsx Gem ###
# Axlsx Docs: http://rubydoc.info/gems/axlsx/frames
# Axlsx::DataValidation: http://rubydoc.info/gems/axlsx/Axlsx/DataValidation
@bradland
bradland / fizzbuzz-fail.rb
Created December 3, 2012 21:20
FizzBuzz fails
# Write a program that prints the numbers from 1 to 100. But for multiples of
# three print “Fizz” instead of the number and for the multiples of five print
# “Buzz”. For numbers which are multiples of both three and five print
# “FizzBuzz”.
(1..100).each do |i|
f = "Fizz" if i % 3 == 0 # should we print fizz?
b = "Buzz" if i % 5 == 0 # should we print buzz?
if f||b # if fizz or buzz...
@bradland
bradland / fizzbuzz.rb
Created December 3, 2012 21:12
FizzBuzz
# Write a program that prints the numbers from 1 to 100. But for multiples of
# three print “Fizz” instead of the number and for the multiples of five print
# “Buzz”. For numbers which are multiples of both three and five print
# “FizzBuzz”.
(1..100).each do |i|
f = "Fizz" if i % 3 == 0
b = "Buzz" if i % 5 == 0
if f||b
@bradland
bradland / MacBook Air Sleep Study.md
Created September 11, 2012 16:43
MacBook Air sleep study

Testing results

Equipment details

Computer (from About This Mac)

MacBook Air
11-inch, Mid 2011

Core i5

module MyApps
# The MyApps module illustrates a common
# The first app class includes a call to Signal::trap
class App1
def initialize
@pid = Process.pid
end
# UFW commands issued
ufw default deny
ufw allow 22
ufw allow 10000
ufw allow 3306 from IP_REDACTED
ufw limit ssh/tcp
uwf logging on
ufw enable