Skip to content

Instantly share code, notes, and snippets.

/*
* Copyright (c) 2020-2021 Trevor Caira
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
@trevorc
trevorc / keybase.md
Created May 14, 2018 20:01
Keybase proof

Keybase proof

I hereby claim:

  • I am trevorc on github.
  • I am toc (https://keybase.io/toc) on keybase.
  • I have a public key ASBMnVMcKtYb0Z1Q7WqbxqLRANTY5lPzmZqDjiCZiE1y8Ao

To claim this, I am signing this object:

@trevorc
trevorc / ping_server.sh
Created October 26, 2017 16:03
Find closest server
#!/bin/sh
set -eu
count=$1
server=$2
latency=$(ping -nqc${count} ${server} |
sed -nE 's,^round[^=]*=[^/]*/([[:digit:]]+\.[[:digit:]]+).*,\1,p')
echo "${latency} ${server}"
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;
{-# LANGUAGE TupleSections #-}
module RPN (main) where
import Control.Applicative ((<$>))
import Control.Monad (forM_, unless)
import Control.Monad.Instances ()
import Data.List (find, intercalate)
import Data.Maybe (listToMaybe)
import System.IO (stdout, hFlush)
@trevorc
trevorc / init.el
Last active October 6, 2015 14:08
;;;;;;;;;;;;;;;;;;;;
;; Initialization ;;
;;;;;;;;;;;;;;;;;;;;
(require 'cl)
(defmacro* dolist* ((iterator list &optional return-value) &rest body)
"Like `dolist' but `destructuring-bind's the elements of LIST.
If ITERATOR is a symbol then dolist* is just like `dolist' except
set autowriteall
set backspace=indent,eol,start
set cinoptions=Ws,(0,t0
set directory=~/.config/vim/swap,/tmp
set encoding=utf-8
set expandtab
set formatoptions=q
set hidden
set hlsearch
set incsearch
@trevorc
trevorc / gist:2341940
Created April 9, 2012 06:27
emacs startup script
#!/bin/sh
app=/Applications/Emacs.app/Contents/MacOS/Emacs
for arg; do
case $arg in
-version|--version|-f|-l|-eval|-batch|-nw) exec $app "$@"
esac
done
@trevorc
trevorc / htpinstaller.sh
Created April 5, 2012 06:00
How To Program ubuntu installer
#!/bin/sh
set -eu
DISTRIBUTE_SETUP=https://raw.github.com/gist/2308340/d2c2899afa9894be579f48a7a6d4193e84a55b6b/distribute_setup.py
sudo -k
which easy_install &> /dev/null || wget -qO- $DISTRIBUTE_SETUP | sudo python
sudo easy_install django
sudo easy_install dotcloud
@trevorc
trevorc / distribute_setup.py
Created April 5, 2012 05:59
distribute setup
#!python
"""Bootstrap distribute installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from distribute_setup import use_setuptools
use_setuptools()
If you want to require a specific version of setuptools, set a download