Skip to content

Instantly share code, notes, and snippets.

View sverweij's full-sized avatar
🌪️
fighting entropy

Sander Verweij sverweij

🌪️
fighting entropy
View GitHub Profile
@sverweij
sverweij / https.py
Last active March 12, 2020 00:29
https on localhost - with python
# generate the certfile with
# openssl req -new -x509 -keyout localhost.pem -out localhost.pem -days 365 -nodes -sha512
# ... and by answering the questions openssl poses
#
# source http://www.piware.de/2011/01/creating-an-https-server-in-python/
import BaseHTTPServer, SimpleHTTPServer
import ssl
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
alias nvm-latest='nvm ls-remote 4 | tail -1 && nvm ls-remote 5 | tail -1 && nvm ls-remote 6 | tail -1'
@sverweij
sverweij / git-fancy-pancy.sh
Last active April 17, 2016 08:25
Fancy command line git history
#!/bin/sh
set -eu
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
@sverweij
sverweij / nvm-outdated-alias
Last active April 17, 2016 08:01
quick, ugly, unpolished 'nvm outdated' alias hack
alias nvm-outdated='NVM_REMOTE_LS=`mktemp` && NVM_LOCAL_LS=`mktemp` && nvm ls-remote 0.12 | tail -1 > $NVM_REMOTE_LS && nvm ls-remote 4 | tail -1 >> $NVM_REMOTE_LS && nvm ls-remote 5 | tail -1 >> $NVM_REMOTE_LS && nvm ls | head -3 > $NVM_LOCAL_LS && diff $NVM_REMOTE_LS $NVM_LOCAL_LS && rm $NVM_REMOTE_LS $NVM_LOCAL_LS'
# note: when succesfull & no changes shows '-bash: echo: write error: Broken pipe'
# which is because piping nvm ls to something does that (2> 'ing it to /dev/null doesn't work)
# this alias is useful as well in the same context (and works with_out_ hitches)
alias nvm-latest='nvm ls-remote 0.12 | tail -1 > a && nvm ls-remote 4 | tail -1 >> a && nvm ls-remote 5 | tail -1 >> a && cat a && rm a'
@sverweij
sverweij / sudo-on-current-tty-only.md
Created March 26, 2016 09:30
Prevent sudo from escalating to other ttys
sudo visudo

and somewhere in that file add

Defaults tty_tickets
@sverweij
sverweij / vi-mode-for-bash-and-gnu-readline.md
Last active January 25, 2017 21:08
switch on vi mode for bash and stuff using gnu-readline

In the .inputrc add set editing-mode vi (for bash and other stuff using gnu readline) ... or in the .bashrc add set -o vi (if you want to use it in bash only)

Source (with lots of good nuggets): http://blog.sanctum.geek.nz/vi-mode-in-bash/

git config --global url.https://github.com/.insteadOf git://github.com/
@sverweij
sverweij / pre-push.md
Last active April 17, 2016 08:32
pre-push git hook - smoke tests & when successful pushes to mirrors

pre-push hook:

set -eu
remote="$1"
url="$2"
BRANCH=`git branch | grep "^* [a-zA-Z]" | cut -c 3- `

# npm run lint && npm run jscs  && npm run test &&
if [ $remote == 'origin' ]
then
@sverweij
sverweij / gist:44db8a829054d1c8030e
Created September 5, 2015 20:12
Split off audio from a video file
### just splitting it off (which is _fast!_):
ffmpeg -i inputvideo.mp4 -c:a copy -vn -sn outputaudio.mp4
### converting it to mp3
ffmpeg -i inputvideo.mp4 -vn -b:a 128k -c:a libmp3lame outputaudio.mp3
@sverweij
sverweij / gist:efe1ab3723e7bb76898d
Last active August 29, 2015 14:18
Connection sharing on microsoft windows machines

TL;DR

netsh wlan set hostednetwork mode=allow "ssid=AIVDSurveilanceCar1" “key=PreferablyaVerylooongpassword” keyUsage=persistent
netsh wlan start hostednetwork

landline connection -> properties -> Sharing -> Share to Wireless Network Connection 2

Does not work with cisco VPN.

Slow explanation