Skip to content

Instantly share code, notes, and snippets.

@trastle
trastle / build-tsungws
Last active December 15, 2015 18:09
A script to build tsung with tsung_ws on OSX
#!/bin/bash
function getWhatWeNeed {
brew install erlang
brew install gnuplot
}
function getCode {
echo -e "\n\nDownloading code...\n\n"
# Get the version of tsung we need
@trastle
trastle / toJSONArray.sh
Last active December 16, 2015 01:18
Converts an input file into a JSON array. Each line of the file will become an element in the array.
#!/bin/bash
DATA_FILE="$1"
OUT_FILE="$DATA_FILE.json"
if [ ! -f "$DATA_FILE" ]; then
echo "Data file is missing please specify a data file on the command line."
exit 1
fi
@trastle
trastle / .gitconfig_part
Created April 15, 2013 16:18
Snippet from .gitconfig to use kdiff3 as the difftool and mergetool on OSX
[alias]
dt = difftool
mt = mergetool
[diff]
tool = kdiff3
prpmpt = false
[merge]
tool = kdiff3
@trastle
trastle / timestamp.js
Created April 19, 2013 09:34
Timestamp in JS (yuk)
function timeStamp() {
var d = new Date();
var hour = ('0' + d.getHours()).slice(-2);
var min = ('0' + d.getMinutes()).slice(-2);
var sec = ('0' + d.getSeconds()).slice(-2);
var mil = ('000' + d.getMilliseconds()).slice(-3);
return hour + ":" + min + ":" + sec + "(" + mil + ")";
}
@trastle
trastle / tls.go
Last active December 16, 2015 15:49
A snippet of Go code for serving HTML pages and WebSockets over TLS (Secure Web Sockets) . This implementation avoids using the poorly performing EDHC cyphers which the HTTP packages uses as part of the default cypher suite. See the golang-nuts thread here for more info: https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/QTDzrcDQmmw
import (
"log"
"net/http"
"crypto/tls"
"net"
"code.google.com/p/go.net/websocket"
)
const (
tlsListenAddress = ":443" // Where are we listening for TLS connections (address:port)
@trastle
trastle / csv2xlsx.vbs
Last active December 16, 2015 15:59
Helping a mate who needed to convert a bunch of CSVs to XLSX files.
' Does the following:
' 1: Convert all of the CVS in the current directory to XLSX files.
' 2: Deletes the CSVs
'
' Usage:
' 1: Place this script in the directory with the CSVs.
' 2: Double click it.
' 3: Jobs a good'un
'
' Borrowing heavily from here:
@trastle
trastle / etc yum.repos.d puppet-deps.repo
Created May 29, 2013 15:32
Main puppet repository and dependencies repository for CentOS6.
[puppetlabs-deps]
name=Puppet Labs Dependencies
baseurl=https://yum.puppetlabs.com/el/6/dependencies/x86_64/
enabled=1
gpgcheck=1
gpgkey=http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs
@trastle
trastle / 99fixbadproxy
Last active February 7, 2022 13:46
Fixing the issue with apt caused by a bad local proxy: -1- Create 99fixbadproxy at: /etc/apt/apt.conf.d/99fixbadproxy -2- Run clear.sh
Acquire::http::Pipeline-Depth "0";
Acquire::http::No-Cache=True;
Acquire::BrokenProxy=true;
@trastle
trastle / add_alternative_jdk.sh
Created July 15, 2013 10:33
Script to add a new JDK as the first alternative in /etc/alternatives.
#!/bin/bash
# The location of the JDK
NEW_JDK_LOCATION="/opt/java/jdk1.7.0_25"
sudo update-alternatives --install "/usr/bin/java" "java" "$NEW_JDK_LOCATION/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "$NEW_JDK_LOCATION/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "$NEW_JDK_LOCATION/bin/javaws" 1
sudo update-alternatives --install "/usr/bin/jarsigner" "jarsigner" "$NEW_JDK_LOCATION/bin/jarsigner" 1
sudo update-alternatives --install "/usr/bin/javah" "javah" "$NEW_JDK_LOCATION/bin/javah" 1
@trastle
trastle / etc_sysconfig_iptables
Created July 15, 2013 15:12
iptables NAT rule to send traffic on port 80 to a service running on 8080
## begin nat
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -i eth2 -p tcp --dport 80 -j DNAT --to-destination :8080
COMMIT
### end nat