Skip to content

Instantly share code, notes, and snippets.

View actaneon's full-sized avatar

Josh King actaneon

  • Get Satisfaction
  • San Francisco, CA
View GitHub Profile
@actaneon
actaneon / EnumClass.cs
Created December 31, 2009 17:48
Enum Class
// Purpose is to have strongly typed options for in code
// and be able to use those options in list operations
// as well as have more than two fields.
// Usage:
// Fruit item = Fruit.GetItems().First(x => x.ID = 1);
// Assert.IsTrue(item.Code = "a");
using System.Collections.Generic;
using System.Linq;
@actaneon
actaneon / .bash_profile
Created December 31, 2009 07:03 — forked from markembling/.bash_profile
Bash prompt with Git Info
# Function for determining current git branch (if any)
# Gracefully fails if not in a git repo and returns nothing.
__gitBranch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
# Retrieves status information for git and places into predefined variables.
__gitStatus() {
# Initialise git status variables
@actaneon
actaneon / profile.ps1
Created December 31, 2009 06:57 — forked from markembling/profile.ps1
Bash like prompt with Git Info
# My preferred prompt for Powershell.
# Displays git branch and stats when inside a git repository.
# See http://gist.github.com/180853 for gitutils.ps1.
. (Resolve-Path ~/Documents/WindowsPowershell/gitutils.ps1)
function prompt {
$path = ""
$pathbits = ([string]$pwd).split("\", [System.StringSplitOptions]::RemoveEmptyEntries)
if($pathbits.length -eq 1) {
@actaneon
actaneon / gitutils.ps1
Created December 31, 2009 06:57 — forked from markembling/gitutils.ps1
Git functions for use with profile.ps1
# Git functions
# Mark Embling (http://www.markembling.info/)
# Is the current directory a git repository/working copy?
function isCurrentDirectoryGitRepository {
if ((Test-Path ".git") -eq $TRUE) {
return $TRUE
}
# Test within parent dirs
mklink /D ".\WindowsPowershell" ".\My Dropbox\PowershellProfile"
@actaneon
actaneon / ShrinkDB.sql
Created December 30, 2009 16:28
Shrinks curent DB and Transaction log
declare @tablename varchar(255)
declare @logfilename nvarchar(200)
declare @datafilename nvarchar(200)
declare @dbname nvarchar(200)
declare @sql nvarchar(1000)
set @dbname = ltrim(rtrim(db_name()))
set @logfilename = ltrim(rtrim((select name from sysfiles where lower(filename) like '%.ldf%')))
set @datafilename = ltrim(rtrim((select name from sysfiles where lower(filename) like '%.mdf%')))
@actaneon
actaneon / IFS.sh
Created November 18, 2009 02:36
IFS - Looping Over Space Separated Filenames
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for f in *
do
echo "$f"
done
IFS=$SAVEIFS
@actaneon
actaneon / Default.aspx
Created October 27, 2009 05:07
Default.aspx for ASP.NET MVC 2
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<%
var originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
%>
@actaneon
actaneon / .gitconfig
Created October 23, 2009 06:47
.gitconfig
[user]
email = [email protected]
name = Josh King
[core]
excludesfile = /Users/jking/.gitignore
#excludesfile = c:/Users/jking/.gitignore
editor = vim
pager = less -FRSX
[merge]
tool = vimdiff
@actaneon
actaneon / DelimitedFileParser.cs
Created August 21, 2009 20:09
DelimitedFileParser.cs
using Microsoft.VisualBasic.FileIO;
public class DelmitedFileParser
{
private void Parse()
{
TextFieldParser parser = new TextFieldParser(@"c:\temp\test.csv");
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");