Skip to content

Instantly share code, notes, and snippets.

View kisom's full-sized avatar

Kyle Isom kisom

View GitHub Profile
@kisom
kisom / gist:1360224
Created November 12, 2011 08:03
Test for the weekend using C-style time constructs in Python
import time
def is_weekend(date, date_is_timestamp=False, format='%Y-%m-%d'):
"""
Check to see if a date falls on a weekend.
You can pass in date as a string. By default, is_weekend expects to see
a date in the format YYYY-mm-dd (ex. 2011-11-10). You can change this
using the strftime(3) format specifiers and passing the format in the
'format' argument.
@kisom
kisom / sup.sh
Created November 24, 2011 19:38
A very primitive shell script process monitor.
#!/bin/sh
# sup.sh
# author: kyle isom <coder@kyleisom.net>
#
# *extremely* primitive supervisor to ensure a daemon runs and stays running
# use it with crontab.
#
# this is an external supervisor to accompany the monitor python module I wrote
# that gets used in the code that's running.
# see https://github.com/kisom/pymods/blob/master/monitor.py
@kisom
kisom / initialise-new.el
Created November 28, 2011 15:20
emacs setup script
;;; emacs lisp file to set up kyle's emacs
;;; install package.el
(let ((buffer (url-retrieve-synchronously
"http://tromey.com/elpa/package-install.el")))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
@kisom
kisom / imgur.py
Created December 2, 2011 08:51
imgur album downloader
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# author: kyle isom <coder@kyleisom.net>
# license: isc / public domain dual-license
# see (http://www.brokenlcd.net/standard-license.txt)
#
"""
This is a module (with a main() function) to grab a list of image links in
an imgur album. The main() function demonstrates how to use that to
@kisom
kisom / book
Created December 4, 2011 15:23
quickly sort my oreilly downloads
#!/bin/sh
# 2011-12-04 kyle isom <coder@kyleisom.net>
# designed to quickly move all mah oreilly downloads to a folder where i
# can sort them
# assumptions:
# the only epubs are from o'reilly
# i download several formats for each book (pdf, epub, mobi)
# my main ebook library is organised by topic/.../title/title.*
@kisom
kisom / build-image.lisp
Created January 1, 2012 20:33
automatically generate a quicklisp-enhanced sbcl image
#!/usr/bin/env sbcl --script
;;;; build-image.lisp
;;;; build a customised sbcl image
;;;;
;;;; you can modify the package list by changing the *base-packages*
;;;; global variable. this is useful for building a custom binary with
;;;; your commonly used libraries already present (at the expense of
;;;; some memory) but will cut down on load times.
@kisom
kisom / validjson.py
Created January 21, 2012 18:39
validate json
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: kyle isom <coder@kyleisom.net>
# license: isc / public domain dual-license
#
# i have this saved to ~/bin/validjson
"""
Quickly check whether a JSON file is valid or not.
"""
@kisom
kisom / crypto.f95
Created January 22, 2012 19:34
CS260 (Fortran) final project... for teh lulz
! dug up this old thing from an old college class... i had a few good chuckles
!--------------------------------------------------------------------------
! TITLE: CSCI260 Final Project
! AUTHORS:
! * kisom
! * Chris
! * Laura
!
! CLASS: CSCI260A
@kisom
kisom / sha256-test.clj
Created January 29, 2012 10:47
SHA-256 hashing in Clojure via Java interop
;; test suite to go with hashing code
(ns user.test.sha256
(:use [clojure.test]
[clojure.string :only [join]]
[user.hash]))
(def sha256-test-vectors
#^{:doc "test vectors from the NESSIE project (http://is.gd/jdM99e)"}
[{ :message ""
:expected "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
@kisom
kisom / tsrv.py
Created February 7, 2012 18:13
Simple server to test sockets.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: kyle isom <coder@kyleisom.net>
# license: ISC / public domain
"""
Simple server to test sockets.
"""
import argparse
import os