Skip to content

Instantly share code, notes, and snippets.

View Pindar's full-sized avatar

Simon Dittlmann Pindar

View GitHub Profile
@Pindar
Pindar / Gruntfile-snippet.js
Created October 1, 2014 09:16
usage of download-github-release grunt plugin
grunt.initConfig({
'download-github-releases': {
user: 'GITHUB_USER',
repo: 'REPOSITORY',
tag: 'TAG_NAME',
token: process.env.GITHUB_RELEASE_ACCESS_TOKEN,
outputDir: 'DOWNLOAD_DIRECTORY'
},
mkdir: {
githubmodules: {
@Pindar
Pindar / convert-encoding.sh
Last active August 29, 2015 14:05
Convert encoding
for file in *.php do
iconv -f cp1252 -t utf8 "$file" > "$file.new" && mv -f "$file.new" "$file"
done
@Pindar
Pindar / coap-server.js
Created June 5, 2014 15:31
CoAP Observer Try
#!/usr/bin/env node
/*
HOW TO:
1) install required tools
- npm install coap --save
- npm install coap-cli -g
2) run the server: chmod +x coap-server.js && ./coap-server.js
3) observe a resource
- coap get -o coap://localhost/message
@Pindar
Pindar / temp_aws_key.sh
Created March 5, 2014 16:29
extract temporary aws keys
#!/bin/bash
# requires http://stedolan.github.io/jq/
AWS_ROLE_NAME=`wget -O - -q 'http://169.254.169.254/latest/meta-data/iam/security-credentials/'`
wget -O mycreds -q "http://169.254.169.254/latest/meta-data/iam/security-credentials/$AWS_ROLE_NAME"
SECRET_KEY=`jq -r '.SecretAccessKey' <mycreds`
ACCESS_KEY=`jq -r '.AccessKeyId' <mycreds`
TOKEN=`jq -r '.Token' <mycreds`
cat >temp_credentials <<EOM
AWSAccessKeyId=$ACCESS_KEY
function levenshtein (s1, s2) {
// From: http://phpjs.org/functions
// + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
// + bugfixed by: Onno Marsman
// + revised by: Andrea Giammarchi (http://webreflection.blogspot.com)
// + reimplemented by: Brett Zamir (http://brett-zamir.me)
// + reimplemented by: Alexander M Beedie
// * example 1: levenshtein('Kevin van Zonneveld', 'Kevin van Sommeveld');
// * returns 1: 3
if (s1 == s2) {
#!/bin/sh
# COPY of http://pastebin.com/zC9HU2pU
# Do elasticsearch optimize on logstash previous day index
# if $1 = all then optimize all indicies
esindex="/opt/elasticsearch/data/elasticsearch/nodes/0/indices"
# Grab yesterday's values
D=`date +%d -d yesterday`
M=`date +%m -d yesterday`
@Pindar
Pindar / gist:7319399
Created November 5, 2013 14:00
Restore database from bz2 file
bunzip2 < serverdb.sql.bz2 | mysql -h example.com -P 3306 -u USERNAME -p DATABASE_NAME
@Pindar
Pindar / timestamp.sh
Created October 17, 2013 07:25 — forked from vsaw/timestamp.sh
#!/bin/sh
awk '{ print strftime("%Y-%m-%dT%H:%M:%S"), $0; fflush(); }'
@Pindar
Pindar / JavaScript.js
Created November 1, 2012 16:51
JavaScript special
/*
* http://dmitrysoshnikov.com/ecmascript/chapter-2-variable-object/
*/
alert(x); // function
var x = 10;
alert(x); // 10
x = 20;
@Pindar
Pindar / arrange.sh
Created March 31, 2012 17:30
arrange of dock items in mac os x
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
killall Dock