Skip to content

Instantly share code, notes, and snippets.

@n-st
n-st / unwrap.py
Created May 24, 2017 10:43
Undo wrapping at 78-character line length
#!/usr/bin/python3
import sys
import fileinput
lines = list(fileinput.input())
lines = [l.strip('\r\n') for l in lines]
for i, l in enumerate(lines):
# We need to account for 8-char-wide tabulators when calculating our line
@n-st
n-st / mac.py
Created May 21, 2017 01:08 — forked from anonymous/mac.py
#!/usr/bin/env python
# don't fuck too hard with it n-st :P
from twisted.words.protocols import irc
from twisted.internet import protocol
from twisted.internet import reactor
from twisted.internet import task
from twisted.python import log
import cfscrape
import validators
import duckduckgo

Keybase proof

I hereby claim:

  • I am n-st on github.
  • I am nst (https://keybase.io/nst) on keybase.
  • I have a public key whose fingerprint is 0179 5F52 941E 8169 E359 C173 EECB F7FA 4855 86E8

To claim this, I am signing this object:

@n-st
n-st / Arubacloud.DC2-IT-Arezzo.txt
Last active April 5, 2017 20:20
Arubacloud benchmarks
-------------------------
nench.sh benchmark
2017-02-25 21:06:15 UTC
-------------------------
Processor: Intel(R) Xeon(R) CPU E5-2650L v4 @ 1.70GHz
CPU cores: 1
Frequency: 1698.925 MHz
RAM: 509M
Swap:
@n-st
n-st / ipv6-slash64.md
Last active March 4, 2017 18:19
IPv6. You're doing it wrong.

IPv6. You're doing it wrong.

If you're reading this, you've probably been called out on assigning unreasonably small IPv6 subnets or even individual IPv6 addresses to your customers.
Here's why you should reconsider and assign a separate /64 subnet to each customer:

@n-st
n-st / .bash_profile
Created May 29, 2016 12:04
Start zsh from bashrc. Useful when you can't use chsh or when the same LDAP account is used both on systems with zsh installed and ones without.
# .bash_profile is executed for login shells,
# .bashrc is executed for interactive non-login shells.
# We want the same behaviour for both, so we source .bashrc from .bash_profile.
# Also, when .bash_profile exists, bash ignores .profile, so we have to source
# it explicitly.
if [ -f "$HOME/.profile" ]; then
. "$HOME/.profile"
fi
@n-st
n-st / sort-gitconfig.sh
Created March 24, 2016 21:51
Sort the sections of a Git config file (and the contents of the sections) alphabetically
awk '{ if ($1 ~ /^\[/) { section=$0; print $0 } else { printf section; print $0 } }' gitconfig | sort -t ']' -k1,1 | sed 's/\[.\+\]\([^\s]\+\)/\1/' > gitconfig.new
mv gitconfig.new gitconfig
@n-st
n-st / qr.js
Created February 28, 2016 16:28
Bookmarklet to generate a QR code containing the URL of the current page. Can also generate QR codes with arbitrary content when executed from an empty browser tab or called via a bookmark shortcut keyword.
javascript:void(function(){if('%s'.length>2){window.open('http://qr.kaywa.com/?s=8&d='+escape('%s'))}else{if(document.location.href.indexOf('http')!=0){t=prompt('Enter%20QR%20code%20content:','http://');if(t!=null){document.location.href='http://qr.kaywa.com/?s=8&d='+escape(t)}}else{window.open('http://qr.kaywa.com/?s=8&d='+escape(document.location.href))}}}());
@n-st
n-st / view-on-archive-org.js
Created February 28, 2016 16:20
Bookmarklet to view current page on the Internet Archive Wayback Machine (https://archive.org/)
javascript:(function(){if(location.href.indexOf('http')!=0){input=prompt('URL:','http://');if(input!=null){location.href='http://web.archive.org/web/*/'+input}}else{location.href='http://web.archive.org/web/*/'+location.href;}})();
@n-st
n-st / 0xfat-30.sh
Created October 16, 2015 01:25
Solution for 0xf.at level 30 (https://www.0xf.at/play/30/)
#!/bin/bash
# Solution for 0xf.at level 30 (https://www.0xf.at/play/30/)
# solved in 49 minutes, 54 seconds
# This script expects the filename of the downloaded challenge image as its only parameter and will output the correct answer string.
# To prevent cheating, this version of the script has been modified in a few subtle ways so it will output an incorrect answer.
# Development process:
# - Use imagemagick to split input image into 40x40 px blocks