Skip to content

Instantly share code, notes, and snippets.

@EnigmaCurry
EnigmaCurry / vpn_namespace.md
Created April 7, 2016 02:28
OpenVPN and browser specific network routing with ip netns

OpenVPN and browser specific network routing with ip netns

Create network bridge

A network bridge allows us to have a virtual router that we can plug multiple network interfaces into. The IP address is assigned to the bridge rather than the individual network interface.

Create the bridge device, br0 :

@EnigmaCurry
EnigmaCurry / gist:35d6f36411057e6c6c4107a7175b7186
Created March 31, 2016 23:48
bash source command doesn't like to be hooked up to pipes
$ echo "export IAMSET=yes" > test.sh
$ source test.sh | tee
$ echo "IAMSET="$IAMSET
IAMSET=
$ source test.sh
$ echo "IAMSET="$IAMSET
IAMSET=yes
@EnigmaCurry
EnigmaCurry / rjconsole.sh
Last active August 29, 2015 14:27
Remote JMX Jconsole over ssh
rjconsole() {
# args: HOST JMX_PORT
if [ $# -lt 1 ] ; then
echo "Usage: rjconsole [user@]HOST [JMX_PORT]"
return
fi
if [ $# == 1 ] ; then
JMX_PORT=7199
else
JMX_PORT=$2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Hyperlink JIRA ticket numbers for DataStax projects
;;
;; For example, all of these tickets should be clickable when
;; bug-reference-prog-mode or bug-reference-mode are enabled :
;;
;; CASSANDRA-8099
;; PYTHON-363
;; TESTINF-386
;; DSP-6091
@EnigmaCurry
EnigmaCurry / copy_ssh_id.sh
Last active August 29, 2015 14:23
A better ssh-copy-id
# Copy an SSH key to multiple accounts on multiple machines.
# Better than ssh-copy-id because it works with systems that don't
# use passwords over ssh.
echo "Enter the ssh pub key: "
read PUBKEY
echo "Enter the hosts to copy the key to (separated by space)"
read HOSTS
HOSTS=(${HOSTS// / })
@EnigmaCurry
EnigmaCurry / |etc|dhcpcd.conf
Last active August 29, 2015 14:22
Local DNS server for choosing different upstream DNS servers based on domain name
#At the end of the file, makes it so resolv.conf isn't overwitten by dhcp
#Probably not necessary since we chattr +i the file though
nohook resolv.conf
#!/bin/bash
## Run a script inside a screen session.
## Keeps the screen session active after the process is done.
## Logs to a file with the same name as SCREEN_NAME
if [ $# != 2 ] ; then
echo "Usage: run_screen SCREEN_NAME SCRIPT"
exit 1;
fi
@EnigmaCurry
EnigmaCurry / client_secrets.md
Created April 26, 2015 17:10
cstar_perf client_secrets.json

cstar_perf uses Google APIs for authentication purposes. If you are installing cstar_perf for yourself you will need to generate your own API token for use with your installed version.

Image

Enter whatever Project Name you want (maybe use cstar-perf.) Use the suggested Project ID (doesn't matter, just has to be unique.)

It will take a minute for the project to be created, once it has:

@EnigmaCurry
EnigmaCurry / build_python.sh
Created March 22, 2015 15:27
Building an older version of Python for use in virtualenv
PREFIX=/opt/python
VERSION=2.7.8
mkdir -p $PREFIX/src
cd $PREFIX/src
wget https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz
tar xfv Python-$VERSION.tar.xz
cd Python-$VERSION
./configure --prefix=/opt/python/Python-$VERSION
make
@EnigmaCurry
EnigmaCurry / remote_bitcoind.sh
Created February 10, 2015 02:27
Bitcoin remote RPC client
#!/bin/bash
# Remote bitcoind RPC client through SSH tunnel
#
# If you have a remote bitcoind you'd like to query it's RPC interface
# from, this script will help you maintain the SSH tunnel to do so.
#
# Set REMOTE_HOST to the user@server your remote bitcoind is running on
# Set LOCAL_FORWARD_PORT to the port you want to run the tunnel on
# Set the RPC_PASSWORD to the rpc password bitcoind is set to use.