Skip to content

Instantly share code, notes, and snippets.

View mindreframer's full-sized avatar
🎯
Focusing

Roman Heinrich mindreframer

🎯
Focusing
View GitHub Profile
@steveruizok
steveruizok / cache.ts
Last active March 31, 2023 14:43
weak map gist
export class Cache<T extends object, K> {
items = new WeakMap<T, K>()
get<P extends T>(item: P, cb: (item: P) => K) {
if (!this.items.has(item)) {
this.items.set(item, cb(item))
}
return this.items.get(item)!
}
@garthk
garthk / PASTE_ME.exs
Last active November 5, 2020 19:08
Watch all Phoenix.LiveView and LiveComponent handle_event callbacks
(fn gl ->
:dbg.stop_clear()
repr = fn
%Phoenix.LiveView.Socket{} -> "socket"
v -> inspect(v)
end
{:ok, _} =
:dbg.tracer(
@goofansu
goofansu / app.js
Last active August 5, 2023 04:05
LiveView upload directly to AWS China S3
let Uploaders = {}
Uploaders.S3 = function (entries, onViewError) {
entries.forEach(entry => {
let xhr = new XMLHttpRequest()
onViewError(() => xhr.abort())
xhr.onload = () => (xhr.status === 200 ? entry.done() : entry.error())
xhr.onerror = () => entry.error()
xhr.upload.addEventListener("progress", event => {
if (event.lengthComputable) {

Various search databases and backends as alternatives to Elasticsearch.

Rust

Charlie Owen - All constraints are beautful

Using cakes to make your friends happy

But they all have issues (vegan, gluten intolerance, peanut allergy) So they all went to the bar -> examples of constraints : making people happy is the objective, you adapt to the constraints

Constraints makes us more creative : Mihaly Csikszentmihaly Nietzsche : "Dancing in chains"

@jpswade
jpswade / devops_best_practices.md
Last active April 16, 2024 18:35
Devops Best Practices Checklist

Find the original here article here: Devops Best Practices

DevOps started out as "Agile Systems Administration". In 2008, at the Agile Conference in Toronto, Andrew Shafer posted an offer to moderate an ad hoc "Birds of a Feather" meeting to discuss the topic of "Agile Infrastructure". Only one person showed up to discuss the topic: Patrick Debois. Their discussions and sharing of ideas with others advanced the concept of "agile systems administration". Debois and Shafer formed an Agile Systems Administrator group on Google, with limited success. Patrick Debois did a presentation called "Infrastructure and Operations" addressing

@vic
vic / ex14parens.rb
Created December 9, 2016 09:13
Add missing parentheses to avoid Elixir 1.4 warnings on function calls.
#!/usr/bin/env ruby
###
# This utility adds missing parentheses to single word function calls
# that are now treated as warnings on Elixir 1.4.
#
# Download this file on your project repo and execute
# ruby ex14parens.rb --help
####
require('fileutils')

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@rob-brown
rob-brown / stage_inspector.ex
Last active August 18, 2016 07:06
Inspect the data passed between GenStages.
defmodule StageInspector do
alias Experimental.{GenStage}
use GenStage
def init(type) when type in [:consumer, :producer_consumer] do
{type, type}
end
def handle_events(events, _from, state = :consumer) do
Enum.each events, &inspect_event/1
@aaronjensen
aaronjensen / drain_stop.ex
Last active November 28, 2022 06:59
Phoenix Drain Stop
# ATTENTION: This is now supported in plug_cowboy as of 2.1.0:
# https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html
defmodule DrainStop do
@moduledoc """
DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown
occurs. It first shuts down the acceptor, ensuring that no new requests can be
made. It then waits for all pending requests to complete. If the timeout
expires before this happens, it stops waiting, allowing the supervision tree
to continue its shutdown order.