Skip to content

Instantly share code, notes, and snippets.

@khornberg
khornberg / lexer.py
Last active December 19, 2018 20:52
Boolean expression matching
from ply import lex
class BooleanMatchError(Exception):
pass
reserved = {'AND': 'AND', 'OR': 'OR'}
math_tokens = [
import Ember from 'ember';
import { schema } from '../models/user';
import Validations from '../validations/user';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
Validations,
changesets: {},
allValid(changeArray) {
@khornberg
khornberg / controllers.application.js
Last active May 30, 2017 13:54
multiple changesets per page
import Ember from 'ember';
import { schema } from '../models/user';
import Validations from '../validations/user';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
Validations,
changesets: {},
allValid(changeArray) {
@khornberg
khornberg / meta.py
Last active May 18, 2016 19:57
Python subclass determined at runtime
# Based on http://python-3-patterns-idioms-test.readthedocs.io/en/latest/Metaprogramming.html
class P1(object):
name = 'Parent1'
class P2(object):
name = 'Parent2'
#!/bin/bash
# Redefined the docker command to connect if the shell has not already
# done so. This speeds up the shell start up.
docker() {
if [ "$DOCKER_HOST" = "" ]; then
# Setup docker
if [ -x /usr/local/bin/docker-machine ]; then
# suppress standard out
eval "docker-machine env default --shell=bash >/dev/null"
@khornberg
khornberg / README.md
Created November 25, 2014 22:57
Attempt to read gzip files in logstash

This attempt has thus failed to allow Logstash to read gzipped files. It is based off of the line codec.

I think it is because of the way Logstash buffers the input stream. It seems that a delimiter is required that will not be there in the gzipped files.

The spec file gzip_spec.rb passes with out issue.

The trouble starts when I run bin/logstash agent -f gzip.conf --debug. Either I get not output or I get Error: Unexpected end of ZLIB input stream on larger files.

One can reproduce the nothing error by creating a file with echo "hello world" | gzip > file.gz and running the gzip.conf. One can reproduce the end of ZLIB input stream error by creating a gzipped file of the logstash README.md.

@khornberg
khornberg / gitlist.desktop
Created February 4, 2014 04:16
gitlist launcher for Ubuntu
[Desktop Entry]
Version=0.1
Name=GitList
Comment=An elegant and modern git repository viewer
Exec=/usr/local/bin/gitlist.sh
Icon=/opt/gitlist/web/img/favicon.png
Terminal=true
Type=Application
Categories=Utility;Application;
@font-face {
font-family: 'octiconsregular';
src: url('octicons-regular-webfont.eot');
src: url('octicons-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('octicons-regular-webfont.woff') format('woff'),
url('octicons-regular-webfont.svg#octiconsregular') format('svg');
font-weight: normal;
font-style: normal;
}
.octicon {
@khornberg
khornberg / convert-readme.sh
Created January 14, 2014 18:04
Convert markdown file to WordPress readme format.
#! /bin/bash
# Script to convert markdown file to WordPress readme format
# @author Kyle Hornberg
# @date 2014-01-14
#
# Changes
# # Header 1 -> === Header 1 ===
# ## Header 2 -> == Header 2 ==
# ### Header 3 -> = Header 3 =
# #### Header 4 -> **Header 4**
@khornberg
khornberg / circles.html
Created October 22, 2013 19:28
Circles at the top of a page
<!DOCTYPE html>
<html>
<body>
<canvas id="topCanvas" height="500px" width="500px">Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c=document.getElementById('topCanvas');
var colors = ['#00cdff', '#123abc', '#36590', '#fedcba'];
var circles = 5;