Skip to content

Instantly share code, notes, and snippets.

View kisom's full-sized avatar

Kyle Isom kisom

View GitHub Profile
@kisom
kisom / gist:858808
Created March 7, 2011 17:09
get datetime.datetime object from str(datetime.datetime)
def get_datetime(timestamp):
"""
Returns a datetime object from str(datetime.datetime).
"""
ctor = []
timestamp = timestamp.split()
date = [ int(i) for i in timestamp[0].split('-') ]
time = [ int(i) for i in timestamp[1].replace('.', ':').split(':') ]
@kisom
kisom / ex
Created May 28, 2011 02:00
exercise 3.3 for saolsen
(* corrections for saolsen *)
(* Exercise 3.3 *)
let rec sum n m f =
if n = m then
f m
else
f n + sum ((n + 1) m f);;
let g x = x * x;;
sum 2 4 g;;
@kisom
kisom / quine.py
Created July 5, 2011 23:26
the most badass quine you will ever see
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: kyle isom
# license: ISC / public domain dual-license
#
# quine: a program that prints itself
import urllib2
remote = 'http://www.kyleisom.net/quine.py.txt'
@kisom
kisom / distcp.sh
Created September 7, 2011 18:07
a simple POSIX shell script to read a MANIFEST and copy it to another dir
#!/bin/sh
# simple shell script to read a manifest file and copy the files in the
# manifest to another dir, i.e. to build a distribution
if [ "$1" -a "$2" ]; then
MANIFEST=$1
DESTDIR=$2
else
echo "usage: distcp.sh MANIFEST DESTDIR"
echo " MANIFEST should be a file containing files to DESTDIR"
@kisom
kisom / configfile.c
Created September 18, 2011 17:19
C function to split a buffer into a char ** containing each line.
/*
* written by kyle isom <[email protected]>
* license: isc / public domain dual license
* one of the functions i wrote for the lurker project
* (https://github.com/kisom/lurker) project
*
* from twitter (@kyleisom):
* '"so a char * goes to a char ** where each char * in the char ** is a line
* in the first char *" - me explaining my C algorithm to @qb1t'
*/
@kisom
kisom / configfile.c
Created September 19, 2011 11:15
C function to strip leading and trailing whitespace from a line of text
/*
* written by kyle isom <[email protected]>
* license: isc / public domain dual license
* one of the functions i wrote for the lurker project
* (https://github.com/kisom/lurker)
*
* C function to strip leading and trailing whitespace
* from a string
* added as a gist because I am not near a compiler or editor and want to commit
* my notes to memory
@kisom
kisom / configfile.c
Created September 20, 2011 15:01
C function to split a line into cmd, val
/*
* written by kyle isom <[email protected]>
* license: isc / public domain dual license
* one of the functions i wrote for the lurker project
* (https://github.com/kisom/lurker)
*
* C function to split a line into command and value
*/
/*
@kisom
kisom / configile.c
Created September 20, 2011 18:29
C function to parse a simple "command: value" line into command and value
/*
* written by kyle isom <[email protected]>
* license: isc / public domain dual license
* one of the functions i wrote for the lurker project
* (https://github.com/kisom/lurker)
*
* C function to split a line into command and value
*/
/*
@kisom
kisom / kyle.json
Created October 3, 2011 08:30
my json template for hackerhub
{
"settings" : {
"id" : "kyle",
"name" : "kyle isom",
"avatar" : "http://is.gd/JZ3Pcw?s=200",
"disqus_shortname" : "kisom",
"enable_search" : true
},
"content" : {
"$ whoami" : {
@kisom
kisom / hhup.py
Created October 3, 2011 12:01
update hackerhub profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: kyle isom <[email protected]>
# license: isc / public domain dual-license
#
# automate updates to hackerhub
"""
Automate updates to hackerhub. Validates a local JSON profile, sftp's it to
a server, and notifies hackerhub to update the profile.
"""