Skip to content

Instantly share code, notes, and snippets.

@khornberg
khornberg / gist:5971924
Created July 11, 2013 02:04
Extract bible book from well formed bible reference (e.g. John 1, 1 John 5:1-3, etc.)
public function get_bible_book( $text )
{
preg_match('/(^\w{1,3}\s)?\w+/', $text, $matches);
return $matches[0];
}
@khornberg
khornberg / index.html
Created July 26, 2013 16:44
Encrypt form fields on the client side before submission such as a password field. Just a concept.
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!-- Consider adding a manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
@khornberg
khornberg / roman.numerals.js
Created August 5, 2013 19:03
Converts roman numerals to arabic numerals and arabic numerals to roman numerals. Replaces roman numerals with arabic numerals.
/**
* Converts roman numerals to arabic numerals and arabic numerals to roman numerals.
* @author Daniel Wachsstock
* @internal Modified by khornberg
* @license MIT
* @link from http://bililite.com/blog/2009/03/09/roman-numerals-in-javascript/ Daniel's orginal post
*
*/
var romanNumerals = [
[1000, 'M'],
@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;
@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**
@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 / 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;
@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.

#!/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 / 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'