Skip to content

Instantly share code, notes, and snippets.

View bennage's full-sized avatar
📺
please stay tuned

Christopher Bennage bennage

📺
please stay tuned
View GitHub Profile
param(
[string]$server = "origin",
[string]$branch = "master"
)
$gitStatus = (Get-GitStatus)
if ($gitStatus -eq $null) {
write-error "Not in a Git repository."
} elseif ($gitStatus.HasUntracked -or $gitStatus.HasWorking -or $gitStatus.HasIndex) {
@tj
tj / some.sh
Created October 11, 2012 18:45
change terminal tab name on cd
function tabname {
printf "\e]1;$1\a"
}
if [ x`type -t cd` == "xfunction" ]; then
# previously wrapped cd
eval $(type cd | grep -v 'cd is a function' | sed 's/^cd/original_cd/' | sed 's/^}/;}/' )
else
# builtin
eval "original_cd() { builtin cd \$*; }"
@half-ogre
half-ogre / NuGet.targets.xml
Created February 22, 2012 04:22
A replacement for the NuGet.targets file that requires nuget.exe be on the path, so you don't have to commit it.
<?xml version="1.0" encoding="utf-8"?>
<!-- #### NOTE #### -->
<!-- To build with Mono's xbuild on bash, you must execute [`sudo install-nuget.sh`](https://gist.github.com/2595337) first. -->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
<!-- Windows specific commands -->
# in ruby, nil is an instance of NilClass. we're monkeypatching NilClass at this point, which is a bad idea for a production app.
# but for this example, it gets the point across and should help you find a solution to what you want... maybe...
class NilClass
def method_missing(name, *args)
if respond_to? name
return name(*args)
else
puts "do something about #{name} being nil, here"
# this will forward the call to the original NilClass.method_missing
// How about?
let (|NullEmpty|NonNull|) input =
if System.String.IsNullOrEmpty input then NullEmpty else NonNull
let fullName first last =
match first, last with
| NullEmpty, NullEmpty -> failwith "Both first and last cannot be null"
| NonNull, NullEmpty -> first
| NullEmpty, NonNull -> last