Skip to content

Instantly share code, notes, and snippets.

View stevenharman's full-sized avatar

Steven Harman stevenharman

View GitHub Profile
@stevenharman
stevenharman / sqlserver_backup_info.rb
Created September 23, 2010 21:49
Extract metadata (like Logical name, file paths, etc.) from a SQL Server backup file into an Array of Hashes.
# Extract metadata (like Logical name, file paths, etc.) from a SQL Server backup file into an Array of Hashes.
# This assumes you're running on Windows and have SQL Server installed locally.
# example usage:
#
# require 'sqlserver_backup_info'
#
# bak = File.expand_path('../MyBackup.bak', __FILE__)
# info = extract_info bak
# info.each { |meta| puts meta[:logical_name] }
#
@stevenharman
stevenharman / Iso8601DateTimeBinder.cs
Created November 2, 2010 19:25
an asp.net-mvc Model Binder that respects the ISO 8601 standard. look it up, yo!
using System;
using System.Globalization;
using System.Web.Mvc;
namespace Zomg.Web.ModelBinders
{
public class Iso8601DateTimeBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
@stevenharman
stevenharman / CapsLockIsCtrl.reg
Created January 20, 2011 20:49
on Windows, remap the CapsLock key to Ctrl key.
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
@stevenharman
stevenharman / namespaced_variables.less
Created February 18, 2011 19:12
Using variables w/in a namespace
#forms {
@input: #454545;
@input_border: #CCCCCC;
}
/* then, somewhere later try to use that */
fieldset {
input {
color: #forms > @input; /* maybe #forms[@input] is a better syntax?
@stevenharman
stevenharman / fitter-happier.sh
Created March 12, 2011 03:20
awesomely weird; Radiohead uses OS X?
say -v Fred "Fitter, happier, more productive,
comfortable,
not drinking too much,
regular exercise at the gym
(3 days a week),
getting on better with your associate employee contemporaries,
at ease,
eating well
(no more microwave dinners and saturated fats),
a patient better driver,
@stevenharman
stevenharman / _gradient.less
Created March 24, 2011 21:59
a gradient mix-in for LESS (tested with dotLESS, but may work with LESS.js)
.gradient(@from:#fff, @to:#fff, @fallback:@from) {
/* https://github.com/jamesfoster/dotless/commit/4004eff3cab321e31f43d052e35b5538f19443f7 */
@ffgradient: "-moz-linear-gradient(top, {0}, {1}) no-repeat scroll 0 0 transparent";
@wkgradient: "-webkit-gradient(linear,left top,left bottom,color-stop(0, {0}),color-stop(1, {1})) no-repeat scroll 0 0 transparent";
@iegradient: "progid:DXImageTransform.Microsoft.gradient(startColorstr='{0}', endColorstr='{1}')";
@ie8gradient: "\"progid:DXImageTransform.Microsoft.gradient(startColorstr='{0}', endColorstr='{1}')\"";
background: @fallback; /* for non-css3 browsers */
background: formatstring(@ffgradient, @from, @to); /* FF3.6+ */
@stevenharman
stevenharman / brew-install-git.sh
Created March 27, 2011 05:16
a replacement for the git-osx-installer
brew install git
class ApplicationController < (defined?(Rails) && ActionController::Base || Object)
end
@stevenharman
stevenharman / account.rb
Created April 22, 2011 22:43
totally contrived example of encapsulating Rails stuff behind the AR model
class Account < ActiveRecord::Base
def invalidate!
update_attributes(:enabled => false)
end
end
<!-- the original SPARK template -->
<!-- notice the SINGLE QUOTES on the data-form attribute -->
<div data-form='{"method":"get", "action":"search"}'>
<input type="search" name="q" placeholder="search..." />
<input type="submit" value="go!" />
</div>