Skip to content

Instantly share code, notes, and snippets.

View johanek's full-sized avatar

Johan van den Dorpe johanek

View GitHub Profile
@johanek
johanek / gist:2508733
Created April 27, 2012 12:18
CentOS 6 graphite
yum install -y pycairo mod_python Django python-ldap python-memcached python-sqlite2 \
bitmap bitmap-fonts python-devel python-crypto pyOpenSSL zope gcc django-taggin
yum install python-Twisted <- fpm build
yum install pythin-pip <- fpm
test:
yum install python-carbon python-whisper python-graphite-conf
cd /opt/graphite/conf
@johanek
johanek / gist:2627357
Created May 7, 2012 11:41
idea for cron manager
What do I want to do?
- Managed cronjobs via Version Control
- Get better reporting on the jobs
- Not get spammed by cron emails
What do I want to know about cronjobs?
- Did the command fail?
- Did the command actually run?
@johanek
johanek / readme_on_cd
Created December 17, 2012 15:10
display README when changing directory
tcsh:
alias cwdcmd "if (-e README) cat README fi"
bash:
PROMPT_COMMAND="[[ -e README ]] && cat README"
@johanek
johanek / sample-init.sh
Last active December 11, 2015 08:29
Generic init script
#!/bin/sh
#
# MYNAME DESCRIPTION
#
# chkconfig: 345 95 5
# description: DESCRIPTION
#
### BEGIN INIT INFO
# Provides: NAME
@johanek
johanek / build-gems.sh
Created April 22, 2013 08:29
build-gems.sh
#!/bin/bash
FPM=/usr/bin/fpm
if [ ! -d BUILD ]
then
mkdir -p BUILD
fi
for gem in `cat gem-list | grep -v "#" `
@johanek
johanek / gist:6120466
Created July 31, 2013 08:51
ruby warrior

class Player
def play_turn(warrior)
@warrior = warrior
@health ||= warrior.health
@direction ||= :forward
attack || look || retreat || wall || captive || rest || walk
@health = warrior.health
end
@johanek
johanek / postgres
Last active August 28, 2017 10:59
Useful postgres commands
Example of getting size of fields:
SELECT id, length(raw), length(cooked) FROM posts ORDER BY length(cooked) DESC limit 100;
Truncate table:
truncate table <table>;
@johanek
johanek / README
Last active December 30, 2015 00:09
graphite-web + logstash
logstash(search) - hits for search string
logstash(search,field,facet) - return stats on a field - facets are count, min, max, total, mean.
logstashGroup(search, group, field, facet) - return stats on a field, grouped by a value.
In [1]: import salt.config
In [2]: import salt.loader
In [3]: import salt.renderers.yaml
In [4]:
In [4]: content = open('test.sls').read()
import sys
import os
import salt.config
import salt.loader
import salt.utils
__opts__ = salt.config.minion_config('/etc/salt/minion')
__salt__ = salt.loader.minion_mods(__opts__)
statemods = salt.loader.states(__opts__, __salt__)
print sorted(list(statemods.keys()))
>>> ['alias.absent', 'alias.present', 'alternatives.auto', 'alternatives.install', 'alternatives.remove', 'alternatives.set', 'apache.configfile', 'archive.closing', 'archive.extracted', 'at.absent', 'at.present', 'blockdev.formatted', 'blockdev.tuned', 'boto_asg.absent', 'boto_asg.present', 'boto_cloudwatch_alarm.absent', 'boto_cloudwatch_alarm.present', 'boto_elasticache.absent', 'boto_elasticache.present', 'boto_elb.absent', 'boto_elb.present', 'boto_iam_role.absent', 'boto_iam_role.present', 'boto_lc.absent', 'boto_lc.present', 'boto_route53.absent', 'boto_route53.present', 'boto_secgroup.absent', 'boto_secgroup.present', 'boto_sqs.absent', 'boto_sqs.present', 'buildout.installed', 'cloud.absent', 'cloud.present', 'cloud.profile', 'cloud.volum