Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / pagination_controller.js
Last active April 24, 2024 10:53
HEY's Stimulus Pagination Controller
/*
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
</section>
@mendhak
mendhak / apigateway.tf
Last active April 24, 2024 10:52
Terraform - API Gateway with greedy path (proxy+) calling httpbin. Also includes deployment
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
}
provider "aws" {
@gene1wood
gene1wood / all_aws_lambda_modules_python.md
Last active April 24, 2024 10:52
AWS Lambda function to list all available Python modules for Python 2.7 3.6 and 3.7
@lepikhinb
lepikhinb / .aliases
Created October 1, 2022 23:23
Bash aliases for common commands
# Git
alias wip="git add .; git commit -m 'wip'"
alias push="git push"
# PHP
alias c="composer"
alias pest='./vendor/bin/pest'
alias pint='./vendor/bin/pint'
alias stan='./vendor/bin/phpstan'
@wholtz
wholtz / rclone_copy.py
Last active April 24, 2024 10:49
Rclone copy in Jupyter notebook with progress bar widget
from subprocess import Popen, PIPE
from tqdm.notebook import tqdm
RCLONE_PATH = "/usr/local/bin/rclone"
cmd = [RCLONE_PATH, "copy", "source_directory", "my_remote:destination_directory/", "--progress"]
with tqdm(total=100, desc="Percentage of total number of files", unit="%") as pbar:
with Popen(cmd, stdout=PIPE, bufsize=1, universal_newlines=True) as proc:
for line in proc.stdout:
line = line.strip()
# ██████╗ ███████╗███╗ ███╗ ██████╗ ██╗ ██╗███████╗ ██╗ ██╗██████╗
# ██╔══██╗██╔════╝████╗ ████║██╔═══██╗██║ ██║██╔════╝ ██║ ██║██╔══██╗
# ██████╔╝█████╗ ██╔████╔██║██║ ██║██║ ██║█████╗ ███████║██████╔╝
# ██╔══██╗██╔══╝ ██║╚██╔╝██║██║ ██║╚██╗ ██╔╝██╔══╝ ██╔══██║██╔═══╝
# ██║ ██║███████╗██║ ╚═╝ ██║╚██████╔╝ ╚████╔╝ ███████╗ ██║ ██║██║
# ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═══╝ ╚══════╝ ╚═╝ ╚═╝╚═╝
#
# ██████╗ ██╗ ██████╗ █████╗ ████████╗██╗ ██╗ █████╗ ██████╗ ███████╗
# ██╔══██╗██║ ██╔═══██╗██╔══██╗╚══██╔══╝██║ ██║██╔══██╗██╔══██╗██╔════╝
# ██████╔╝██║ ██║ ██║███████║ ██║ ██║ █╗ ██║███████║██████╔╝█████╗
@braindevices
braindevices / #btrfs benchmark for daily used desktop OS
Last active April 24, 2024 10:46
which file sytem to use for daily work? should we turn on btrfs compression?
#btrfs benchmark for daily used desktop OS
@kleysonr
kleysonr / face_liveness.html
Last active April 24, 2024 10:45
Mediapipe facemesh eye blink for face liveness detection example
<html>
<head>
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Require the peer dependencies of facemesh. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@2.6.0/dist/tf-core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-converter@2.6.0/dist/tf-converter.min.js"></script>
@danteay
danteay / nix-installation.md
Created April 23, 2024 23:10
Nix installation (flakes + home-manager)

Install

Nix es entre varias cosas un gestor de paquetes que mantiene separacion entre las dependencias de cada proyecto sin interferir con el sistema de la PC directamente mediante la gestion de diferentes sources configurados mediante links simbolicos al sistema principal.

Podemos compararlo con Homebrew el cual es el gestor de paquetes mas comunmente usado en MacOS, la mayor diferencia es que mientras que brew instala las dependencias dentro de una carpeta propia del disco del sistema principal, nix maneja todas las dependencias requeridas dentro de un volumen de disco logico completamente aparte del sistema de archivos principal de la PC.