Skip to content

Instantly share code, notes, and snippets.

View meonkeys's full-sized avatar

Adam Monsen meonkeys

View GitHub Profile
@meonkeys
meonkeys / C1.java
Last active December 15, 2015 16:29
Example of a protected member in Java.
class C1 extends P1 {
}
class Node(object):
def __init__(self):
children = []
def flush(self):
tmp = self.children
self.children = None
for kid in tmp:
kid.flush()
#!/usr/bin/python
# .- coding: utf-8 -.
#
# irssi_log_merge.py.
# Written by Lasse Karstensen <[email protected]>, 2008.
# Released under GPLv2.
#
# Newest version available on http://hyse.org/irssi-log-merge/ .
#
# Modified by Florian Rathgeber <[email protected]>
@meonkeys
meonkeys / ram_backed_mysql.sh
Created March 11, 2013 16:27
Script to automatically control a MySQL instance with an in-memory datadir.
#!/bin/bash
set -o errexit
# Script to automatically control a MySQL instance with an in-memory datadir.
#
# Requires:
# * Bash shell
# * recent mysql installed into BASEDIR
# I used "mysql-5.1.47-linux-x86_64-icc-glibc23"
# see: http://thread.gmane.org/gmane.comp.finance.mifos.devel/8684
@meonkeys
meonkeys / my.ini
Created March 11, 2013 16:24
RAM-backed MySQL configuration file
# see http://thread.gmane.org/gmane.comp.finance.mifos.devel/8684
# - replace occurrences of PATHx, below
# - replace occurrences of USER, below (with your username)
[client]
port = 3307
socket = /PATH1/mysqld.sock
[mysqld]
user = USER
def greatest(x,maxx=float("-inf")):
if len(x)>0:
if x[0] > maxx: maxx=x[0]
return greatest(x[1:],maxx)
else:
return maxx
print greatest([1,5,3,7,4,5,9,10,2,5,6,2]) #prints 10
# Timeout based
lockfile=/var/run/script.lock
(
flock --timeout 60 200 || ( echo "UNKNOWN: Lock failed"; exit 3)
stuff;
) 200>${lockfile}
# Only allow one at a time
lockfile=/var/run/script.lock
require 'octokit'
require 'csv'
require 'date'
# Description:
# Exports Github issues from one or more repos into CSV file formatted for import into JIRA
# Note: By default, all Github comments will be assigned to the JIRA admin, appended with
# a note indicating the Github user who added the comment (since you may not have JIRA users
# created for all your Github users, especially if it is a public/open-source project:
#
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@meonkeys
meonkeys / dumbo.md
Last active December 14, 2015 01:49
MapReduce example with Dumbo

Process log lines. Return count of log lines per hostname with 'invalid user' in the log message.

input

localhost: restarting
dsl5.example.com: invalid user 'bart'
dsl5.example.com: invalid user 'charlie'
dsl5.example.com: invalid user 'david'
dsl8.example.net: invalid password for user 'admin'