View Program.cs
using System;
using System.IO;
using System.Threading;
using System.Xml;
using Couchbase;
namespace ConsoleApp1
{
class Program
{
View TestStuff.ps1
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True)]
[string]$Foo,
[Parameter(Mandatory=$True)]
[string]$Bar
)
echo "Foo: $Foo"
View profile.ps1
# need to have this all the time in $USER_HOME\Documents\WindowsPowerShell\profile.ps1
Set-PSReadLineKeyHandler -Key Tab -Function Complete
Set-PSReadLineOption -EditMode Emacs
View recursive_block.rb
def foo(n, &block)
if n > 0
yield(n)
foo(n - 1, &block)
end
end
View selection.rb
def selection_sort(array, start_idx=0)
smallest_value, swap_idx = nil, nil
for idx in start_idx..(array.size - 1)
val = array[idx]
if smallest_value.nil? || smallest_value > val
smallest_value = val
swap_idx = idx
end
end
View bubble.rb
def bubble_sort(array)
@swap_needed = false
array.each_with_index do |val, idx|
a = val
b = array[idx + 1]
if !b.nil? && a > b
@swap_needed = true
array[idx] = b
array[idx + 1] = a
View git-index.sh
$ git init .
Initialized empty Git repository in /Users/swittnekamp/tmp/git_index/.git/
$ cat <<EOF > foo.txt
Some example content
EOF
$ git add foo.txt
$ git status
View osx-10.11-setup.md

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

View extract_values.rb
class Hash
def extract_nested_values(hsh=self)
return hsh unless hsh.respond_to?(:keys)
hsh.keys.map do |k|
extract_nested_values(hsh[k])
end.flatten
end
end
View destructuring.rb
#
# ruby splat destructuring
#
class Bar
def qux
42
end
end