Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bitops's full-sized avatar

Sebastian Wittenkamp bitops

View GitHub Profile
@bitops
bitops / TestStuff.ps1
Created August 1, 2017 23:45
My first PowerShell script. Oh yeah.
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True)]
[string]$Foo,
[Parameter(Mandatory=$True)]
[string]$Bar
)
echo "Foo: $Foo"
@bitops
bitops / profile.ps1
Created August 1, 2017 23:44
Sebastian's Powershell profile
# need to have this all the time in $USER_HOME\Documents\WindowsPowerShell\profile.ps1
Set-PSReadLineKeyHandler -Key Tab -Function Complete
Set-PSReadLineOption -EditMode Emacs
@bitops
bitops / recursive_block.rb
Created July 31, 2016 20:30
a recursive function in ruby that takes a block
def foo(n, &block)
if n > 0
yield(n)
foo(n - 1, &block)
end
end
@bitops
bitops / selection.rb
Created July 28, 2016 18:48
selection sort :)
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
@bitops
bitops / bubble.rb
Created July 27, 2016 05:29
bubble sort :)
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
$ 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
@bitops
bitops / osx-10.11-setup.md
Created March 4, 2016 01:50 — forked from kevinelliott/osx-10.11-setup.md
Mac OS X 10.11 El Capitan Setup

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.

@bitops
bitops / extract_values.rb
Created June 16, 2015 18:33
Simple Ruby to extract nested values from a Hash
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
#
# ruby splat destructuring
#
class Bar
def qux
42
end
end
@bitops
bitops / hipchat.el
Last active November 14, 2019 20:09
HipChat + jabber.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; use jabber-connect to connect. Make sure you tab to select the hipchat account if it's the ;;
;; only connection configured. ;;
;; ;;
;; a fork of https://gist.github.com/puffnfresh/4002033 ;;
;; ;;
;; shout out to http://emacs.stackexchange.com/questions/10940/connecting-to-hipchat-xmpp-via-jabber-el ;;
;; for the help. ;;
;; ;;
;; you can look up the necessary jabber info on the account i