Skip to content

Instantly share code, notes, and snippets.

Michael Strasser mjstrasser

  • Brisbane, Australia
Block or report user

Report or block mjstrasser

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mjstrasser
mjstrasser / StreamUtils.java
Last active Jun 5, 2018
Utilities for working with Java streams
View StreamUtils.java
package mjs.stream.utils;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class StreamUtils {
/**
* Converts a stream into an iterable for use by, e.g. Spring CrudRepository classes.
*/
View package.json
{
"name": "retry-axios",
"version": "1.0.0",
"description": "Retry function for axios promise-based HTTP client",
"scripts": {
"test": "jest --coverage"
},
"dependencies": {
"is-retry-allowed": "^1.1.0"
},
@mjstrasser
mjstrasser / zipper.erl
Created Mar 19, 2017
Higher-order functions in practice from Functional Programming in Erlang MOOC
View zipper.erl
-module(zipper).
-compile(compile_all).
-include_lib("eunit/include/eunit.hrl").
%% Tail-recursive implementation of zip/2
%% that combines items into 2-tuples.
zip(Xs, Ys) -> lists:reverse(zip(Xs, Ys, [])).
% Stop when either list finishes.
zip([], _, Zs) -> Zs;
zip(_, [], Zs) -> Zs;
@mjstrasser
mjstrasser / index.erl
Created Mar 13, 2017
Index generator for week 2 assignment in Functional Programming in Erlang MOOC from University of Kent (futurelearn.com)
View index.erl
-module(index).
-export([get_file_contents/1,show_file_contents/1,
index_file/1, word_index/1]).
-include_lib("eunit/include/eunit.hrl").
%% Index the words in the specified file.
index_file(Filename) ->
word_index(get_file_contents(Filename)).
@mjstrasser
mjstrasser / keybase.md
Last active Jan 30, 2016
Keybase proof
View keybase.md

Keybase proof

I hereby claim:

  • I am mjstrasser on github.
  • I am mjstrasser (https://keybase.io/mjstrasser) on keybase.
  • I have a public key whose fingerprint is F541 37DC 4A71 A203 BEE9 F12C A13D 44D8 2E90 4858

To claim this, I am signing this object:

@mjstrasser
mjstrasser / tunnels.rb
Last active Aug 29, 2015
Manage SSH tunnels to remote hosts.
View tunnels.rb
require 'net/ssh/gateway'
module Net
module SSH
# A class that manages URLs, tunnelling them if necessary.
class Tunnels
HP = Struct.new(:host, :port) do
def to_s
@mjstrasser
mjstrasser / headers_proxy.rb
Last active Aug 29, 2015
Web proxy that injects HTTP headers for test purposes
View headers_proxy.rb
# Logging class that logs nothing. The default is INFO logging to $stderr.
class NullLog < WEBrick::BasicLog
def log(level, data)
# Do nothing.
end
end
# Subclass of WEBrick::HTTPProxyServer that injects HTTP headers into the request.
#
# Specifying a RequestCallback proc does not work because the WEBrick::HTTPRequest object
@mjstrasser
mjstrasser / pimp_it_hard.rb
Created Jul 6, 2014
Pimp it hard: Ruby script to pummel http://pimpmylight.catchpole.net/ a number of times, using random colour choice and random delays between messages.
View pimp_it_hard.rb
# Run Pimp My Light for a while
require 'httparty'
COLOURS = [:red, :orange, :green]
PML_URL = 'http://pimpmylight.catchpole.net/?update=%s'
TOTAL = ARGV.length > 0 ? ARGV[0].to_i : 5
COUNTS = { red: 0, orange: 0, green: 0, except: 0 }
You can’t perform that action at this time.