Skip to content

Instantly share code, notes, and snippets.

View jgoodall's full-sized avatar

John Goodall jgoodall

View GitHub Profile
@jgoodall
jgoodall / README.md
Last active September 19, 2023 18:06
This is a sample of how to send some information to logstash via the TCP input from node.js or python.

This is a sample of how to send some information to logstash via the TCP input in nodejs or python. It assumes the logstash host is on 10.10.10.100 and the TCP listening input is 9563.

The logstash.conf should look something like the sample file.

The log message should be a stringified JSON object with the log message in the @message field.

To use, run the node script node sendMessageToLogstash.js, or the python script python sendMessageToLogstash.js

@jgoodall
jgoodall / redis-pub.js
Last active December 11, 2015 17:49
redis pub sub in node (using [redis module](https://github.com/mranney/node_redis))
var redis = require('redis')
, rc = redis.createClient()
for (var i = 0; i < 10; i++) {
var msg = 'message ' + i
console.log('publishing message: ' + msg)
rc.publish('test', msg)
}
@jgoodall
jgoodall / updates.sh
Last active December 10, 2015 19:48
update software packages installed in user space
#!/bin/sh
# update software packages installed in user space
# update homebrew
brew update
brew outdated
brew upgrade
# update global node modules
@jgoodall
jgoodall / calendar.sh
Created November 12, 2012 18:35
shell script to print a calendar to the screen, highlighting today (geektool)
#!/bin/sh
# useful for [geektool](http://projects.tynsoe.org/en/geektool/)
#
# colorcal - change current day and date via ANSI color escape sequences
# see http://www.termsys.demon.co.uk/vtansi.htm for color codes.
color="\033[1;33m"
underline="\033[4m"
reset="\033[0m"
@jgoodall
jgoodall / things.sh
Created November 12, 2012 18:33
shell script to print things tasks to the screen (geektool)
#!/bin/bash
# useful for [geektool](http://projects.tynsoe.org/en/geektool/)
# jg: made lib_dir generic
# Title: Things Extract Script for GeekTool
# Author: Alex Wasserman
# Description: Extracts the currents items from Things database, stores in a temp file. Outputs tmp file if Things DB is locked in use.
# Things SQL Library
export SQL_LIBRARY="ThingsLibrary.db"
@jgoodall
jgoodall / memoryusage.sh
Created November 12, 2012 18:31
shell script to print memory usage to the screen (geektool)
#!/bin/sh
# useful for [geektool](http://projects.tynsoe.org/en/geektool/)
/usr/bin/vm_stat | sed 's/\.//' | awk '
/free/ {FREE_BLOCKS = $3}
/inactive/ {INACTIVE_BLOCKS = $3}
/speculative/ {SPECULATIVE_BLOCKS = $3}
/wired/ {WIRED_BLOCKS = $4}
END {
@jgoodall
jgoodall / pre-commit.sh
Created October 26, 2012 12:39
A git pre-commit hook for node.js projects to lint js files, run tests, and build docs
#!/bin/sh
#
# A git pre-commit hook for node.js projects to
# * lint JavaScript files with [jshint](https://github.com/jshint/jshint/)
# * run [mocha](http://visionmedia.github.com/mocha/) tests from npm, as defined in package.json
# * build docs (e.g. using docco or markdox), as defined in package.json
#
# package.json should have a scripts block that defines how to run tests and build docs:
# "scripts" : {
# "test": "./node_modules/mocha/bin/mocha -R spec"
@jgoodall
jgoodall / setup_git.sh
Created July 27, 2012 13:51
Setup git and configure apache
#!/bin/sh
# Define your LDAP URL
#LDAP_URL=ldaps...
GIT_DIR=/var/lib/git
APACHE_CONFIG_FILE=/etc/httpd/conf.d/git.conf
if [ `whoami` != "root" ]; then
echo "You must run this script as root (sudo $0)"
exit 1
@jgoodall
jgoodall / post-receive-hook.sh
Created July 18, 2012 15:18
git post-receive hook for sending notifications to notifo
#!/bin/sh
#
# Send git commit notifications to [notifo](http://notifo.com/)
# read the commands from stdin in the git hook
read oldrev newrev refname
# name of the repository
REPO="GIT REPOSITORY NAME"
@jgoodall
jgoodall / notifo.sh
Created July 18, 2012 14:39
send message to notifo service from shell
#!/bin/bash
# Send messages to [notifo](http://notifo.com/)
# the message is passed from the command line
if [ $# -lt 1 ]; then
echo "Usage: " $0 "'the message to send'"
exit 1
else
message=$1
fi