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
From 579377d5e510a4c138904181b640480524c30bce Mon Sep 17 00:00:00 2001
From: "M. Scott Ford" <scott@corgibytes.com>
Date: Fri, 2 Jan 2015 10:34:16 -0500
Subject: [PATCH] Exports sftp_reply_* functions
---
include/libssh/sftp.h | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/libssh/sftp.h b/include/libssh/sftp.h
@mscottford
mscottford / MvcSiteMapMenuHelper.cs
Created May 27, 2009 21:42
An ASP.NET MVC HTML helper method that renders a menu from a SiteMap
public static string Menu(this HtmlHelper helper, string siteMapProviderName)
{
var provider = SiteMap.Providers[siteMapProviderName];
return NodesAsHtml(provider.RootNode);
}
private static string NodesAsHtml(SiteMapNode node)
{
var writer = new StringWriter();
@mscottford
mscottford / ObjectExtensions.cs
Created June 8, 2009 21:23
Object helper method that makes it quite a bit easier to work with anonymous classes.
// Example
// var sample = new { booleanValue = true, stringValue = "Test Value" }
// sample.Property<bool>("booleanValue") will result in true
// sample.Property<string>("stringValue") will result in "Test Value"
static class ObjectExtensions
{
public static T Property<T>(this object target, string name)
{
return (T)target.GetType().InvokeMember(name, BindingFlags.GetProperty, null, target, new object[] { });
}
@mscottford
mscottford / configuration_settings_hackery.rb
Created December 4, 2009 18:19
A class for IronRuby users that will point the current AppDomain's configuration to a new configuration file.
require 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
class ConfigurationSettingsHackery
def set_config_file(new_config_file)
set_config_file_on_current_app_domain(new_config_file)
refresh_current_client_config_paths
reset_configuration_manager_to_force_reload
end
@mscottford
mscottford / log4net.rb
Created December 7, 2009 16:13
Helper class for using log4net with IronRuby.
class Log4Net
def initialize()
@log4net = IronRuby.require('log4net')
end
def configure
@log4net.GetType("log4net.Config.BasicConfigurator").GetMethod("Configure", System::Array.of(System::Type).new(0)).Invoke(nil, nil)
end
def logger(log_name)
require 'optparse'
require 'ostruct'
require 'Mono.Cecil'
class System::Reflection::Assembly
def get_type_from_name(name)
method(:GetType).overload(System::String).call(name)
end
end
require 'oci8'
require 'ostruct'
require 'optparse'
class DatabaseUtils
def print_table_row(owner, table_name, column_data)
output = "#{owner}.#{table_name}: {"
index = 0
first = true
require 'oci8'
require 'ostruct'
require 'optparse'
class DatabaseUtils
def print_table_row(owner, table_name, column_data)
output = "#{owner}.#{table_name}: {"
index = 0
first = true
@mscottford
mscottford / watir_wait.rb
Created January 7, 2010 13:43
Dynamically adds "wait_to_" variants for common watir methods. Calling these variants will force the browser to first wait for the browser to finish, and then to wait for the specified element to exist before performing the desired action.
require 'watir'
require 'watir/container'
require 'watir/element'
require 'watir/input_elements'
require 'watir/link'
def support_wait_to_methods
timeout_in_seconds = 30
original_method_missing = self.instance_method(:method_missing)
@mscottford
mscottford / transformer_names.rb
Last active September 4, 2015 18:26
transformer_names.rb: Used to get a random Transformer character name. Great for naming devices.
class TransformerNames
# source: http://en.wikipedia.org/wiki/List_of_The_Transformers_characters#Autobots
AUTOBOTS = ['Teletraan', 'Optimus Prime', 'Wheeljack', 'Bumblebee',
'Cliffjumper', 'Prowl', 'Jazz', 'Sideswipe', 'Ratchet', 'Ironhide', 'Hound',
'Mirage', 'Trailbreaker', 'Sunstreaker', 'Bluestreak', 'Windcharger',
'Brawn', 'Huffer', 'Gears', 'Skyfire', 'Grimlock', 'Slag', 'Sludge',
'Snarl', 'Swoop', 'Warpath', 'Tracks', 'Grapple', 'Blaster', 'Red Alert',
'Smokescreen', 'Perceptor', 'Seaspray', 'Hoist', 'Powerglide',
'Beachcomber', 'Inferno', 'Cosmos', 'Omega Supreme', 'Devcon', 'Skids',
'Alana', 'Elita One', 'Chromia', 'Firestar', 'Moonracer', 'Alpha Trion',