This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 https://overreacted.io/making-setinterval-declarative-with-react-hooks/ for the | |
* original inspiration. | |
*/ |
On macOS:
$ brew install golang
$ go get github.com/cloudflare/cloudflared/cmd/cloudflared
$ cd ~/go/src/github.com/cloudflare/cloudflared/
$ env GOOS=linux GOARCH=arm GOARM=5 make cloudflared
$ scp cloudflared [email protected]:
Then you can follow the instructions from https://docs.pi-hole.net/guides/dns-over-https/#arm-architecture-raspberry-pi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = Hash.new(Float::INFINITY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CircularDoublyLinkedList | |
include Enumerable | |
class Node | |
include Comparable | |
attr_accessor :key, :next, :prev | |
alias right next | |
alias left prev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A pure Ruby implementation of https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm | |
# | |
# 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 = Hash.new(Float::INFINITY) | |
dist[source] = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# snitch = Snitch.new('A string') | |
#=> #<Snitch:0x00007fe53a1964b0 @obj="A string"> | |
# snitch.empty? | |
# Calling empty? on A string with [] | |
#=> false | |
class Snitch | |
attr_reader :obj | |
def initialize(obj) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
domains = ARGF.readlines.map(&:chomp) | |
queries = domains.map { |domain| %[url_contains:"/#{domain}" OR url_contains:".#{domain}"] } | |
queries.sort_by!(&:size) | |
rule_limit = 1024 | |
operator_limit = 30 | |
rules = [queries.pop] | |
queries.reverse_each do |query| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Error { | |
NoRuleApplies, | |
} | |
enum Term { | |
TmTrue, | |
TmFalse, | |
TmIf(Box<Term>, Box<Term>, Box<Term>), | |
TmZero, | |
TmSucc(Box<Term>), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Declares a new variable, $forwarded_scheme, that contains the URL scheme | |
# used by a user even if Fastly terminates your TLS connections. | |
# | |
# Will use the scheme extracted from the request URI by default or return | |
# "https" if the Fastly-SSL HTTP header is found. | |
map $http_fastly_ssl $forwarded_scheme { | |
default $scheme; | |
"1" "https"; | |
} |