Skip to content

Instantly share code, notes, and snippets.

@peter-stratton
peter-stratton / bonded network interface example
Last active November 13, 2018 03:12
Connect to same network via ethernet or wifi (in that order) if available.
# /etc/network/interfaces
auto lo
iface lo inet loopback
auto bond0
iface bond0 inet static
address 192.168.1.155
netmask 255.255.255.0
gateway 192.168.1.1
@peter-stratton
peter-stratton / ammonite_slick_postgres.scala
Last active June 5, 2019 07:26
Slick and Postgresql Ammonite Session
load.ivy("org.postgresql" % "postgresql" % "9.4-1206-jdbc4")
load.ivy("com.typesafe.slick" %% "slick" % "3.1.1")
load.ivy("org.slf4j" % "slf4j-nop" % "1.6.4")
import slick.driver.PostgresDriver
import slick.driver.PostgresDriver.api._
import scala.concurrent.ExecutionContext.Implicits.global
import slick.jdbc.GetResult._
import scala.concurrent.Future
import scala.concurrent.Await
@peter-stratton
peter-stratton / pyclean.sh
Created January 16, 2015 21:48
Python *.pyc and __pycache__ recursive cleanup
#!/bin/bash
echo
echo `find . -type f -iname \*.pyc -not -path "./.*"`
echo `find . -type d -name __pycache__ -not -path "./.*"`
echo
read -p "Delete these files (y/n)? " RESP
case "$RESP" in
y|Y ) find . -type f -iname \*.pyc -not -path "./.*" -delete && find . -type d -name __pycache__ -not -path "./.*" -delete;;
n|N ) echo "Exiting without deleting anything.";;
* ) echo "invalid";;
@peter-stratton
peter-stratton / xyzDistCalc.py
Created October 11, 2014 18:23
XYZ coordinate distance calculation
import math
x1,y1,z1 = 5.0,6.7,1.5
x2,y2,z2 = 4.0,1.2,1.6
distance = math.sqrt((x2-x1)**2+(y2-y1)**2+(z2 -z1)**2)