Skip to content

Instantly share code, notes, and snippets.

View jagipson's full-sized avatar

Jeffrey Gipson jagipson

View GitHub Profile
class Object
def method_missing(name, *args, &block)
# noop
end
end
- (@action)reltypeClick:(id)sender
{
var button;
var direction;
switch ([sender tag]) {
case 1:
direction = reltypeaDirBA;
button = reltypeaDirToggle;
break;
!#/usr/bin/ruby
max = 100
sum = (0..max).inject { |s,n| s + n**2 }
sqr = ((0..max).inject { |s,n| s+n }) ** 2
puts sqr-sum
###### Alternate solution :
#!/usr/bin/ruby
else
new_config = BOT_CONFIG
new_config[:autoload_plugins] = args
@bot.write_configuration(new_config)
# In lieu of reloading the configuration file, just redefine the constant
Kernel.remove_const(:BOT_CONFIG) if Kernel.const_defined?(:BOT_CONFIG)
Kernel.const_set(:BOT_CONFIG, new_config)
msg nick, "new configuration saved."
end
Use cases for mod to RuBot
1: The bot starts with no :autoload_plugins: entry in the yaml config file: a blank entry should be added
2: :autoload_plugins: is empty. The only plugin that should be loaded when the connection is established is core
3: :autoload_plugins: has multiple space-delimited module names. All are loaded when the connection is established.
4: :autoload_plugins: has multiple space-delimited module names. An invalid module name is in the list. All valid modules are loaded when the connection is established. Invalid modules produce a warning on the console, but do not raise.
5: The bot starts with no :autojoin_rooms: entry in the yaml config file: a blank entry should be added
6: :autojoin_rooms: is empty. No rooms are joined when the bot connection is established.
7: :autojoin_rooms: has multiple space-delimited #room names. All are joined when the connection is established.
@jagipson
jagipson / gist:1083757
Created July 14, 2011 23:59
JPG Renamer
#!/bin/bash
basedir=/tmp/testscript/working/Images
pushd "$basedir" &>/dev/null
# Loop over all dirs with names in front
for dirname in $(find ./apteryx -maxdepth 1 -type d -iregex '\./[a-z].*')
do
patnum=$(echo $dirname | sed 's/^.*_\([0-9]\+\)/\1/')
if grep -qv '^[[:digit:]]\+$' <<<$patnum
#!/bin/bash
# This script is named jpgtest_setup.sh
rm -rf /tmp/testscript
function setup
{
mkdir -p "$(dirname "$1")"
touch "$1"
}
class ProcedureDefinition < ActiveRecord::Base
validates :name, :presence => true
validates :version, :presence => true
before_destroy :check_is_latest_version
@jagipson
jagipson / backup_prep.sh
Created May 31, 2012 15:54
Git repo prepare for backups and restore
#!/bin/bash
# 05/26/2012 jag
# COMPONENT_NAME: backup_prep.sh
#
# ORIGIN: Jeffrey Gipson
#
# Personal Proprietary
# (C) COPYRIGHT 2012 Jeffrey Gipson
# Unpublished work - All Rights Reserved
#
#!/bin/bash
# Usage: rotate-screen [absolute] [action]
#
# ACTIONS:
# flip|invert - invert the screen from the current rotation
# left - rotate to the left
# right - rotate to the right
#
# OPTION: