Skip to content

Instantly share code, notes, and snippets.

@aaronlerch
aaronlerch / gist:1171640
Created August 25, 2011 19:42
Calling Twilio from Powershell
[System.Reflection.Assembly]::LoadFile("path to twilio assembly") | out-null
$twilio = new-object Twilio.TwilioRestClient("accountSid", "authToken")
$msg = $twilio.SendSmsMessage("+15551112222", "+15553334444", "Can you believe it's this easy to send an SMS?!")
@aaronlerch
aaronlerch / gist:1464878
Created December 12, 2011 04:29
Hmmm, no?
# Run at 11:28 PM on Sunday the 11th
Date.today
=> Sun, 11 Dec 2011
Date.tomorrow
=> Tue, 13 Dec 2011
@aaronlerch
aaronlerch / fluentmigrator_migration.xml
Created January 17, 2012 15:41
Simple Resharper live template for FluentMigrator migrations
<TemplatesExport family="Live Templates">
<Template uid="23818653-ac72-4057-9afc-35649cdfe0fc" shortcut="migration" description="FluentMigrator Migration" text="[Migration($VERSION$)]&#xD;&#xA;public class $MIGRATION_NAME$ : Migration&#xD;&#xA;{&#xD;&#xA; public override void Up()&#xD;&#xA; {&#xD;&#xA; $UP$&#xD;&#xA; }&#xD;&#xA;&#xD;&#xA; public override void Down()&#xD;&#xA; {&#xD;&#xA; $DOWN$&#xD;&#xA; }&#xD;&#xA;}" reformat="True" shortenQualifiedReferences="True">
<Context>
<CSharpContext context="Everywhere" minimumLanguageVersion="2.0" />
</Context>
<Categories />
<Variables>
<Variable name="VERSION" expression="getCurrentTime(&quot;yyyyMMddHHmmss&quot;)" initialRange="0" />
<Variable name="MIGRATION_NAME" expression="" initialRange="0" />
<Variable name="UP" expression="constant(&quot;throw new NotImplementedException();&quot;)" initialRange="0" />
@aaronlerch
aaronlerch / StringExtensions.cs
Created November 30, 2012 19:48
Ahhhh, much better.
public static class StringExtensions
{
public static bool Is(this string value, string compareTo)
{
return value.Is(compareTo, StringComparison.OrdinalIgnoreCase);
}
public static bool Is(this string value, string compareTo, StringComparison stringComparison)
{
return String.Equals(value, compareTo, stringComparison);
@aaronlerch
aaronlerch / gist:4230659
Created December 7, 2012 03:58
Cheat on Heroku Cedar stack: current status
Repo: https://github.com/aaronlerch/cheat
Current spike set up at: http://cheat-cedar.herokuapp.com/
The gem 'ambition' requires 'ParseTree' which isn't compatible with 1.9.2. Recommendations on next steps?
2012-12-07T03:55:30+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 52103`
2012-12-07T03:55:35+00:00 app[web.1]: *** Sorry, ParseTree doesn't work with ruby 1.9.2
2012-12-07T03:55:36+00:00 heroku[web.1]: Process exited with status 1
@aaronlerch
aaronlerch / gist:5144754
Created March 12, 2013 17:02
Redis URI examples
The ToRedisEndPoints extension method ( found here: https://github.com/ServiceStack/ServiceStack.Redis/blob/master/src/ServiceStack.Redis/RedisExtensions.cs ) doesn't know how to process a string-based redis endpoint using URI syntax.
Example: this fails to parse.
redis://user-is-not-used:password-is-used@my-redis-server:1234/5678
It more strictly expects a format that is:
password@host:port
If I pass it the URI above ("redis://" prefixed) then it fails to process.
@aaronlerch
aaronlerch / .bashrc
Created April 5, 2013 18:12
find-string (fs) for bash In powershell I had "fs" wrap a simple find-string helper. Been missing it in bash, but it was easy enough to create.
fs() {
if [ "$#" -lt 1 ]
then
echo "A search string is required"
return
fi
find . -iname "${2:-*.cs}" | xargs grep "$1" -s
}
@aaronlerch
aaronlerch / FunqDependencyResolver.cs
Last active December 16, 2015 00:09
SignalR IDependencyResolver implementation for Funq/ServiceStack.
using System;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using Funq;
using Microsoft.AspNet.SignalR;
namespace Foo
{
public class FunqDependencyResolver : DefaultDependencyResolver
@aaronlerch
aaronlerch / gist:5664860
Created May 28, 2013 18:15
ServiceStack self-host workaround for VirtualPathUtility exception. If you're self-hosting recent versions of ServiceStack (3.9.45+) and serving Razor views, you'll notice that @href (which is a wrapper around Url.Content) fails with app-relative paths that start with "~/". Add the following to your startup code to work around it.
var domain = Thread.GetDomain(); // or AppDomain.Current
domain.SetData(".appDomain", "yep");
domain.SetData(".appVPath", "/");
domain.SetData(".appPath", domain.BaseDirectory);
if (String.IsNullOrWhiteSpace(domain.GetData(".appId") as string))
{
domain.SetData(".appId", "1");
}
if (String.IsNullOrWhiteSpace(domain.GetData(".domainId") as string))
{
@aaronlerch
aaronlerch / README.md
Created August 7, 2013 16:46
Upstart scripts for MongoDB Monitoring Service agent (MMS) MongoDB Backup Service agent (MBS?)

Download

Download and install the agent(s). These examples are on a standard 64-bit Amazon EC2 Linux AMI.

MMS

wget [path to mms agent download, specified by 10gen]
sudo tar xvzf 10gen-mms-agent-[CUSTOM_NAME].tar.gz -C /opt