Skip to content

Instantly share code, notes, and snippets.

View kkirsche's full-sized avatar

Kevin Kirsche kkirsche

View GitHub Profile
@kkirsche
kkirsche / american_flag.exs
Created July 13, 2015 23:07
Print American Flag
defmodule Recursion do
require Integer
# Recursion for star rows
def print_star_row_pair_n_minus_1_times(n) when n <= 1 do
print_row AmericanFlag.star_row(IO.ANSI.white_background)
end
def print_star_row_pair_n_minus_1_times(n) do
print_row AmericanFlag.star_row(IO.ANSI.white_background)
print_row AmericanFlag.star_row(IO.ANSI.red_background)
@kkirsche
kkirsche / config.json
Created July 27, 2015 13:47
Fixed config.json for twbs#16893
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@kkirsche
kkirsche / TCPDumpDataToFile.sh
Created October 16, 2015 12:44
Use TCP dump to output data to stdout and file
tcpdump -s0 -AX | tee -a filename.extension
let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(forecastAPIKey)/")
let forecastURL = NSURL(string: "60.7142,-80.0064", relativeToURL: baseURL)
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: configuration)
let request = NSURLRequest(URL: forecastURL!)
let dataTask = session.dataTaskWithRequest(request, completionHandler: {
(data: NSData?, response: NSURLResponse?, error: NSError?) -> Void in
print(data!)
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg {
font: 10px sans-serif;
}
.area {
fill: steelblue;
@kkirsche
kkirsche / Create and Setup new Laravel 4 Project.md
Last active December 18, 2015 02:48
Create and Setup new Laravel 4 Project

Install Laravel 4

To install Laravel 4 we will take advantage of composer's create-project ability. We can do this in the following manner:

    composer create-project laravel/laravel LocalDirectoryName

This will install the Laravel project. Where I have put LocalDirectoryName, you can specify the folder name that you would like laravel installed to within the directory.

@kkirsche
kkirsche / Solarized iTerm3 Profile
Created February 22, 2016 18:22
iTerm3 Profile
{
"Badge Text" : "",
"Working Directory" : "\/Users\/<username>",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Green Component" : 0.8900123,
"Blue Component" : 0.7978109,
"Red Component" : 0.9161106
},
"Rows" : 25,
@kkirsche
kkirsche / Brewfile
Last active April 1, 2016 00:36
Mac Brewfile
# Brewfile
# Relies on: brew tap Homebrew/bundle
# https://github.com/Homebrew/homebrew-bundle
cask_args appdir: '/Applications'
# Taps
tap "caskroom/cask"
# Brews
brew "ansible"
brew "ansible-cmdb"
brew "cask"
@kkirsche
kkirsche / tracer.go
Created May 26, 2016 17:40
Golang URL Tracer
package main
import (
"log"
"net/http"
"time"
)
// TransportWrapper wraps the http.Transport structure to allow us to record the
// URLs which we are redirected through
@kkirsche
kkirsche / fileserver.py
Created July 18, 2016 15:49 — forked from vgel/fileserver.py
A very basic HTTP file server in 13 lines of python. Assumes all requests are GETs, and it vulnerable to directory traversal (Run it in ~ and localhost:8080/../../ will ls root), so don't use it online. Will correctly list files in directories.
import sys, os, socket
s = socket.socket()
s.bind((sys.argv[1], int(sys.argv[2])))
s.listen(5)
try:
while True:
conn, addr = s.accept()
path = os.path.join(os.getcwd(), "./"+conn.recv(4096).split("\n")[0].split(" ")[1])
conn.send((open(path).read() if os.path.isfile(path) else reduce(lambda x,s:x+"\n"+s+("/" if os.path.isdir(s) else ""),sorted(os.listdir(path)),"Directory "+path+" ls")) if os.path.exists(path) else '404: '+path)
conn.close()