Skip to content

Instantly share code, notes, and snippets.

View nfvs's full-sized avatar

Nuno Santos nfvs

View GitHub Profile
@nfvs
nfvs / autossh-socks5-proxy.sh
Last active January 22, 2024 15:48
Use autossh to setup a local socks5 proxy
[Unit]
Description=AutoSSH socks5 tunnel
After=network-online.target ssh.service
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -N -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa -D 0.0.0.0:1080 root@127.0.0.1
ExecStop=/bin/kill $MAINPID
[Install]
@nfvs
nfvs / macbook-deep-sleep.sh
Created February 15, 2019 07:19
Prevent macbook from waking up during sleep
# First, disable SIP
# Boot into recovery with CMD+R
csrutil disable
# Reboot...
# Get board ID
BOARD_ID=`ioreg -l | grep board-id | sed 's/.*<"\(.*\)">.*/\1/'`
# Modify IOPlatformPlygin ktext
@nfvs
nfvs / gist:6a88b0d13289f26e0ac0df1274e21109
Last active February 6, 2017 18:19
Print all tags of a particular Docker repo's latest image (except 'latest')
docker images $REPO | awk '{if ($2 == "latest") print $3;}' | xargs sh -c 'docker images | grep $0' | awk '{if ($2 != "latest") print $2;}'
@nfvs
nfvs / docker-vpn-fix.sh
Created May 28, 2015 08:42
Fixes docker push when using Cisco AnyConnect
#!/usr/bin/env bash
boot2docker down
vboxmanage modifyvm "boot2docker-vm" --natpf1 "docker,tcp,127.0.0.1,2376,,2376"
boot2docker up
$(boot2docker shellinit)
export DOCKER_HOST=tcp://127.0.0.1:2376
@nfvs
nfvs / backbone_collection_fetch.js
Last active August 29, 2015 14:13
Custom backbone.js Collection.fetch() that doesn't execute if the last instance hasn't completed yet.
// Override the default Backbone.collection.fetch()
// to avoid being called before the last one has finished
Backbone.Collection.prototype.fetch = _.wrap(
Backbone.Collection.prototype.fetch,
function(original_fetch) {
var args = Array.prototype.slice.call(arguments, 1);
// Check if the last fetch() is still underway, if so skip this one.
if (this.fetch_pending === true) return;
@nfvs
nfvs / manage-cron-jobs.sh
Created March 28, 2014 17:11
Enable and disable cron jobs in a file by commenting/uncommenting them.
#!/usr/bin/env bash
function usage () {
cat <<EOF
Usage: $0 [-p] -e|-d -f <file>
where:
-e enable cron jobs
-d disable cron jobs
-p print only
-f modify existing file