Skip to content

Instantly share code, notes, and snippets.

Paul Mucur mudge

Block or report user

Report or block mudge

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
mudge /
Created Aug 26, 2019
Auto-switch Node.js versions with chnode by reading .node-version files
# Based off chruby's
function chnode_auto() {
local dir="$PWD/" version
until [[ -z "$dir" ]]; do
if { read -r version <"$dir/.node-version"; } 2>/dev/null || [[ -n "$version" ]]; then
mudge / use-debounce.js
Last active Sep 22, 2019
A custom React Hook for a debounced click handler with a given callback and delay.
View use-debounce.js
* Inspired by Dan Abramov's "Making setInterval Declarative with React Hooks",
* this is a custom hook for debouncing a callback (e.g. for click handlers) such
* that a callback will not be fired until some delay has passed since the last click.
* The callback will automatically be updated with the latest props and state on every
* render meaning that users don't need to worry about stale information being used.
* See for the
* original inspiration.
mudge /
Last active Jan 21, 2020
Compiling & installing cloudflared for DNS-over-HTTPS on a Raspberry Pi Model B
mudge / dijkstra_with_fibonacci_heap.rb
Last active Jul 15, 2018
Implementing Dijkstra's algorithm with Fibonacci Heap
View dijkstra_with_fibonacci_heap.rb
require 'fibonacci_heap'
# Assuming `graph` is an object with the following interface that stores vertices as `FibonacciHeap::Node`
# instances and `source` is a `FibonacciHeap::Node`:
# * `graph.vertices`: return an Enumerable of all vertices in the graph
# * `graph.neighbours(u)`: return an Enumerable of all vertices that neighbour a given vertex `u`
# * `graph.length(u, v)`: return the numeric weight of the edge between two given vertices `u` and `v`
def dijkstra(graph, source)
dist =
mudge / fibonacci_heap.rb
Last active Jun 24, 2018
A Ruby implementation of a Fibonacci heap
View fibonacci_heap.rb
class CircularDoublyLinkedList
include Enumerable
class Node
include Comparable
attr_accessor :key, :next, :prev
alias right next
alias left prev
mudge / dijkstra.rb
Last active Jun 22, 2018
An implementation of Dijkstra's algorithm in Ruby
View dijkstra.rb
# A pure Ruby implementation of
# Takes a graph in hash form, e.g. { 'A' => ['B', 'C'], 'B' => ['D'], 'C' => ['D'] },
# and a source node, e.g. 'A', and returns the distances to every reachable node and a hash of "next hops" for each node.
def dijkstra(graph, source)
q = graph.keys
prev = {}
dist =
dist[source] = 0
mudge / snitch.rb
Last active Feb 17, 2018
A wrapper class for reporting on method calls useful for reverse engineering
View snitch.rb
# snitch ='A string')
#=> #<Snitch:0x00007fe53a1964b0 @obj="A string">
# snitch.empty?
# Calling empty? on A string with []
#=> false
class Snitch
attr_reader :obj
def initialize(obj)
mudge / best_fit.rb
Last active Jul 28, 2017
Applying bin packing techniques to GNIP PowerTrack rules
View best_fit.rb
domains =
queries = { |domain| %[url_contains:"/#{domain}" OR url_contains:".#{domain}"] }
rule_limit = 1024
operator_limit = 30
rules = [queries.pop]
queries.reverse_each do |query|
enum Error {
enum Term {
TmIf(Box<Term>, Box<Term>, Box<Term>),
You can’t perform that action at this time.