Skip to content

Instantly share code, notes, and snippets.

@agassner
agassner / tm.sh
Created January 18, 2019 16:12
Delete old MacOS Time Machine backups
sudo tmutil listbackups | grep 2018 | xargs -I {} sudo tmutil delete '{}'
sudo hdiutil compact /Volumes/TimeMachine/YourBackup.sparsebundle
@agassner
agassner / s3.py
Last active April 25, 2022 11:48
S3 upload and copy with encryption
#!/usr/bin/env python
import boto3
from boto3.s3.transfer import S3Transfer
filename = 'file.txt'
bucket_name = 'ravenskill'
s3 = boto3.resource('s3')
@agassner
agassner / vpc.py
Last active September 29, 2016 13:12
AWS - Boto3 waiters style for when InternetGateway, Subnet, Vpc and Dhcp Options are deleted (Eventual Consistency)
#!/usr/bin/env python
import boto3
import logging
import time
from botocore.exceptions import ClientError
class Waiter:
@agassner
agassner / rtspserver
Created November 27, 2015 22:14
rtspserver init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: RTSPSERVER
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4
# Default-Stop: 0 1 6
# Description: Provides the Mpromoneth rtsp server
### END INIT INFO
SCRIPT="/home/pi/h264_v4l2_rtspserver/h264_v4l2_rtspserver -P 8554 -Q 10 -r -s -W 2592 -H 1944 -F 15"
@agassner
agassner / gist:34e51a5921748a99754e
Created August 14, 2014 09:20
Flush the DNS in OS X Mavericks
dscacheutil -flushcache
sudo killall -HUP mDNSResponder
#!/bin/bash
## in .bash_profile
SSHAGENT=`which ssh-agent`
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi
// simple example of the cake pattern
// abstract DAO trait
trait Repository[A, B]{
// saves an entity, returns an ID
def save(entity: A): B
// more features..
}
trait RdbmsRepository extends Repository[MyUserCaseClass, Long]{
@agassner
agassner / gist:6239406
Created August 15, 2013 09:01
git autocomplete on Mac OS X
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
echo "source ~/.git-completion.bash" >> ~/.bash_profile
@agassner
agassner / gist:6235121
Created August 14, 2013 20:13
remove unused kernels
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
@agassner
agassner / gist:6234552
Created August 14, 2013 19:20
patching with git
# create a patch
git diff --no-prefix > patchfile
# apply a patch
patch -p0 < patchfile
# apply a patch created without "--no-prefix"
patch -p1 < patchfile