Skip to content

Instantly share code, notes, and snippets.

@thsutton
thsutton / invalid-users.txt
Created January 15, 2013 06:50
SSH scanning attempts.
1145 test
904 admin
637 a
570 oracle
540 net
516 cr
516 54
516 45ru
516 27
516 179
1228.8G 201206150327
1.3G 201206180153
59.0G 201206290123
68.0G 201207090326
17.0G 201207160118
30.0G 201207200747
14.0G 201207310133
6.6G 201208030035
88.0G 201208100549
55.0G 201208240537
@thsutton
thsutton / passphrase.sh
Last active December 11, 2015 12:29
Generate a random passphrase from the words in your system dictionary.
#!/bin/sh
#
# Generate an $N word passphrase from the words in $D.
#
N=6
D=/usr/share/dict/words
R=/dev/random
L=$(cat $D | wc -l)
od -An -tu4 -N $(expr $N \* 4) $R | \
xargs -n 1 -I @ sh -c "head -n \$(expr @ % $L) $D | tail -1" | \
<?php
require_once __DIR__.'/vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernel;
@thsutton
thsutton / add-classes-to-user-password-indicators.patch
Created April 3, 2013 23:56
Patch Drupal's user module JS to add classes to the password field indicators
diff --git a/htdocs/modules/user/user.js b/htdocs/modules/user/user.js
index d182066..e5e5abc 100644
--- a/htdocs/modules/user/user.js
+++ b/htdocs/modules/user/user.js
@@ -52,6 +52,11 @@ Drupal.behaviors.password = {
// Update the strength indication text.
$(innerWrapper).find('.password-strength-text').html(result.indicatorText);
+ $(innerWrapper).find('div.password-strength')
+ .removeClass('password-strength-error')
@thsutton
thsutton / splitInto.hs
Created July 13, 2013 14:58
splitInto :: Int -> [a] -> [[a]]
splitInto :: Int -> [a] -> [[a]]
splitInto n l
| n <= 0 = error "splitInto: n < 1"
splitInto n [] = []
splitInto n l = case splitAt n l of
(c, []) -> [c]
(c, r ) -> c:(splitInto n r)
@thsutton
thsutton / fix-packt-epubs.sh
Created September 23, 2013 11:28
Shell script to fix the "unique" identifiers in EPUB files sold by Packt Publishing.
#!/bin/sh
#
# fixpacktepubs.sh
#
# Process the EPUB files in the current directory and recreate them with the
# ISBN as the unique value. This script was written because Packt Publishing
# sell EPUBs with non-unique unique identifiers and it assumes that the EPUBs
# being process are structured like Packt's.
#
@thsutton
thsutton / make-drupal-file-field-private.sh
Last active February 9, 2022 07:52
Hold your hand through the process of converting an existing Drupal 7 file field to use the private file system. Update the $FIELD variable (and, if required, the path and arguments for drush) and do what it tells you to.
#!/bin/sh
#
# This script will hold your hand during the process of converting an existing Drupal 7 file field from public to private.
#
# http://twitter.com/thsutton
# http://www.linkedin.com/pub/thomas-sutton/55/391/350
# http://thomas-sutton.id.au/
set -eu
@thsutton
thsutton / stream-randoms.lhs
Created July 24, 2014 01:03
Generate a stream of random numbers.
This is a Literate Haskell file: lines begining with `>` are Haskell
code and other lines are just plain old text (Markdown, actually). If
you save this file with a `.lhs` extension, the Haskell tools will all
run it just like a normal `.hs` file.
We're going to generate lists of random numbers and will need a few
helpful functions from the standard library:
> import Data.List (unfoldr)
> import System.Random
@thsutton
thsutton / example.hs
Created August 8, 2014 00:00
Monad transformers example - a monad with exceptions, logging, and configuration.
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Main where
import Control.Applicative
import Control.Monad.Except
import Control.Monad.IO.Class ()
import Control.Monad.Reader
import Control.Monad.Writer