Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / Kickstarter Spending Report README.md
Last active August 29, 2015 14:03
Kickstarter Spending Report

I wanted a quick way to see how much I'd spent on Kickstarter. These browser console scripts will convert all Kickstarter pledges to your home currency and add them up.

  1. Set homeCurr in xe.com.js and kickstarter.com.js to the same value.
  2. Run xe.com.js in a console window on http://xe.com.
  3. Set exchg in kickstarter.com.js to the output of step 2.
  4. Run kickstarter.com.js in a console window on https://www.kickstarter.com/profile/backings?ref=nav.

You should see something like:

@sehrgut
sehrgut / jquery.withStyles.js
Last active August 29, 2015 14:03
jQuery plugin to find elements based on computed CSS styles
/*
jquery.withStyles.js - jQuery plugin to find elements based on computed CSS styles
Copyright (C) 2014 Keith Beckman
Released under the GPLv3
## Usage
* Returns collection of all `a` tags with computed styles matching the CSS declaration
* `$('a:withStyles("font-style: bold; color: #FFFFFF;")')`
* `$('a').filter(':withStyles("font-style: bold; color: #FFFFFF;")')`
* `$('a').withStyles("font-style: bold; color: #FFFFFF;")`
@sehrgut
sehrgut / facebook-trending.abp
Created January 8, 2015 22:01
AdBlock Plus rule for Facebook "Trending" feed
@sehrgut
sehrgut / console.loghistory.js
Created June 24, 2015 20:01
console.log() with message history
console.log = (function (oldlog) {
var console_log = oldlog.bind(console);
var messages = [];
var newlog = function (msg) {
messages.push(msg);
console_log(msg);
};
@sehrgut
sehrgut / get-ebay-history.js
Created July 14, 2015 16:46
reads ebay purchase history from purchase history page
function getEbayHistory() {
var jq = jQuery([1]);
function parseItem(el) {
jq[0] = el;
var $title = jq.find('a.item-title');
return {
title: $title.text(),
url: $title.attr('href')
};
@sehrgut
sehrgut / gtm-cut.sh
Last active August 29, 2015 14:26
cuts a clip from a non-standard .mov file recorded by GoToMeeting
#!/bin/bash
function print_usage() {
cat <<EOF
Usage: `basename "$0"` --start time --length seconds --in path --out path
--start time: start time in 'HH:MM:SS.mmm' format
--length seconds: clip length in integer seconds
--in path: input file, must have '.mov' extension
--out path: output file, must have '.mov' extension
@sehrgut
sehrgut / finder-toggle-hidden.sh
Created August 13, 2015 21:46
function to toggle display of hidden files in OS X's Finder (put it in your .profile)
function finder-toggle-hidden () {
mode='TRUE'
if [[ `defaults read com.apple.finder AppleShowAllFiles` = 'TRUE' ]]; then
mode='FALSE'
fi
defaults write com.apple.finder AppleShowAllFiles $mode
killall Finder
}