Skip to content

Instantly share code, notes, and snippets.

View jesusaurus's full-sized avatar

Joni Harker jesusaurus

  • Earth
View GitHub Profile
@jesusaurus
jesusaurus / escctrlcaps.pke
Created March 21, 2012 22:14 — forked from hunner/escctrlcaps.pke
caps->ctrl->esc->caps
clear Lock
clear Control
keycode 9 = Caps_Lock NoSymbol Caps_Lock NoSymbol Caps_Lock
keycode 37 = Escape NoSymbol Escape NoSymbol Escape
keycode 66 = Control_L NoSymbol Control_L NoSymbol Control_L
keycode 135 = Multi_key Multi_key Multi_key Multi_key
add Lock = Caps_Lock
add Control = Control_L Control_R
@jesusaurus
jesusaurus / gist:2315182
Created April 5, 2012 23:48
Meta git hook
#!/bin/bash
# run all the execuable scripts in the corresponding hook.d directory
# e.g. if this is the update hook, run all scripts in update.d/
while read oldrev newrev ref
do
for file in `find ./$0.d/ -type f`
do
if [ -x $file ]
@jesusaurus
jesusaurus / scientific.patch
Created April 20, 2012 01:29
Patch for Scientific Python's setup.py
--- setup.py 2012-02-03 13:15:50.000000000 -0800
+++ setup.py 2012-02-03 13:15:50.000000000 -0800
@@ -44,9 +44,8 @@
arrayobject_h_include = [os.path.join(sys.prefix,
"Lib/site-packages/numpy/core/include")]
else:
- arrayobject_h_include = [os.path.join(sys.prefix,
- "lib/python%s.%s/site-packages/numpy/core/include"
- % sys.version_info [:2])]
+ import numpy.distutils.misc_util
@jesusaurus
jesusaurus / github.sh
Created July 11, 2012 07:03
A script to hook a push to github from another repo being pushed to
#!/bin/bash
# Author: Jonathan Harker <jesusaur@cat.pdx.edu>
REPO=GitHubUser/GitHubRepo.git
KEY="/full/path/to/github.key"
case "$1" in
# Use case 1:
# Call 'github.sh all' in post-receive hook
#!/usr/bin/env zsh
#
# Works best with blinking text; the last heart will blink
# when you have less than 25% of your battery life remaining.
FULL="$(cat /sys/class/power_supply/BAT0/charge_full)"
NOW="$(cat /sys/class/power_supply/BAT0/charge_now)"
BATTERY=$(echo "scale=25;$NOW/$FULL" | bc)
if [[ $BATTERY -lt .25 ]]; then
@jesusaurus
jesusaurus / logstash_index_cleaner.py
Created January 29, 2013 00:09
Python script to clean logstash entries from elasticsearch
#!/usr/bin/env python
#
# Shamelessly stolen from https://logstash.jira.com/secure/attachment/12610/logstash_index_cleaner.py
#
# Deletes all indices with a datestamp older than "days-to-keep" for daily
# if you have hourly indices, it will delete all of those older than "hours-to-keep"
#
# This script presumes an index is named typically, e.g. logstash-YYYY.MM.DD
# It will work with any name-YYYY.MM.DD or name-YYYY.MM.DD.HH type sequence
#
include:
- java
elasticsearch:
pkg:
- installed
- sources:
- elasticsearch: http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.2.deb
service.running:
- require:
@jesusaurus
jesusaurus / myscript.sh
Last active December 6, 2019 08:19
Redirect a bash script's output and error to syslog
#!/usr/bin/env bash
# The pattern `exec > $X 2>&1` does two things: the last bit redirects standard
# error to go to standard output, and the first bit sends standard output to the
# file $X. Here our $X is the process substitution `>( $process )` which takes
# the standard input of $process and presents it as a file handle. Putting
# these two together, we have both our standard out and our standard error
# going to the standard input of $process. Our $process here first runs tee,
# which sends its standard input to both standard out and to the file listed.
# We then pipe our standard out into the logger command, which sends it to syslog.
@jesusaurus
jesusaurus / apache_proxy.sls
Created April 23, 2013 23:16
UndefinedError: 'pillar' is undefined
{% macro proxy(site, server, port, http=True, https=False) -%}
extend:
{{ pillar['package']['apache'] }}:
service:
- watch:
- file: /etc/{{ pillar['package']['apache'] }}/sites-enabled/{{ site }}
/etc/{{ pillar['package']['apache'] }}/sites-enabled/{{ site }}:
file.managed:
@jesusaurus
jesusaurus / install-salt.sh
Created April 26, 2013 23:28
Install salt-master to run under a service user
#!/bin/bash
$SALT_HOME=/var/local/salt
sudo useradd -m -d $SALT_HOME -r -U -c "Salt Master Daemon" salt
mkdir salt
cat > salt/master <<EOF
user: salt