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 / 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 / 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 / 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
alias nvm-latest='nvm ls-remote 4 | tail -1 && nvm ls-remote 5 | tail -1 && nvm ls-remote 6 | tail -1'
@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)
@sverweij
sverweij / get-typescript-dependencies.md
Last active March 2, 2017 20:59
Get dependencies of a typescript code base with dependency-cruiser

The recipe in previous revisions of this gist is obsolete as dependency-cruiser supports typescript (and coffeescript, livescript) out of the box since december 2016, so it's currently as simple as:

npm i --global dependency-cruiser

# ... assuming your source is in src, you can dump the dependencies 
# (including those in node_modules) to a file with:
depcruise -T json -f dependencies.json src

# or if you want to make a graph - send it through graphviz dot
@sverweij
sverweij / gist:70258f4f33639f8f60467bc22189748d
Created December 15, 2016 20:41
git log format - add this to your .git/config
[format]
pretty = %Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset
Good font with ligatures: Fira Code
Embedding a font in a package: https://github.com/adilparvez/atom-hasklig
# you can check that with ssh-add
ssh-add -l
# response when these steps need to be taken: 'The agent has no identities.'
# response when everything ok would be more like: '2048 SHA256:yourkey /Users/youryousername/.ssh/id_rsa (RSA)'
# start the ssh-agent
ssh-agent -s
# add your keys.
ssh-add ~/.ssh/id_rsa
@sverweij
sverweij / poor-mans-html-lint.html
Created March 12, 2017 09:37
poor man's html lint
<style>
*[style],
a:not([href])
a[href="#"],
a[href=""],
a[href*="javascript:void(0)"],
img:not([alt]):not(aria-hidden="true"),
img[alt=""],
html:not([lang]),
html[lang=""],