Skip to content

Instantly share code, notes, and snippets.

View fuzzmonkey's full-sized avatar

George Sheppard fuzzmonkey

View GitHub Profile
@fuzzmonkey
fuzzmonkey / ar_table_information.rb
Created November 14, 2012 18:04
ActiveRecord extract database table information
require 'active_record'
ActiveRecord::Base.establish_connection(
:host => "localhost",
:user => "your_user",
:adapter => "mysql2",
:database => "your_database"
)
ActiveRecord::Base.connection.tables.each do |table_name|
@fuzzmonkey
fuzzmonkey / glitchr_info
Created November 27, 2012 22:46
glitchr_
̥ ̥̥ ̥̥̥ ̥̥̥̥ ̥̥̥̥̥ ̥̥̥̥̥̥̥̊̊̊̊̊̊̊̊̊̊̊ ̥̥̥̥̥̥̥̥̊̊̊̊̊̊̊̊̊̊̊ ̥̥̥̥̥̥̥̥̥̊̊̊̊̊̊̊̊̊̊̊ ̥̥̥̥̥̥̥̥̊̊̊̊̊̊̊̊̊̊̊ ̥̥̥̥̥̥̥̊̊̊̊̊̊̊̊̊̊̊ ̥̥̥̥̥ ̥̥̥̥ ̥̥̥ ̥̥ ̥
If we take a look at the actual characters of the above string
str.split(//).map(&:ord).to_s
=> [10, 805, 32, 805, 805, 32, 805, 805, 805, 32, 805, 805, 805, 805, 32, 805, 805, 805, 805, 805, 32, 805, 805, 805, 805, 805, 805, 805, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 32, 805, 805, 805, 805, 805, 805, 805, 805, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 32, 805, 805, 805, 805, 805, 805, 805, 805, 805, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 32, 805, 805, 805, 805, 805, 805, 805, 805, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 32, 805, 805, 805, 805, 805, 805, 805, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, 32, 805, 805, 805, 805, 805, 32, 805, 805, 805, 805, 32, 805, 805, 805, 32, 805, 805, 32, 805, 10]
Looking at the bulk ok this string, character 805, this appear
@fuzzmonkey
fuzzmonkey / railscheck.rb
Last active December 13, 2015 16:58 — forked from andrew/railscheck.rb
## Gem Upgrade check
#
# Check your github repos for out of date gems
#
# usage: $ USERNAME=yourusername PASSWORD=yourpassword GEM=gemname VERSIONS=1.1,1.2,1.3 ruby railscheck.rb
# or
# usage: $ USERNAME=yourusername PASSWORD=yourpassword ORG=yourorgname GEM=gemname VERSIONS=1.1,1.2,1.3 ruby railscheck.rb
#
# n.b requires the octokit gem
@fuzzmonkey
fuzzmonkey / activesupport instrumentation riemann.rb
Last active December 16, 2015 06:58
A few bits of Ruby code for using ActiveSupport::Notifications to pass custom & rails provided metrics to riemann.
# in config/initializers/riemann.rb
$riemann = Riemann::Client.new
channels_to_subscribe = ["auth","process_action.action_controller","deliver.action_mailer"]
channels_to_subscribe.each do |channel|
ActiveSupport::Notifications.subscribe channel do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
Rails.logger.debug "ActiveSupport::Notifications #{event.name}, #{event.payload.inspect}"
riemann_event = {
host: `hostname`,
state: event.payload[:state],
#!/usr/bin/env ruby
require 'net/http/post/multipart'
require 'mime/types'
require 'oauth'
require 'json'
require 'uri'
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
OAUTH_TOKEN = ''
@fuzzmonkey
fuzzmonkey / ruby_version_find.rb
Created June 27, 2013 15:53
a script for find .ruby-version or .rbenv-version files in your github repos.
# Find any ruby-version or rbenv-version files in your GitHub repos
#
# usage: $ USERNAME=yourusername PASSWORD=yourpassword ruby ruby_version_find.rb
# or
# usage: $ USERNAME=yourusername PASSWORD=yourpassword ORG=yourorgname ruby ruby_version_find.rb
#
# n.b requires the octokit gem
require 'rubygems'
require 'octokit'
14:31 < piman_> I think this sounds awful.
14:31 < piman_> "Stress-testing this perspective" is the same as "devil's advocate trolling".
14:31 < piman_> And asking people to constantly explain themselves for your thought experiments is completely inconsiderate.
^ Potential misunderstanding about what you meant, which you later clarify but you followed with:
14:34 < txus> piman_: if learning is a thought experiment to you then you don't understand the value of discussion and bringing knowledge and new points of view to other people
^ This is dismissive, implying someone doesn't understand is a pretty low blow in a discussion
//pin numbers
int LEFTRIGHT_DIR = 10;
int LEFTRIGHT_PWM = 9;
void setup() {
pinMode(LEFTRIGHT_DIR, OUTPUT);
pinMode(LEFTRIGHT_PWM, OUTPUT);
Serial.begin(9600);
@fuzzmonkey
fuzzmonkey / gist:8806903
Created February 4, 2014 16:18
Basic riemann config
; -*- mode: clojure; -*-
; vim: filetype=clojure
(logging/init :file "/var/log/riemann/riemann.log")
; Listen on the local interface over TCP (5555), UDP (5555), and websockets
; (5556)
(let [host "127.0.0.1"]
(tcp-server :host host)
(udp-server :host host)
@fuzzmonkey
fuzzmonkey / gist:77a0d1065043a5e4e387
Created September 1, 2014 18:09
This code generates three SQL queries in ActiveRecord. Not what i was expecting..
foos = Foo.where(params)
if foos.any?
# Foo Load (0.1ms) select count from foos where params
if foos.size == 1 && foos.first.attribute == 'bar'
# Foo Load (0.1ms) select count from foos where params
# Foo Load (0.1ms) select * from foos where params
end
end