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 May 15, 2024 18:30
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" }
@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 April 8, 2024 19:23
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 May 3, 2024 12:55
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 = () => {
@fbaierl
fbaierl / ForkMITLicensedProject.md
Created November 6, 2018 14:17
HOWTO fork a MIT licensed project

No, you are not allowed to change the copyright notice. Indeed, the license text states pretty clearly:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

But you are allowed to add a copyright notice.

If you want to keep the MIT license, which is what I would advise you to do, you only need to add a single line to the license file, before or after Copyright (c) 2012 Some Name with your own copyright notice. The final LICENSE file will look like this:

The MIT License (MIT)

@F21
F21 / signing-gpg-keys.md
Last active May 5, 2024 20:59
Signing someone's GPG key

This is a quick guide of the commands we use to sign someone's GPG key in a virtual key signing party.

Note: The steps cover only the technical aspects of signing someone's key. Before signing someone's key, you must verify their identity. This is usually done by showing government-issued ID and confirming the key's fingerprint

The commands will work for both GPG and GPG2.

I use Julian's key for the examples. His key id is 2AD3FAE3. You should substitute with the appropriate key id when running the commands.

Signing the key

  1. List the keys currently in your keyring: gpg --list-keys.