Skip to content

Instantly share code, notes, and snippets.

View mscottford's full-sized avatar
🔎
hunting for code to clean up

M. Scott Ford mscottford

🔎
hunting for code to clean up
View GitHub Profile
@mscottford
mscottford / update-dns.rb
Created May 24, 2010 18:52
Uses the Rackspace Apps control panel website to update the DNS A record for a subdomain.
#!/usr/bin/ruby
require 'rubygems'
require 'steam'
require 'net/http'
require 'resolv'
require 'mail'
class DnsUpdateBot
def initialize
@mscottford
mscottford / demo.html
Created June 30, 2010 20:59
jQuery plugin that protects the selection of textareas when jQuery UI buttons are clicked.
<!DOCTYPE html>
<html lang='en'>
<head>
<script src="js/jquery-1.4.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery-ui-1.8.2.custom.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="css/black-tie/jquery-ui-1.8.2.custom.css" type="text/css" media="screen" title="no title" charset="utf-8">
<style type="text/css" media="screen">
html {
font-size: 11px;
font-family: arial;
@mscottford
mscottford / gist:768002
Created January 6, 2011 15:17
Fun with PHP's $this variable (PHP 5.2)
Interactive shell
php > class Foo {
php { public function invoke() {
php { print(get_class($this));
php { }
php { }
php > class Bar {
php { public function invoker() {
php { $foo = new Foo();
@mscottford
mscottford / rvm_prompt.bash
Created January 28, 2011 06:54
bash script that displays the current ruby in use by rvm as part of the prompt
function red_text {
local LIGHT_RED="\[\033[1;31m\]"
local NO_COLOR="\[\033[0m\]"
echo "$LIGHT_RED$1$NO_COLOR"
}
function green_text {
local LIGHT_GREEN="\[\033[1;32m\]"
local NO_COLOR="\[\033[0m\]"
echo "$LIGHT_GREEN$1$NO_COLOR"
@mscottford
mscottford / AppController.h
Created August 2, 2011 01:52
MacRuby IB Outlets and Actions Workaround
#import <Foundation/Foundation.h>
@interface AppController : NSObject {
NSComboBox *seriesCombo;
NSComboBox *titleCombo;
NSButton *readButton;
}
@property IBOutlet NSComboBox *seriesCombo;
@property IBOutlet NSComboBox *titleCombo;
cloudraker:mcsweeneys mscottford$ bundle exec rake db:migrate
rake aborted!
dlopen(/Users/mscottford/.rvm/gems/ruby-1.9.3-p0@mcsweeneys/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle, 9): Symbol not found: _ruby_current_thread
Referenced from: /Users/mscottford/.rvm/gems/ruby-1.9.3-p0@mcsweeneys/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
Expected in: flat namespace
in /Users/mscottford/.rvm/gems/ruby-1.9.3-p0@mcsweeneys/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle - /Users/mscottford/.rvm/gems/ruby-1.9.3-p0@mcsweeneys/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
(See full trace by running task with --trace)
/Users/mscottford/src/railsdog/mcsweeneys/config/initializers/10_cas.rb:1: warning: already initialized constant CAS
undefined local variable or method `new_action' for Admin::VariantsController:Class (NameError)
/Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/spree_core-0.70.3/app/controllers/admin/variants_controller.rb:4:in `<class:VariantsController>'
/Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/spree_core-0.70.3/app/controllers/admin/variants_controller.rb:1:in `<top (required)>'
/Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
/Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
/Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/mscottford/.rvm/gems/ruby-1.9.2-p290@mcsweeneys/gems/activesupport-3.1.1/lib/active_sup
@mscottford
mscottford / application.rb
Created January 10, 2012 14:54
spree calculator issue
module Mcsweeneys
class Application < Rails::Application
# snip
config.to_prepare do
## snip
Spree::Environment::Calculators.class_eval do
attr_accessor :handling_fees
end
end
cloudraker:mcsweeneys mscottford$ irb
1.9.3p0 :001 > a = Object.new
=> #<Object:0x007f7f59c09538>
1.9.3p0 :002 > Object.class_eval { def foo; puts 'wow'; end; }
=> nil
1.9.3p0 :003 > a.foo
wow
=> nil
1.9.3p0 :004 > b = Object.new
=> #<Object:0x007f7f59c19b18>
class Base
def alpha
:alpha
end
end
class Child < Base
def beta
:beta
end