Skip to content

Instantly share code, notes, and snippets.


Matthew Kerwin phluid61

View GitHub Profile
phluid61 / keyboard hijacks.js
Created Nov 3, 2019
Greasemonkey script to disable keyboard hijacking
View keyboard hijacks.js
// ==UserScript==
// @name Disable keyboard hijacking
// @description Stop websites from highjacking keyboard shortcuts
// @run-at document-start
// @include *
// @exclude*
// @grant none
// ==/UserScript==
phluid61 /
Created Sep 15, 2019
thoughts on draft-ietf-httpbis-header-structure

Thoughts on draft-ietf-httpbis-header-structure


RE: httpwg/http-extensions#913 (and 790, and 629, ...)

I've been thinking about data types and models again. My premise is that a type is a combination of a range/domain of values, and a set of operations that can be performed on those values.

phluid61 / generate_views_parallel
Last active Jun 6, 2019
Run generate_views in parallel: `MAX_PARALLEL_CHILDREN=4 bin/generate_views_parallel myrepo`
View generate_views_parallel
#!/usr/bin/perl -w
use FindBin;
use lib "$FindBin::Bin/../perl_lib";
use EPrints;
use strict;
use Getopt::Long;
use Pod::Usage;
phluid61 / hangmun.rb
Last active Sep 13, 2018
Redwine's assignment, done in Ruby
View hangmun.rb
all_words ='dictionary.txt', 'r') {|f|{|l|l.strip}.to_a }
all_words.reject! {|w| w.nil? || w == '' }
# --- prompt and initialise
candidates = []
while candidates.empty?
print "Word length: "
length = STDIN.gets.to_i
phluid61 / strings.rb
Last active Feb 1, 2018
The best way to generate strings in Ruby...
View strings.rb
# A Percent character '%'
eval '% %s %% % '
# (wrapped in `eval` to highlight the trailing space, which is critical)
# A Question-mark character '?'
# A Hash character '#'
phluid61 /
Last active Nov 7, 2017
EPrints 'reencode' subroutine to heuristically detect certain non-UTF-8 encodings
# A percent-encoded URI does not necessarily have to encode UTF-8
# sequences. For example:
# <
# The percent-encoded sequence is actually EUC-CN (a Chinese character
# encoding). We have no problem in perl when the 'word' parameter is
# naively converted to octets, however the database will definitely
phluid61 /
Last active Sep 14, 2017
EPrints - custom view menu size function

Adds a custom function to EPrints' repository view configuration, so you can define a subroutine for each menu level that returns the map of {id=>count} for that level.

Particularly handy when the a conflict between the menu's fields and the generated DISTINCT BY clause include NULL values in the menu despite allow_null=>0 being specified in config.

See the discussion at

phluid61 /
Last active Jul 20, 2017
hpush -- like 'push' for a hash
package hpush;
use base 'Exporter';
our @EXPORT = ('hpush');
use strict;
use warnings;
sub hpush (\%@) {
my $h = shift;
phluid61 / bigdecimal-test.rb
Created Jul 19, 2017
Testing BigDecimal in Ruby
View bigdecimal-test.rb
require 'bigdecimal'
def _sprintf num
('%0.45f' % num).sub(/0+$/,'')
n = 1
loop do
n += 1
phluid61 / test_a.rb
Last active Mar 28, 2017
How to unit test module methods
View test_a.rb
require 'test/unit'
$VERBOSE = true
#require 'a'
module A
extend self
def add(x, y)
x + y