Skip to content

Instantly share code, notes, and snippets.

View JangoSteve's full-sized avatar

Steve Schwartz JangoSteve

View GitHub Profile
# Created by Steve Schwartz [1] (for Alfa Jango, LLC [2]) for the Twilk API [3]
# [1] http://github.com/jangosteve
# [2] http://www.alfajango.com
# [3] http://twilk.com
# The latest version of this script may be found at http://gist.github.com/371710
require 'net/http'
require 'rubygems'
require 'json'
# Created by Steve Schwartz [1] (for Alfa Jango [2]) with the help of David Leal [3]
# [1] http://github.com/jangosteve
# [2] http://www.alfajango.com
# [3] http://github.com/david
# The latest version of this script may be found at http://gist.github.com/371710
require 'benchmark'
class OptionsHashBenchmarker
module LightviewHelper
# Modified by Steve Schwartz [1] (for Alfa Jango, LLC [2]) from Ric Roberts's original script [3]:
# CHANGELOG:
# -Added link_to_reg_lightview method to use the gracefully-degrading version of Lightview (creates a regular link that has a javascript method onclick)
#
# [1] http://github.com/jangosteve
# [2] http://www.alfajango.com
# [3] http://ricroberts.com/articles/lightview-for-modal-dialogs-on-rails
module PrototipHelper
# Created by Steve Schwartz [1] (for Alfa Jango, LLC [2]) for the Scriptaculous Prototip tooltip library by Nick Stakenburg [3].
#
# [1] http://github.com/jangosteve
# [2] http://www.alfajango.com
# [3] http://www.nickstakenburg.com/projects/prototip2/
# Using this in your views:
# <%= prototip( "target_id_to_attach_prototip",
#!/usr/bin/env ruby
# adapted for RMSR from http://gist.github.com/41713
# run every couple minutes via cron
# and output results to script_output.log
# sudo crontab -e
# then add the following:
# */2 * * * * ruby /bin/passenger_monitor_cron 2>&1 >> /var/log/script_output.log
command = '/usr/bin/passenger-memory-stats'
20:43 :: ~ $ wget http://cdn3.ratemystudentrental.com/javascripts/all-rmsr.js?1273741914
--2010-05-13 20:43:39--  http://cdn3.ratemystudentrental.com/javascripts/all-rmsr.js?1273741914
Resolving cdn3.ratemystudentrental.com... 216.137.63.146, 216.137.63.175, 216.137.63.203, ...
Connecting to cdn3.ratemystudentrental.com|216.137.63.146|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 293014 (286K) [application/x-javascript]
Saving to: `all-rmsr.js?1273741914'
100%[======================================>] 293,014      312K/s   in 0.9s    
Steves-Macbook:desktop steveschwartz$ wget http://cdn.ratemystudentrental.com/javascripts/all-rmsr.js.gz?1275522132--00:33:42-- http://cdn.ratemystudentrental.com/javascripts/all-rmsr.js.gz?1275522132 => `all-rmsr.js.gz?1275522132.6'Resolving cdn.ratemystudentrental.com... 208.78.103.49
Connecting to cdn.ratemystudentrental.com[208.78.103.49]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85,785 [application/x-gzip]
100%[====================================================================================>] 85,785 431.60K/s in 0.19 seconds
00:33:43 (429.56 KB/s) - `all-rmsr.js.gz?1275522132.6' saved [85785/85785]
Steves-Macbook:desktop steveschwartz$ wget http://cdn0.ratemystudentrental.com/javascripts/all-rmsr.js.gz?1275522132--00:33:57-- http://cdn0.ratemystudentrental.com/javascripts/all-rmsr.js.gz?1275522132 => `all-rmsr.js.gz?1275522132.7'Resolving cdn0.ratemystudentrental.com... 216.137.33.166, 216.137.33.33, 216.137.33.228, ...
#!/bin/sh
echo "js-zipped-served-from-rmsr-vs-cloudfront-vs-intercepted-cloudfront"
echo " "
echo "------------------------------------------------------------------------------------------------------------------------------------------------------"
for i in {1..5}
do
for loc in "http://cdn.ratemystudentrental.com/javascripts/all-rmsr.js?1275522132" "http://cdn0.ratemystudentrental.com/javascripts/all-rmsr.js?1275522132" "http://compressed.ratemystudentrental.com/javascripts/all-rmsr.js?1275522132" "http://cdn0.ratemystudentrental.com/javascripts/all-rmsr.js.gz?1275522132"
do
echo "vv $loc vv"
#!/usr/bin/env ruby
require 'open-uri'
require 'rexml/document'
require 'rexml/xpath'
url = 'http://rpm.newrelic.com/accounts.xml?include=application_health'
headers = {'x-license-key' => 'YOUR LICENSE KEY'}
# Validates whether the value of the specified attribute matches the format of an URL,
# as defined by RFC 2396. See URI#parse for more information on URI decompositon and parsing.
#
# This method doesn't validate the existence of the domain, nor it validates the domain itself.
#
# Allowed values include http://foo.bar, http://www.foo.bar and even http://foo.
# Please note that http://foo is a valid URL, as well http://localhost.
# It's up to you to extend the validation with additional constraints.
#
# class Site < ActiveRecord::Base