Skip to content

Instantly share code, notes, and snippets.

View andre's full-sized avatar

Andre Lewis andre

View GitHub Profile
#! /usr/bin/env ruby
require "open3" # for reading stderr
# A dirt-simple script to merge a pull request from someone on github.
# Andre Lewis, 2009
#
# Assumptions:
# 1. you're currently working on master
# 2. you've already reviewed the pull request and have decided to include it.
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
# Quick and dirty applescript to determine batter life under very light load. This script just navigates Safari to a
# page every 10 seconds to simulate web browsing.
#
# You'll need to change the file output path (in the log method) for your machine.
#
# The test:
# * a freshly charged and calibrated battery
# * dim brightness to 50%
# * turn off bluetooth
# * set display to never go to sleep
# MySQL Statistics by Eric Lindvall <eric@5stops.com>
# MySQLTuner integration by Andre Lewis <@andre@scoutapp.com>
class MysqlQueryStatistics < Scout::Plugin
ENTRIES = %w(Com_insert Com_select Com_update Com_delete)
OPTIONS=<<-EOS
user:
name: MySQL username
>> MySQLTuner 1.0.1 - Major Hayden
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.41-3ubuntu12.3
[OK] Operating on 32-bit architecture with less than 2GB RAM
-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in InnoDB tables: 267M (Tables: 9)
@andre
andre / nokogiri_test.rb
Created January 26, 2011 20:11
This will crash macruby inconsistently with "incorrect checksum for freed object - object was probably modified after being freed."
require "rubygems"
require "nokogiri"
puts "starting"
html=<<-EOS
<div class="result">
<div>
<h1>
# Takes an IP or hostname. Reports 1 if it can ping the host, 0 if it can't
class Ping < Scout::Plugin
OPTIONS=<<-EOS
host:
name: Host
notes: the IP address or hostname to ping
EOS
def build_report
#!/bin/sh
#
# killspike2
# Remove (presumably erroneous) peaks from RRD files
#
# Matt Zimmerman <mdz@debian.org>, 05/2002
#
set -e
# Multiple, concurrent HTTP (non-SSL) requests
#
# Works in macuruby
require 'net/http';
def do_https
http=Net::HTTP.new('www.yahoo.com', 80)
http.start() {|http|
req = Net::HTTP::Get.new('/')
warning: Could not find object file "/Users/lrz/src/macruby-0.10/ext/openssl/openssl_missing.o" - no debug information available for "openssl_missing.c".
warning: Could not find object file "/Users/lrz/src/macruby-0.10/ext/openssl/ossl.o" - no debug information available for "ossl.c".
warning: Could not find object file "/Users/lrz/src/macruby-0.10/ext/openssl/ossl_asn1.o" - no debug information available for "ossl_asn1.c".
warning: Could not find object file "/Users/lrz/src/macruby-0.10/ext/openssl/ossl_bio.o" - no debug information available for "ossl_bio.c".
warning: Could not find object file "/Users/lrz/src/macruby-0.10/ext/openssl/ossl_bn.o" - no debug information available for "ossl_bn.c".