Skip to content

Instantly share code, notes, and snippets.

Avatar
🔎
hunting for code to clean up

M. Scott Ford mscottford

🔎
hunting for code to clean up
View GitHub Profile
View 0001-Exports-sftp_reply_-functions.patch
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
An ASP.NET MVC HTML helper method that renders a menu from a SiteMap
View MvcSiteMapMenuHelper.cs
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 Jun 8, 2009
Object helper method that makes it quite a bit easier to work with anonymous classes.
View ObjectExtensions.cs
// 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 Dec 4, 2009
A class for IronRuby users that will point the current AppDomain's configuration to a new configuration file.
View configuration_settings_hackery.rb
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 Dec 7, 2009
Helper class for using log4net with IronRuby.
View log4net.rb
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)
View instrumentor.rb
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
View dbgrep.rb
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
View dbdump.rb
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 Jan 7, 2010
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.
View watir_wait.rb
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 Sep 4, 2015
transformer_names.rb: Used to get a random Transformer character name. Great for naming devices.
View transformer_names.rb
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',
You can’t perform that action at this time.