Skip to content

Instantly share code, notes, and snippets.

@zecho
zecho / error_html.ex
Created February 16, 2024 06:59 — forked from srcrip/error_html.ex
Custom Phoenix error pages
# goes in lib/your_app_web/controllers/error_html.ex
defmodule ExampleWeb.ErrorHTML do
use ExampleWeb, :html
def render("404.html" = template, assigns) do
assigns =
assigns
|> Map.merge(%{__changed__: %{}})
|> assign(:message, Phoenix.Controller.status_message_from_template(template))
@zecho
zecho / ediff.sh
Created August 18, 2023 13:08 — forked from redguardtoo/ediff.sh
Use Emacs in ediff to resolve vcs conflicts
#!/bin/sh
[ -z "$MYEMACSCLIENT" ] && MYEMACSCLIENT="emacs"
# $1=$BASE, $2=$LOCAL, $3=$REMOTE, $4=$MERGED
if [ "$MYEMACSCLIENT" = "emacs" ]; then
$MYEMACSCLIENT -nw -Q --eval "(setq startup-now t)" -l "$HOME/.emacs.d/init.el" --eval "(progn (setq ediff-quit-hook 'kill-emacs) (if (file-readable-p \"$3\") (ediff-merge-files-with-ancestor \"$1\" \"$2\" \"$3\" nil \"$4\") (ediff-merge-files \"$2\" \"$3\" nil \"$4\")))"
else
$MYEMACSCLIENT -nw --eval "(progn (setq ediff-quit-hook 'kill-emacs) (if (file-readable-p \"$3\") (ediff-merge-files-with-ancestor \"$1\" \"$2\" \"$3\" nil \"$4\") (ediff-merge-files \"$2\" \"$3\" nil \"$4\")))"
fi
@zecho
zecho / uuid6.sql
Created August 18, 2023 11:19 — forked from fabiolimace/UUIDv6.sql
Functions for generating UUIDv6 and UUIDv7 on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023 Fabio Lima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@zecho
zecho / config
Created April 6, 2023 10:48 — forked from Mel34/config
Sway config
# Default config for sway
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# Read `man 5 sway` for a complete reference.
### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4
@zecho
zecho / nx_fizzbuzz.ex
Created March 21, 2023 13:24 — forked from toranb/nx_fizzbuzz.ex
fizzbuzz with Nx
defmodule Mlearning do
@moduledoc false
def mods(x) do
[rem(x, 3), rem(x, 5), rem(x, 15)]
end
def fizzbuzz(n) do
cond do
rem(n, 15) == 0 -> [0, 0, 1, 0]
@zecho
zecho / stimulus.md
Created October 23, 2022 22:06 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
@zecho
zecho / example_form.html.twig
Created October 23, 2022 22:06 — forked from bjo3rnf/example_form.html.twig
Stimulus.js controller for Symfony collection form type with configurable item limit
{% macro collection_item(form) %}
<div data-form-collection-target="field">
{{ form_widget(form) }}
<button type="button"
data-action="form-collection#removeItem">
remove
</button>
</div>
{% endmacro %}
@zecho
zecho / open_source_dos_games.md
Created August 8, 2020 14:29 — forked from lucasw/open_source_dos_games.md
Open Source DOS Games

Actual dos games that could at least theoretically be recompiled with the right dos tools, and then played in dosbox or on real hardware.

Doom doesn't count because the dos source is not available.

Look at http://dosgames.com/forum/about19706.html

FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@zecho
zecho / convert-dateinterval.php
Created December 12, 2018 12:23
Convert DateInterval in seconds to split
<?php
$d1 = new \DateTime();
$d2 = (clone $d1)->add($interval);
$interval = $d2->diff($d1);