Skip to content

Instantly share code, notes, and snippets.

@gquittet
gquittet / tailwind-gauge-chart.html
Last active February 6, 2024 07:17
tailwind gauge chart
<!-- percent to deg => Math.round(((value / 100) * 180 - 45) * 10) / 10 -->
<div class="relative flex aspect-[2] items-center justify-center overflow-hidden rounded-t-full bg-blue-400">
<div class="absolute top-0 aspect-square w-full rotate-[calc(72deg-45deg)] bg-gradient-to-tr from-transparent from-50% to-white to-50% transition-transform duration-500"></div>
<div class="absolute top-1/4 flex aspect-square w-3/4 justify-center rounded-full bg-blue-100"></div>
<div class="absolute bottom-0 w-full truncate text-center text-[20vmax] leading-none">40%</div>
</div>
package main
import (
"bytes"
"fmt"
"net"
"runtime"
"sync"
"sync/atomic"
"time"
@wybiral
wybiral / noscript-tracking.go
Last active September 11, 2023 08:53
Tracking cursor position in real-time with remote monitoring (without JavaScript)
// Tracking cursor position in real-time without JavaScript
// Demo: https://twitter.com/davywtf/status/1124146339259002881
package main
import (
"fmt"
"net/http"
"strings"
)
@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@paulcsmith
paulcsmith / an_action_that_requires_sign_in.cr
Last active March 8, 2018 21:22
For sign up and sign in (authentication)
class Somethings::Index < BrowserAction
before require_sign_in
action { "do stuff" }
# You can extract all this to a module since you'll likely use it in multiple places
# Probably in src/pipes/authentication.cr or something
private def require_sign_in
if signed_in?
@nicklaw5
nicklaw5 / ramdom_sha1.go
Last active December 19, 2022 10:25
Golang - Generate random SHA1 hash
// Source: https://stackoverflow.com/questions/12321133/golang-random-number-generator-how-to-seed-properly
package main
import (
"crypto/sha1"
"fmt"
"math/rand"
"time"
)
@ereli
ereli / countries.sql
Last active May 22, 2024 07:29 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes. PostgreSQL compatible
CREATE SEQUENCE country_seq;
CREATE TABLE IF NOT EXISTS country (
id int NOT NULL DEFAULT NEXTVAL ('country_seq'),
iso char(2) NOT NULL,
name varchar(80) NOT NULL,
nicename varchar(80) NOT NULL,
iso3 char(3) DEFAULT NULL,
numcode smallint DEFAULT NULL,
phonecode int NOT NULL,
@lechup
lechup / slugify.sql
Last active November 11, 2018 16:54 — forked from thomasbilk/slugify.sql
Pseudo Transliteration for Postgres aka `slugify`
CREATE OR REPLACE FUNCTION slugify(str text) RETURNS text AS $$
BEGIN
RETURN regexp_replace(
lower(translate(str,
'äëïöüáéíóúâêîûôåãõàèìòùřšěčůńýśćłęążźĄŃÝŚĆŁĘÄËÏÖÜÁÉÍÓÚÂÊÎÛÔÅÃÕÀÈÌÒÙŘŠĚČŮŻŹß ²ø®',
'aeiouaeiouaeiouaaoaeioursecunyscleazzANYSCLEAEIOUAEIOUAEIOUAAOAEIOURSECUZzs-2dR'
-- missing chars will be removed
)),
-- strip all others chars than [^a-z0-9 \-]
'[^a-z0-9 \-]',
@poy
poy / subcommands.go
Last active February 27, 2023 06:02
Simple Subcommands in Go
package subcommands
import (
"fmt"
"log"
"os"
"strings"
)
type Command interface {
@colophonemes
colophonemes / create_triggers
Last active February 17, 2024 15:15
Postgres TRIGGER to call NOTIFY with a JSON payload
CREATE TRIGGER person_notify AFTER INSERT OR UPDATE OR DELETE ON income
FOR EACH ROW EXECUTE PROCEDURE notify_trigger(
'id',
'email',
'username'
);
CREATE TRIGGER income_notify AFTER INSERT OR UPDATE OR DELETE ON income
FOR EACH ROW EXECUTE PROCEDURE notify_trigger(
'id',