Skip to content

Instantly share code, notes, and snippets.

@sehrgut
sehrgut / xkeyscorerules100.txt
Created July 9, 2014 18:14
XKEYSCORE Tor rules
/*
Leaked by Das Erste
URL: http://daserste.ndr.de/panorama/archiv/2014/Quellcode-entschluesselt-Beweis-fuer-NSA-Spionage-in-Deutschland,nsa224.html
Source: http://daserste.ndr.de/panorama/xkeyscorerules100.txt
*/
// START_DEFINITION
/**
* Fingerprint Tor authoritative directories enacting the directory protocol.
*/
@sehrgut
sehrgut / blocklistman.sh
Last active June 5, 2021 01:06
blocklistman.sh
#!/bin/bash
#
# blocklistman.sh
# Licensed under the GPL v3
#
# Downloads a list of peer blocklists in P2P gzipped format and combines them.
# It only eliminates exact duplicate IP ranges (ignoring range name), and doesn't
# handle overlapping ranges specially.
#
# Usage: Put it in a cron job and pipe stdout to a file your application knows about.
@sehrgut
sehrgut / unsort.sh
Last active December 21, 2015 13:58
For OS X and other platforms where you don't have GNU sort, but want a quick way to shuffle lines. This has been done many times before, but most implementations I've seen don't deal equally with filename arguments and stdin.
#!/bin/bash
# Licensed under any of GPLv2, MIT, and BSD 2-clause licenses
(
if [[ $1 ]]; then
while [[ $1 ]]; do
cat $1
shift
done
else cat
@sehrgut
sehrgut / nettest.sh
Last active December 21, 2015 13:58
Useful tool to keep tabs on an iffy network connection.
#!/bin/bash
# Licensed under any of GPLv2, MIT, and BSD 2-clause licenses
TEST_ADDR='4.2.2.1'
INTERVAL=10
VERSION='nettest v0.2a, keith beckman'
args=$(getopt vhi:H:V $*)
function usage () {
@sehrgut
sehrgut / DrawJustifiedString.vb
Last active December 21, 2015 13:38
System.Graphics#DrawString has no facilities for drawing justified text. This method will draw text into a box, justified. It only handles a single line, but TODO is wrap, so it can be a complete drop-in for Graphics#DrawString. As is, it's useful for single lines such as in logotype.
' This document is free and open-source software licensed simultaneously under the MIT License,
' the GPL v2, and the two-clause BSD License.
Public Sub DrawJustifiedString(ByRef g As Graphics, ByVal txt As String, ByVal font As Font,
ByVal brush As Brush, ByVal destination As RectangleF, ByVal format As StringFormat)
Using fmt As StringFormat = format.Clone
fmt.FormatFlags = fmt.FormatFlags Or StringFormatFlags.MeasureTrailingSpaces ' don't lose spaces
fmt.SetMeasurableCharacterRanges({New CharacterRange(0, 1)}) ' Set Graphics#MeasureCharacterRanges to measure first character
fmt.Alignment = StringAlignment.Center ' "Justified" is an alignment. We need to align each character Center in its computed box
@sehrgut
sehrgut / MeasureAllCharacterRanges.vb
Last active December 21, 2015 13:19
`System.Drawing.Graphics#MeasureCharacterRanges` has a hard limit of 32 `CharacterRange`s for measurement, so here's a workaround. MS has stated they have no intention of fixing this, so get used to it, kids. http://connect.microsoft.com/VisualStudio/feedback/details/96250/setmeasurablecharacterranges-crashes-with-more-than-32-characters#tabs
' This document is free and open-source software licensed simultaneously under the MIT License,
' the GPL v2, and the two-clause BSD License.
Public Function MeasureAllCharacterRanges(ByVal g As Graphics, ByVal txt As String, ByVal font As Font, ByVal dest As RectangleF,
ByVal format As StringFormat, ByVal ranges As IEnumerable(Of CharacterRange)) As IEnumerable(Of Region)
Dim out As New List(Of Region)(ranges.Count)
' Defensive copy to not side-effect caller based on shared GDI format struct
Using fmt As StringFormat = format.Clone
While ranges.Any
@sehrgut
sehrgut / LetterpressSizes.json
Last active April 19, 2018 12:43
Traditional letterpress point size names, in JSON
/*
* Transcribed to JSON from http://en.wikipedia.org/wiki/Point_(typography)#Traditional_point-size_names
* This document is free and open-source software licensed simultaneously under the MIT License, the GPL v2,
* and the two-clause BSD License.
*
* nb. Where conflicts in naming existed (Double Small Pica and Double Pica), the British unit took
* precedence. In all other cases, both US and British units are described.
*/
{
"LetterpressSizes": {

Fastest function to intersect a large number of big arrays in javascript, without dependencies

* The compressed version is only 345 caracters long. * Faster than common libraries, even a large number of arrays, or on very big arrays. (See benchmarks) *

Usage

array_intersect(array1, array2, ..., arrayN)

How it works

The idea is simple and comes from here: http://pioupioum.fr/developpement/javascript-array-intersection.html.
@sehrgut
sehrgut / libertarians.md
Created July 8, 2013 22:21
some google zeitgeist about us crazy libertarians, from my current node.js project "googlesay".

#Google Say

##about "libertarians are just"

  • "Libertarians are just radical Right-wingers who have not one care for anything or anyone other than themselves." *
  • "The Libertarians are just the Antinomians of the modern age." *
  • "6 Comments to �Libertarians Are Just Republicans Who Smoke Pot�." *
  • "His entire piece is premised upon the idea that libertarians are just another element of the Right that simply needs to be brought back into the..." *
  • "Also, it gives credence to allegations from liberals that libertarians are just conservatives in disguise." *
  • "Otherwise, libertarians are just " all the
@sehrgut
sehrgut / squint.sh
Last active December 17, 2015 17:19
squint - a bash script for cygwin to rip audio tracks from YouTube video files wihtout transcoding
#!/usr/bin/bash
# Licensed under any of GPLv2, MIT, and BSD 2-clause licenses
FFDIR=`cygpath -u $USERPROFILE`"/bin/ffmpeg/bin"
infile=`cygpath -w "$1"`
outfile=`cygpath -w "${1%.*}"`
echo $1
FFPROBE="$FFDIR/ffprobe.exe"