This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Only split on newlines, so each line of data is one record. | |
default_IFS=$IFS | |
IFS="$(echo -e "\n\r")" | |
# each $line will be one line, even if there are spaces in it. | |
for line in $(cat sample_data.txt) ; do | |
# do stuff... | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
altscreen on | |
termcap * OP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function stacktrace() { | |
frame=0 | |
while caller $frame ; do frame=$((frame + 1)) ; done | |
} | |
function lib_inner() { | |
stacktrace | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Report on modules that failed to install. | |
# | |
# Look for various "FAIL" messages in the cpanm build.log files. | |
# (FIXME: Explain the difference, and what they mean.) | |
# Parse out the module names and report any that are not installed. | |
logs=$HOME/.cpanm/work/*/build.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@LIST = (path="", model=null, opts={}) -> | |
opts.model = model if model | |
Backbone.Collection.extend $.extend opts, | |
parse: ({data}) -> data | |
comparator: (item) -> | |
compare_item(item) | |
url: API path | |
@REVERSE_LIST = (path="", model=null, opts={}) -> | |
list = @LIST(path, model, opts) | |
$.extend list, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(cheat_sheet_ipc). | |
-export([init/0, incr/1, decr/1, current/0]). % not loop/0 | |
%% Define a constant. | |
-define(SVC_NAME, counter_service). % atom, not Variable or string | |
%% Start a new process to manage our counter. | |
init() -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Char | |
import System.IO | |
readFirstLine = withFile "test.txt" ReadMode (\handle -> do | |
line <- hGetLine handle | |
return line) | |
readAndPrintTestFile = withFile "test.txt" ReadMode (\handle -> do | |
contents <- hGetContents handle | |
-- unless we output contents in some way, it isn't evaluated, and will be empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
from collections import defaultdict | |
import pprint | |
import sqlite3 | |
import sys | |
ADDRESS_DB_FILE = 'Contacts-2016-01-23.abbu/AddressBook-v22.abcddb' | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -w | |
require 'find' | |
require 'md5' | |
dir = ARGV[0] | |
dir = "." unless dir | |
digests = {} | |
Find.find( dir ) do |f| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set up ssh-agent | |
SSH_ENV="$HOME/.ssh/environment" | |
function start_agent { | |
echo "Initializing new SSH agent..." | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" | |
echo succeeded | |
chmod 600 "${SSH_ENV}" | |
. "${SSH_ENV}" > /dev/null | |
/usr/bin/ssh-add; |