Skip to content

Instantly share code, notes, and snippets.

View ukazap's full-sized avatar

Ukaza Perdana ukazap

View GitHub Profile
@heri16
heri16 / 0-README.md
Last active April 26, 2024 09:08
Secure Short Unique IDs (for generating Invites Codes or Promo Codes or URL slug from Postgres Database)

What

This is open-source code that lets you generate short unique identifiers from numbers (within Postgres DB). These IDs are URL-safe, can encode several numbers, and do not contain common profanity words.

This is what they look like:

https://example.com/order/FHxkSB1ai
@evadne
evadne / lecture.md
Last active October 4, 2023 23:24
How to Sell Elixir (2023)

How to Sell Elixir AGAIN (2023)

Presented by Evadne Wu at Code BEAM Lite in Stockholm, Sweden on 12 May 2023

Synopsis

We have celebrated 10 years of Elixir and also nearly 25 years of Erlang since the open source release in December 1998.

Most of the libraries that were needed to make the ecosystem viable have been built, talks given, books written, conferences held and training sessions provided. A new generation of companies have been built on top of the Elixir / Erlang ecosystem. In all measures, we have achieved further reach and maturity than 5 years ago.

@gagarine
gagarine / win11-mouse-scroll-reverse.md
Last active November 2, 2024 07:23
Reverse Mouse Wheel scroll in Windows 11 (Natural Mode like MacOS)

Reverse Mouse Wheel scroll in Windows 11

Chose between natural mode like MacOS or Windows default mode.

Step 1: Open Windows PowerShell in Administrator Mode.

You can do this by going to Start Menu, type PowerShell, and click Run as Administrator.

Step 2: Copy the following code and paste it in the command line of Windows PowerShell:

$mode = Read-host "How do you like your mouse scroll (0 or 1)?"; Get-PnpDevice -Class Mouse -PresentOnly -Status OK | ForEach-Object { "$($_.Name): $($_.DeviceID)"; Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Enum\$($_.DeviceID)\Device Parameters" -Name FlipFlopWheel -Value $mode; "+--- Value of FlipFlopWheel is set to " + (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Enum\$($_.DeviceID)\Device Parameters").FlipFlopWheel + "`n" }
@sj26
sj26 / activerecord-lifetime.rb
Created March 3, 2022 01:38
ActiveRecord Connection Lifetime controls for using postgres with an autoscaling pgbouncer service safely
# frozen_string_literal: true
# Connection lifetime for ActiveRecord
#
# Make sure that connections to the database can only live for a certain number
# of seconds. Once lifetime is reached, the underlying connection will be
# reconnected. This is enforced when checking out a connection for use from the
# pool. Use in combination with idle_timeout to enforce connection lifetime on
# idle connections as well.
#
@mcxiaoke
mcxiaoke / miui-blotware-apps.md
Last active November 15, 2024 20:03
MIUI 13/14 bloatware apps, updated at 20240816

对于所有应用,不建议直接删除,使用adb shell pm disable-user package-name禁用即可,方便出问题时恢复。

DO NOT UNINSTALL:

  • com.miui.securitycenter
  • com.miui.securityadd
  • com.xiaomi.finddevice

(Don’t uninstall these three apps or services from your Xiaomi device. Otherwise, you may encounter device bricking or bootloop issues.)

@heri16
heri16 / README.md
Last active October 19, 2021 10:56
Binary encoding of OUCH messages in Elixir

Reuse logic in Elixir

Here are commons ways to reuse logic in Elixir:

1a. Move Function to other module (guards, pattern-matching) 1b. Protocol - Polymorphism

  1. Behaviour Dynamic-func - with def method_name(implemetation, args)
@heri16
heri16 / playground.go
Last active September 9, 2021 08:51
Nasdaq OUCH_4.2 golang
package main
import (
"bytes"
"encoding"
"encoding/binary"
"io"
"fmt"
"stockbit.com/proto/ouch42"
@johnjeffers
johnjeffers / ubuntu-20.04-macbook-pro.md
Created May 31, 2020 00:21
Ubuntu 20.04 on a 15" Retina MacBook Pro (Mid-2014)

Ubuntu 20.04 on a 15" Retina MacBook Pro (Mid-2014)

These are notes from my efforts to get Ubuntu 20.04 installed on my older MacBook Pro. I'm making this gist public in the hopes that it's helpful to others.

I did a Minimal install, but selected the option to install additional 3rd-party drivers.

Wifi doesn't work during the install (because it requires a 3rd-party driver), so you won't be able to choose to download updates while installing. No big deal, run a software update after the install.

The installer takes about 25 minutes to complete. Post-install, most things work. The only driver I had to manually install was for the FaceTime camera. More on that below.

@gimiki
gimiki / traefik_tcp_mqtt_mosquitto_docker_compose.md
Last active July 21, 2024 20:38
Traefik Reverse Proxy - Mosquitto MQTT Broker - Docker Container

This gist is to configure a Mosquitto MQTT Broker behind a Traefik reverse-proxy, both in a docker container. Mosquitto will be configuread as a TCP Service.

This is a simple configuration used on the same single server. Probably to be adapted for other cases. Having mosquitto behind a reverse proxy enables you to configure TLS on Traefik (likely you already do that for other applications as well) and to load balance different MQTT instances, but that goes beyond this gist.

As noted in Traefik docs, in the router you must use the rule HostSNI(`*`) when using non-TLS routers like in this example. Ref. https://docs.traefik.io/routing/routers/#rule_1

docker-compose.yml

@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active October 24, 2024 18:10
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {