Skip to content

Instantly share code, notes, and snippets.

View andrioid's full-sized avatar

Andri Óskarsson andrioid

View GitHub Profile
@andrioid
andrioid / configparse.sh
Created June 13, 2014 08:58
Simple search/replace config file script in Bash
#!/bin/bash
# Replaces params with values and outputs
# Note: Not really designed for complex variables. So beware of sed
USAGE="configparse <infile> [param1=value1 param2=value2 .. paramn=valuen]"
# - .e.g. configparse sitebleh.tmpl DOCROOT=/data/moo USER=ano HOSTNAME=scrolls.org
if [ ! "$1" ]; then
echo $USAGE
exit 1
fi
@andrioid
andrioid / reload-images.js
Last active August 29, 2015 14:02
I was playing with RRD and network graphs at home (what do normal people do on holidays?). Anyway... If you include this script in your markup, it will periodically reload all images it can find. For better or worse...
(function() {
function updateImages(){
var images = document.images;
for (var i=0; i<images.length; i++) {
var imagename = images[i].src.match(/((.*)\.(png|gif|jpg))/i);
if (imagename) {
var timestamp = new Date().getTime();
images[i].src = imagename[0] + "?nocache=" + timestamp;
}
}
@andrioid
andrioid / gist:1eb785ecbb9fccd3fde1
Last active August 29, 2015 14:01
JSON creation CLI idea
I needed to make a Bash script talk to a RESTish service today.
Found a bunch of JSON parsing tools, but no creation tools.
I wanted this. Does it make sense?
jc -all.your.base=moo -all.your.cows=beef,burger
{
all: {
your: {
@andrioid
andrioid / slack-svn-postcommit
Last active December 19, 2016 16:54
Slack Subversion Post Commit Hook
#!/bin/bash
# Requires Curl and Subversion Server installed.
# Put this file as "post-commit" with 755 permissions on the hooks directory of your repo
REPO_PATH=$1
REV=$2
LOOK=/usr/bin/svnlook
CURL=/usr/bin/curl
CHANNEL="#general"