Skip to content

Instantly share code, notes, and snippets.

View andrioid's full-sized avatar

Andri Óskarsson andrioid

View GitHub Profile
@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"
@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 / 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 / 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
<?php
interface ICircuitBreakerStorage {
}
class CircuitBreaker {
/**
* StorageImplemntation should be a defined interface.
**/
@andrioid
andrioid / keybase.md
Created August 22, 2014 06:42
Keybase Proof

Keybase proof

I hereby claim:

  • I am andrioid on github.
  • I am andrioid (https://keybase.io/andrioid) on keybase.
  • I have a public key whose fingerprint is D4DE 3FBB F5CE 71A7 2EB3 A34B 7F7D 175F 7082 C827

To claim this, I am signing this object:

// HTTP Fire and Forget (Asynchronous, mostly - hey it's PHP!)
public static function SendHTTP($action, $data = null, $service = 'admin', $host = false, $port = false, $key = false){
if ($port == false) { $port = Config::Get('MBISS_PORT'); }
if ($host == false) { $host = Config::Get('MBISS_HOST'); }
if ($key == false) { $key = Config::Get('MBISS_KEY'); }
if (data == null) { $data = array(); }
if ($key == false) { $key = ''; }
if (empty($host) || empty($port)) { return false; }
@andrioid
andrioid / parse-template.sh
Created May 21, 2015 17:48
Replace {{tags}} with environmental variables
for line in $(find . -iname '*.dtpl'); do
config=${line%.dtpl}
cp $line $config
echo "Replacing '$config'"
for key in $(cat $config | grep -o -P '({{[0-9a-z_-]+}})'); do
ukey=$(echo $key | sed 's/.*/\U&/' | sed -e "s/{{//" | sed -e "s/}}//")
val=$(eval "echo \$${ukey}")
#echo "Tag: $key $ukey $val"
if [ -n "$val" ]; then
@andrioid
andrioid / .bash_profile
Created October 4, 2017 11:34 — forked from jusopi/check.sh
Set node version per project using .nvmrc file
# change title name of tab in terminal
function title {
echo -ne "\033]0;"$*"\007"
}
enter_directory(){
if [ "$PWD" != "$PREV_PWD" ]; then
PREV_PWD="$PWD";
title $(echo ${PWD##*/}) $(node -v);
if [ -e ".nvmrc" ]; then

Keybase proof

I hereby claim:

  • I am andrioid on github.
  • I am andrioid (https://keybase.io/andrioid) on keybase.
  • I have a public key ASBGyzR9oDNGwQMN6sGbtbGgq-4XqyQG_JG6jsuckLzg9wo

To claim this, I am signing this object: