Skip to content

Instantly share code, notes, and snippets.

View chrisshroba's full-sized avatar

Christopher Shroba chrisshroba

View GitHub Profile
@chrisshroba
chrisshroba / clearscrollback.sh
Last active March 10, 2016 15:40
Function to clear all iTerm scrollback history
# Clears all iTerm scrollback
# Useful to run before commands with long output
# (simply scroll to top to find beginning of output)
c () {
echo "\033]50;ClearScrollback\x7"
}
@chrisshroba
chrisshroba / pseudocode.py
Created March 7, 2016 01:32
473 Homework 5 #1a Pseudocode
GetKSamples(stream S, int k):
samples = list of length k // samples is the list we'll return
for i gets 1...k:
samples[i] = next item in S // Add the first five items in the
// stream to samples
l <- k // Count of things seen so far
while S is not done
x <- next item in S
l <- l+1 // Increment count
if Random(l) <= k // With 5/l probability...
#!/usr/bin/env bash
COLUMNS=$(tput cols)
for i in $(seq 1 $((COLUMNS - 2)))
do
echo -ne "\033[2K\r"
echo -n "["
yes = | head -n $i | tr -d "\n"
if [ $((COLUMNS - 2 - i)) != 0 ]
then
yes " " | head -n $((COLUMNS - 2 - i)) | tr -d "\n"
#!/usr/bin/env bash
COLUMNS=$(tput cols)
echo $COLUMNS
for i in $(seq 0 $((COLUMNS - 2)))
do
echo -ne "\033[2K\r"
echo -n "["
yes = | head -n $i | tr -d "\n"
if [ $((COLUMNS - 2 - i)) != 0 ]
then
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);