Skip to content

Instantly share code, notes, and snippets.

View jbfink's full-sized avatar
💭
we have statuses now? is this AOL?

John Fink jbfink

💭
we have statuses now? is this AOL?
View GitHub Profile
@quandyfactory
quandyfactory / rps.py
Created July 1, 2010 04:24
Simple command-line Rock, Paper, Scissors game.
#!/usr/bin/env python
"""
Simple command-line based Rock Paper Scissors game in Python.
"""
import random
vals = 'R P S'.split(' ')
msg_win = "You win this round."
msg_lose = "You lose this round."
msg_tie = "Tie! You both picked "
@quandyfactory
quandyfactory / hamont_election_results.py
Created October 27, 2010 16:20
Nasty hack to get city of #HamOnt election data into a usable format.
#!/usr/bin/env python
"""
Grabs election data from the City of Hamilton's GEMS election data pages, converts it into a json object and an sql insert statement.
Yeah, I know: the code is seriously ugly-ass and inelegant. What the hell, it works.
Update: The City changed their election results pages and this script no longer works. I'm working on updating it.
Very Important Note: this code breaks on ward 14, where Rob Pasuta is acclaimed and there are no ward results on the web page.
Instead of fixing it in the code, for now I just fixed the SQL statement manually by removing the trustees from the results.
@tritonrc
tritonrc / ldap_admin.rb
Created January 17, 2011 19:55
Simple Sinatra based LDAP admin tool
require 'rubygems'
require 'sinatra'
require 'net-ldap'
require 'digest/sha1'
require 'base64'
require 'haml'
LDAP_HOST = 'localhost'
ADMIN_DN = 'cn=admin,dc=company,dc=com'
@mludvig
mludvig / scan2pdf.sh
Created April 22, 2011 13:48
scan2pdf.sh - Linux command-line scan-to-pdf script
#!/bin/bash -e
## Put your sane-detected device name here.
#DEVICE="snapscan"
## For network scanners use
#DEVICE="net:sane.example.org:snapscan"
DEVICE='brother4:net1;dev0'
## See scanimage --device $(DEVICE) --help
SOURCES[0]="FlatBed"
@aemkei
aemkei / LICENSE.txt
Created November 2, 2011 19:27 — forked from 140bytes/LICENSE.txt
minesweeper - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@vmihailenco
vmihailenco / proxy.go
Created November 20, 2011 15:22
Simple TCP proxy in Golang
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"
@quandyfactory
quandyfactory / .vimrc
Created December 20, 2011 19:40
my nascent .vimrc file
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
@mislav
mislav / stupid-json.rb
Created December 21, 2011 12:31
Stupid simple JSON parser & generator
# encoding: utf-8
#
## Stupid small pure Ruby JSON parser & generator.
#
# Copyright © 2013 Mislav Marohnić
#
# 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
@quandyfactory
quandyfactory / pyloc.py
Created January 24, 2012 19:02
Returns total, nonblank and net lines of code for a Python script or a folder of python scripts.
#!/usr/bin/env python
# coding: utf-8
"""
Calculates total, nonblank and net lines of code for Python scripts.
"""
import os
import re
def get_line_count(blob):
@nherment
nherment / backup.sh
Created February 29, 2012 10:42
Backup and restore an Elastic search index (shamelessly copied from http://tech.superhappykittymeow.com/?p=296)
#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`