Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / data_validations.rb
Last active June 7, 2024 03:56
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 / 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 / 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
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
# 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:
@bradland
bradland / free.sh
Created February 25, 2013 21:27
Outputs memory stats on the command line for OS X. Similar to (but way different than) free on Linux.
#!/usr/bin/python
# Credit to drfrogsplat from here:
# http://apple.stackexchange.com/questions/4286/is-there-a-mac-os-x-terminal-version-of-the-free-command-in-linux-systems
import subprocess
import re
# Get process info
ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0]

BrainHoney Technical Solution Outline

Goal

Provide customers with a solution that can run on their own servers without the requirement for an active internet connection.

Solution Strategy

BrainHoney will host both the content and assessments for ERR items, eliminating the need for ERR to run on customer's equipment.

@bradland
bradland / install-tabula.sh
Last active December 16, 2015 02:09
Install script for Tabula
# Tabula installer for Ubuntu 12.10
# This script will build a working install of Tabula in your cwd. I run this
# entire script as root because of the number of software installs. If you're
# not comfortable with that, you're probably able to figure out how to do this
# as a regular user.
# These scripts prefer apt packages that are available by default under Ubuntu
# 12.10, but will fall back to using source distributions where packages are not
# available in the default Ubuntu repositories.