Skip to content

Instantly share code, notes, and snippets.

@scottmuc
scottmuc / PermalinkProcessingHandler.cs
Created December 31, 2011 23:52
BLOG: It's good to laugh at your old code
using System.Web;
using CBC.Radio3.Permalinks.Common;
namespace CBC.Radio3.Permalinks.HttpHandlers
{
public class PermalinkProcessingHandler : IHttpHandler
{
private readonly IPermalinkParser permalinkParser;
public PermalinkProcessingHandler()
@scottmuc
scottmuc / WebPath.cs
Created January 1, 2012 00:06
BLOG: Handy Web Path Concatenation Code
using System.Text;
namespace CBC.Radio3.Commons.Web
{
public class WebPath
{
/// <summary>
/// Takes a parameter list of strings and returns the strings concatenated with a
/// preceding '/' character. If the string has a trailing/preceding slash it will
/// be removed. Any slashes in the middle of the string will remain.
@scottmuc
scottmuc / CreateDatabase.cs
Created January 2, 2012 15:05
BLOG: Unit Testing Domain Persistence With NDbUnit
[Fact(Skip = "Only need this to setup the DB")]
public void CreateDatabaseSchemaFromMappingFiles()
{
IWindsorContainer container = new WindsorContainer()
.Install(BinsorScript.FromFile(TestConfiguration.BinsorConfig));
var cfg = container.Resolve<Configuration>();
var schema = new SchemaExport(cfg);
schema.Create(true, true);
}
@scottmuc
scottmuc / 1.WhatIHaveToDo.ps1
Created January 2, 2012 15:31 — forked from ferventcoder/1.WhatIHaveToDo.ps1
Pester - Script variables should reset for every describe
Describe "When installing packages from a packages.config manifest" {
$script:chocolatey_nuget_was_called = $false
$script:chocolatey_rubygem_was_called = $false
$script:chocolatey_webpi_was_called = $false
$script:packageName = ''
$script:version = ''
# content here
}
@scottmuc
scottmuc / gist:2876931
Created June 5, 2012 18:53
Why is -rbundle/setup here?
Rakefile is:
task :test do
sh "env > test.env"
end
my local env doesn't have RUBYOPT set, but when I run `rake test` I see the following:
RUBYOPT=-I/Users/ThoughtWorks/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.1.4/lib -rbundler/setup
#!/bin/bash
for i in {1..90}
do
num=`printf "%02d" $i`
if ! ls das-00${num}* &> /dev/null; then
echo missing episode ${num}
fi
done
@scottmuc
scottmuc / remove_amplification.rb
Last active March 10, 2018 18:58
A script to unfollow everyone on Twitter and another to remove retweets from your Twitter timeline
require 'rubygems'
require 'twitter'
$stdout.sync = true
def rate_limited
begin
yield
rescue Twitter::Error::TooManyRequests => error
sleep error.rate_limit.reset_in + 1
@scottmuc
scottmuc / Get-FromSFtp.Tests.ps1
Last active August 29, 2015 14:02
Adding Pester tests to existing code
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
. "$here\$sut"
$mockSFtpCode = @"
public class MockSFtp {
public bool ConnectCalled { get; private set; }
public bool DisconnectCalled { get; private set; }
public bool IsConnected { get; set; }
public string ChangeDirectoryParam { get; private set; }
Recipe: sprout-homebrew::cask
* directory[/usr/local/Library/Taps] action create[2016-01-02T19:45:57+01:00] INFO: Processing directory[/usr/local/Library/Taps] action create (sprout-homebrew::cask line 3)
(up to date)
* homebrew_tap[caskroom/cask] action tap[2016-01-02T19:45:57+01:00] INFO: Processing homebrew_tap[caskroom/cask] action tap (sprout-homebrew::cask line 8)
(up to date)
* package[caskroom/cask/brew-cask] action install[2016-01-02T19:45:57+01:00] INFO: Processing package[caskroom/cask/brew-cask] action install (sprout-homebrew::cask line 10)
(up to date)
* package[caskroom/cask/brew-cask] action upgrade[2016-01-02T19:45:57+01:00] INFO: Processing package[caskroom/cask/brew-cask] action upgrade (sprout-homebrew::cask line 12)
(up to date)
* directory[/opt/homebrew-cask/Caskroom] action create[2016-01-02T19:45:58+01:00] INFO: Processing directory[/opt/homebrew-cask/Caskroom] action create (sprout-homebrew::cask line 17)
@scottmuc
scottmuc / bumpme
Last active February 14, 2018 12:53
Wed Feb 14 12:53:38 UTC 2018