Skip to content

Instantly share code, notes, and snippets.

View tmlbl's full-sized avatar

Tim tmlbl

View GitHub Profile
@tmlbl
tmlbl / bank.sh
Created June 1, 2016 07:51
A quick bash script to encrypt a directory with a passkey.
#!/bin/bash
BANK_DIR=$HOME/.bank
mkdir -p $BANK_DIR;
if [ "$1" = "lock" ]; then
if [ -e $BANK_DIR.tar.gz.gpg ]; then
echo "$BANK_DIR already locked.";
exit 1;
@tmlbl
tmlbl / meetup.jl
Last active October 27, 2015 01:07
Script to find Julia developers in your area using the GitHub API
using HTTPClient: HTTPC
using JSON
# Fill in your city name and GitHub API token
const MEETUP_LOCATION = lowercase("Seattle")
const API_TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Pages of search results to examine. Warning - you WILL hit the rate limit
const NUM_PAGES = 1
typealias Field Union{AbstractString,Void}
@tmlbl
tmlbl / jvm
Last active March 20, 2016 06:19
JVM - Julia Version Manager
#!/bin/bash
# I keep Julia binaries in /opt/julia with the same directory structure
# as ~/.julia to store different versions, and use this script to switch
# between them. I also like to maintain a link of the ~/.julia folder to
# ~/julia, for easier package development.
JBIN=""
PDIR=""
@tmlbl
tmlbl / macro.jl
Last active August 29, 2015 14:22
Macro problems
macro stringall(msg...)
return :(join(map((i) -> string(eval(i)), $msg), " "))
end
x = "foo"
function test()
x = "bar"
global y = "baz"
@stringall x y
@tmlbl
tmlbl / Colors.jl
Created June 1, 2015 17:11
Symbol dict example
const text_colors = AnyDict(
:black => "\033[1m\033[30m",
:red => "\033[1m\033[31m",
:green => "\033[1m\033[32m",
:yellow => "\033[1m\033[33m",
:blue => "\033[1m\033[34m",
:magenta => "\033[1m\033[35m",
:cyan => "\033[1m\033[36m",
:white => "\033[1m\033[37m",
:normal => "\033[0m",
@tmlbl
tmlbl / typed.ts
Created April 21, 2015 23:00
Typed Class
class Typed<T> {
type: T
constructor(obj: T) {
this.type = obj;
}
}
interface MyType {
prop: string;
@tmlbl
tmlbl / roach.go
Created March 19, 2015 20:34
Trying to use cockroachdb
package main
import (
"fmt"
"net/http"
"time"
"github.com/cockroachdb/cockroach/client"
"github.com/cockroachdb/cockroach/proto"
)
@tmlbl
tmlbl / yesno.sh
Last active August 29, 2015 14:16
A "Standard Library"-Style Function for Bash
#!/bin/bash
# Asks the user a yes or no question, returning the boolean result
# $1: Message message to print
# $2: Default answer (defaults to "no" (1))
std_askyesno() {
local CONF="y/N"
if [[ $2 == 0 ]]; then local CONF="Y/n"; fi
local reply="n"
read -p "$1 $CONF " -n 1 -r reply
@tmlbl
tmlbl / testexec.sh
Created February 26, 2015 17:42
Bash script to check for required executables
#!/bin/bash
test_exec() {
echo -e "Checking for command: \e[34m$1\e[0m"
EX=$(which $1)
if [[ ! "$EX" ]]; then
echo -e "\e[31mUh oh! It looks like you need to install $1:"
echo -e "$2\e[0m"
exit 1
else
@tmlbl
tmlbl / Qstring.jl
Last active August 29, 2015 14:16
Basic query string encoder in Julia
using HttpCommon
using Dates
# Creating a query string that will encode unix datetimes
# given Julia DateTimes. Methods to handle more types could
# easily be added.
function qstring(kv::Tuple...)
encodeval(v::String) = encodeURI(v)
encodeval(dt::DateTime) = string(int64(datetime2unix(dt)))
encodepair(p::Tuple) = string(encodeval(p[1]), "=", encodeval(p[2]), "&")