Skip to content

Instantly share code, notes, and snippets.

View Adzz's full-sized avatar

Adam Lancaster Adzz

View GitHub Profile
defmodule Day3 do
# Since my last answer wasn't purely Nx, I'm going
# to try to stick to Nx as much as is possible, but
# we don't have string manipulation stuff so that will
# have to be done in Elixir
import Nx.Defn
def part1 do
File.read!("aoc/3.txt")
|> parse_input()
@mcrumm
mcrumm / app.js
Last active April 28, 2023 09:48
flatpickr + LiveView example
// assets/js/app.js
// ...
import Pickr from "./pickr"
const hooks = {
Pickr
}
// ...
@benmmurphy
benmmurphy / dos.md
Last active November 20, 2020 00:32
erlang hash dos review

Erlang hash-dos review.

TLDR. It's easy to generate collisions for phash and phash2 when hashing binaries. Erlang dict uses phash so if its possible to generate quadratic slow down by triggering collisions. ETS uses phash2 so its possible to generate quadratic slow down by triggering collisions in ETS. The good news is that even though erlang maps uses phash2 and its possible to generate collisions it does not seem easy to trigger a quadratic slow down because the hash array mapped trie implementation rehashes the input with a different prefix when it can't find a unique position in the trie and it looks like it is difficult to generate inputs that collide over multiple different prefixes.

This review is going to focus on taking the hash of binaries because this is the most likely user controllable input to the hash functions.

erlang.phash/2

@moomerman
moomerman / backend-engineer-elixir-092020.md
Last active December 2, 2020 10:58
Backend Engineer (Elixir) - Good Club

Job description

  • Build the supermarket of the future - https://www.goodclub.co.uk
  • 4+ years experience building backend systems in Elixir, Ruby or similar
  • Production Elixir experience not necessary, but a willingness to learn and transfer skills
  • Comfortable with modern HTML, CSS and Javascript
  • Fast-growing, well-funded, values-driven start-up
  • Remote friendly (GMT +/- 3)
  • Full-time
  • Salary: £30k-£60k / €33k-€65k dependant on experience

Writing Elixir tests for greater long-term value: tricks and tools


Short summary: There are "tricks of the trade" for writing readable, maintainable tests that help produce a more coherent system. This talk shows some of them, with an emphasis on code you can use or copy today.


Longer description:

@onlurking
onlurking / programming-as-theory-building.md
Last active April 19, 2024 22:31
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@mudge
mudge / use-debounce.js
Last active September 22, 2022 10:14
A custom React Hook for a debounced click handler with a given callback and delay.
/*
* 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.
*/
#!/bin/bash
VERSIONS=$(gcloud app versions list --service $1 --sort-by '~version' --format 'value(version.id)')
COUNT=0
echo "Keeping the $2 latest versions of the $1 service"
for VERSION in $VERSIONS
do
((COUNT++))
if [ $COUNT -gt $2 ]
then
@coryodaniel
coryodaniel / kube_terminology.md
Last active August 9, 2017 17:42
Kube Terminology Cheatsheet
  • Nodes - Server, laptop, EC2 Instance, droplet. Whatever can host a docker container. They run your pods.
  • Pods - Group of 1 or more docker containers that should be run together. E.g.: an ‘app’ pod may be composed of a NGiNX server, rails app, and a memcached instance.
    • stateless
    • base unit of containerized workloads
    • shared networking space / IP / Port space
    • communicate via localhost
    • share volumes
    • should rarely be created manually
    • kinda feels like a docker-compose file
  • Services - By default, pods are not exposed outside of your cluster. Services expose pods to the public internet.
@reborg
reborg / rich-already-answered-that.md
Last active February 23, 2024 13:09
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content