Skip to content

Instantly share code, notes, and snippets.

View davecowart's full-sized avatar

Dave Cowart davecowart

  • Homewood, Alabama
View GitHub Profile
@davecowart
davecowart / usage.sh
Last active November 13, 2015 18:58
ec2-search
davec@Busters ~
% which ec2-rdp !10511
ec2-rdp () {
~/ec2-search.sh $1 $2 | xargs ~/rdp.sh
}
davec@Busters ~
% cat ec2-search.sh !10512
#!/bin/bash
@davecowart
davecowart / graphite.md
Last active August 29, 2015 14:01 — forked from kkc/graphite.md

install graphite (http://graphite.wikidot.com) on Amazon Linux AMI. Please fork and fix if you find an error.

Instally pycairo

sudo yum install pycairo-devel

Install pip

sudo yum install python-pip
@davecowart
davecowart / gist:6455054
Created September 5, 2013 19:38
SQL Merge Statement
select * from toolkitnotifications;
MERGE toolkitnotifications as target
USING (
select
ti.N2ItemId, ti.Id as ToolkitItemId, t.UserId, GETDATE() as Created, 'UpdatedContent' as [Action]
FROM ToolkitItems ti
LEFT JOIN Toolkits t
ON ti.ToolkitId = t.Id
WHERE ti.IsDeleted = 0
@davecowart
davecowart / github_watcher.rb
Created July 19, 2013 18:16
Github branch watcher
require 'open-uri'
require 'json'
class GithubWatcher
ROOT_URL = 'https://api.github.com'
TOKEN = '[API TOKEN]'
def compareBranches
branches = JSON.parse(open("#{ROOT_URL}/repos/[ORGANIZATION]/[REPO]/branches?access_token=#{TOKEN}").read)
active_branches = branches.select{|b| !['master','uat','qa'].include?(b['name'])}
@davecowart
davecowart / dabblet.css
Created December 20, 2012 22:09
Untitled
.card {
width: 150px;
background-color:lightblue;
padding:0 10px;
}
.card h3 {
border-bottom: solid 2px #aaa;
}
@davecowart
davecowart / S3FileSystem.cs
Created August 31, 2012 20:13
S3 Implementation of IFileSystem for N2CMS
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
using N2.Engine;
@davecowart
davecowart / regex.m
Created August 27, 2012 22:11
Obj-c YouTube Regex
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(?<=(?:v|i)=)[a-zA-Z0-9-]+(?=&)|(?<=(?:v|i)\\/)[^&\n]+|(?<=embed\\/)[^\"&\n]+|(?<=‌​(?:v|i)=)[^&\n]+|(?<=youtu.be\\/)[^&\n]+" options:NSRegularExpressionCaseInsensitive error:&error];
NSString *link = [post objectForKey:@"link"];
NSTextCheckingResult *match = [regex firstMatchInString:link options:0 range:NSMakeRange(0, [link length])];
NSString *identifier = [link substringWithRange:match.range];
NSString *html = [self embedYouTube:identifier frame:webView.frame];
[webView loadHTMLString:html baseURL:nil];
@davecowart
davecowart / vso.ps1
Created July 3, 2012 15:01
VS Open Function
#If you're in a folder with a solution file, it'll open the solution - otherwise it'll just open Visual Studio
Set-Alias vs "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"
function vso {
$SolutionFile = @(gci *.sln)[0]
vs $SolutionFile
}
@davecowart
davecowart / TapExtension.cs
Created June 22, 2012 18:02
C# implementation of Ruby's tap method
public static class TapExtension {
public static T Tap<T>(this T obj, Action<T> block) {
block.Invoke(obj);
return obj;
}
}
@davecowart
davecowart / Repository.cs
Created March 28, 2012 18:24
Dapper Repository
using System;
using System.Collections.Generic;
using System.Linq;
using Dapper;
namespace Example.Data.Dapper {
public class MessageRepository : RepositoryBase, IMessageRepository {
/// <summary>
/// Gets a single message
/// </summary>