Skip to content

Instantly share code, notes, and snippets.

View crankycoder's full-sized avatar

Victor Ng crankycoder

View GitHub Profile
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-- Original grok filters
-- POSINT \b(?:[0-9]+)\b
-- GREEDYDATA .*
-- HOUR (?:2[0123]|[01][0-9])
-- MINUTE (?:[0-5][0-9])
-- SECOND (?:(?:[0-5][0-9]|60)(?:[.,][0-9]+)?)
@crankycoder
crankycoder / gist:7606664
Created November 22, 2013 20:51
netsyslog.py example
#!/usr/bin/python
import socket
import time
FACILITY = {
'kern': 0, 'user': 1, 'mail': 2, 'daemon': 3,
'auth': 4, 'syslog': 5, 'lpr': 6, 'news': 7,
'uucp': 8, 'cron': 9, 'authpriv': 10, 'ftp': 11,
'local0': 16, 'local1': 17, 'local2': 18, 'local3': 19,
@crankycoder
crankycoder / gist:6302667
Last active December 21, 2015 11:59
Ubuntu Discourse install docs

Official Discourse Install Guide

Recommended Server Hardware

  • 2 GB of RAM
  • 2 GB of swap
  • 2 processor cores

With 2 GB of memory and dual cores, you can run two instances of the thin server (NUM_WEBS=2), and easily host anything but the largest of forums.

@crankycoder
crankycoder / gist:6181211
Last active December 20, 2015 19:09 — forked from surrealroad/gist:5146661
Digital Ocean Discourse production install with LAMP (using Apache)
#create & deploy lamp droplet
#login via ssh as root
#initial setup (ref: http://library.linode.com/getting-started#sph_logging-in-for-the-first-time)
# update /etc/hosts (to "thalassophobia.surrealroad.com")
nano /etc/hosts
#
@crankycoder
crankycoder / gist:5859517
Created June 25, 2013 15:41
When using the go1.1.1 release binary, the Lua sandbox tests fail. This is due to bug https://code.google.com/p/go/issues/detail?id=5726 Patching the Heka Makefile to use the internal linker will reliably reproduce the error.
diff --git a/Makefile b/Makefile
index 0496238..18c68b2 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ build/go:
$(GOBIN): build/go
cd build/go/src && \
- PATH="$(BIN):$(HERE)/pythonVE/bin:$(PATH)" ./all.bash
+ GO_EXTLINK_ENABLED=0 PATH="$(BIN):$(HERE)/pythonVE/bin:$(PATH)" ./all.bash
@crankycoder
crankycoder / gist:5554897
Created May 10, 2013 14:52
monitor the existence of a file
import time
def check_file(filename):
try:
with open(filename): pass
return True
except IOError:
return False
def monitor_file():
@crankycoder
crankycoder / es.sh
Last active December 16, 2015 09:28
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.6.deb
sudo dpkg -i elasticsearch-0.20.6.deb
#!/bin/bash
# node.js using PPA (for statsd)
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
# Install git to get statsd
sudo apt-get install git
@crankycoder
crankycoder / bash
Created April 9, 2012 16:51 — forked from haf/bash
Installing graphite Ubuntu 11.10
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get upgrade
@crankycoder
crankycoder / gist:1827731
Created February 14, 2012 15:56
Jython code to generation DSA/RSA keys
"""
Simple stupid utility to create RSA or DSA key keys
Just add the JSCH library to your classpath and things ought to work.
(JY25)~/Downloads > export CLASSPATH=./jsch-0.1.42.jar
(JY25)~/Downloads > jython
*sys-package-mgr*: processing new jar, '/Users/victorng/Downloads/jsch-0.1.42.jar'
Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_29