Skip to content

Instantly share code, notes, and snippets.

View Iristyle's full-sized avatar

Ethan J. Brown Iristyle

View GitHub Profile
@Iristyle
Iristyle / git-rewrite-file-paths.sh
Created August 28, 2013 00:28
Rewrite git tree to add prefix to file paths
## rewrite the tree to add a prefix and trash some unnecessary files
git filter-branch --index-filter 'rm -f "$GIT_INDEX_FILE" && git read-tree --prefix=acceptance/ "$GIT_COMMIT" && git rm acceptance/.gitignore acceptance/Gemfile --ignore-unmatch' HEAD
@Iristyle
Iristyle / janky-pr-check.sh
Created July 26, 2013 19:49
For use during a PR sent to Janky to ensure latest code is pulled
if [[ ! -d './.git' ]]; then
git init
fi
owner=$(echo $JANKY_COMMIT_URL | sed -rn 's/^http(s)?\:\/\/github\.com\/(.*?)\/(.*?)\/?/\2/p')
repo=$(echo $JANKY_COMMIT_URL | sed -rn 's/^http(s)?\:\/\/github\.com\/(.*?)\/(.*?)\/?/\3/p')
url="https://[email protected]/$owner/$repo"
found=$(git remote | grep $owner)
@Iristyle
Iristyle / fizzbuzz.exs
Created July 24, 2013 18:26
Elixir FizzBuzz
defmodule FizzBuzz do
def sequence([]), do: []
def sequence(until) when is_integer(until) and until > 0 do
sequence(0..until |> Enum.to_list)
end
def sequence([head|tail]) do
output(rem(head, 3), rem(head, 5), head)
sequence(tail)
end
@Iristyle
Iristyle / current_scope.py
Created July 16, 2013 15:52
Sublime scope under current cursor
print(view.syntax_name(view.sel()[0].begin()))
# TODO: replace this hard-coded path with the path on disk where dngs are stored for current trip
$tripLocalPath = 'C:\Users\Ethan\Pictures\Curacao 2013'
$tripLocalFilter = '*.dng'
$memoryCardPath = 'd:\\'
$memoryCardFilter = '*.orf'
$names = dir $tripLocalPath -Recurse -Include $tripLocalFilter |
Select -ExpandProperty BaseName |
Sort-Object
@Iristyle
Iristyle / ConvertTo-Hashtable.ps1
Created May 30, 2013 12:04
Turn a PSCustomObject into a standard hash
function ConvertTo-Hashtable
{
<#
.Synopsis
Converts a PSCustomObject that may be returned over WinRM to a
standard Hashtable
.Description
.Parameter PSObject
.Example
#>
@Iristyle
Iristyle / Output-SuperWide.ps1
Created May 30, 2013 12:03
Filter PowerShell Output Width
# monkey path the built-in output system
filter Out-Default
{
$input |
Out-String -Width 500 -Stream |
Microsoft.PowerShell.Utility\out-default
}
@Iristyle
Iristyle / Ping-Redis.ps1
Created April 5, 2013 17:03
Powershell PING Redis
$client = New-Object Net.Sockets.TcpClient('localhost', 6379)
$stream = $client.GetStream()
$bytes = [Text.Encoding]::ASCII.GetBytes("PING`r`n")
$stream.Write($bytes, 0, $bytes.Length)
$buffer = New-Object byte[] 32
$read = $stream.Read($buffer, 0, 32)
$response = [Text.Encoding]::ASCII.GetChars($buffer) -join ''
Write-Host "Redis Response to PING: $response"
@Iristyle
Iristyle / Start-Vagrant.bat
Created March 15, 2013 18:35
Windows startup script to fire up a Vagrant VM safely on boot (using Run registry key for instance)
ECHO OFF
cd /d %~dp0
for /f "tokens=2* delims= " %%F IN ('vagrant status ^| find /I "default"') DO (SET "STATE=%%F%%G")
ECHO Close this window if it remains open, and http://localhost:8081 is responsive
IF "%STATE%" NEQ "saved" (
ECHO Starting Vagrant VM from powered down state...
vagrant up
) ELSE (
@Iristyle
Iristyle / gist:5005653
Created February 21, 2013 15:53
Configure HAProxy for userlists

Create SHA512 passwords

# make sure to use a leading space so that the command is not stored in your bash history!!
 mkpasswd -m sha-512 password1
# generates -> $6$yMgsow58.g/Z$mBjHfdVzqcF/LN.iwV23Eyqg.yGPTsp9pOwaStsJ6c4I4zL7BhucVVAkv5guf7OVRr8Pw0mHF4NrWBRCG5ci7/
 mkpasswd -m sha-512 password2
# generates -> $6$RZ86vRkQ$aRKN1HOsk6bDHBbMhS7jSo/p1NGFl4PvwY3KpU.72i./LvITi41nL84EkxOFXl.6Bmhynj/L7pYbfF0rUHtOB0