Skip to content

Instantly share code, notes, and snippets.

View sfate's full-sized avatar
🇺🇦
Glory to Ukraine, Glory to the Nation, fuck the russian federation! :feelsgood:

Oleksii Bobyriev sfate

🇺🇦
Glory to Ukraine, Glory to the Nation, fuck the russian federation! :feelsgood:
View GitHub Profile

Alerts are an extension of Markdown used to emphasize critical information. On GitHub, they are displayed with distinctive colors and icons to indicate the importance of the content.

An example of all five types:

> [!NOTE]  
> Highlights information that users should take into account, even when skimming.

> [!TIP]
> Optional information to help a user be more successful.

Demo:

Spoiler warning

Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag... just make sure you close <details> afterward.

console.log("I'm a code block!");
@sfate
sfate / fromhex.bash
Created March 13, 2024 22:15 — forked from mhulse/fromhex.bash
Bash function to convert hex to 256 terminal color.
# fromhex A52A2A
# fromhex "#A52A2A"
# BLUE_VIOLET=$(fromhex "#8A2BE2")
# http://unix.stackexchange.com/a/269085/67282
function fromhex() {
hex=$1
if [[ $hex == "#"* ]]; then
hex=$(echo $1 | awk '{print substr($0,2)}')
fi
r=$(printf '0x%0.2s' "$hex")
@sfate
sfate / upd.sh
Last active April 15, 2024 08:27
Update asdf plugins
brew upgrade asdf
# asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
# asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
# asdf plugin add golang https://github.com/asdf-community/asdf-golang.git
asdf install ruby 3.2.2
asdf install nodejs 20.11.0
asdf install golang 1.22.0
@sfate
sfate / README.md
Last active January 18, 2023 17:38
Pretty print objects in golang

TL;DR

Function that provides ability to print variable values in golang. No external dependencies are used. Try it online: https://go.dev/play/p/mxbwyIUSLVZ

Legend

Sometimes printing some variable value in golang might be challenging or not easy to follow. Current implementation just simply wraps passed object into json and prints it in STDOUT.

package main
import "fmt"
var (
Info = Teal
Warn = Yellow
Fata = Red
)
@sfate
sfate / README.md
Last active January 6, 2023 18:40
[go] Test equality for two structs with human readable output

TL;DR

Function that provides ability to compare two structs in human-readable diff output with testify package. Try it online: https://go.dev/play/p/1v288fhRk9T

Legend

testify package for golang provides Equal function to compare structs (lists, arrays, etc). Unfortunately, it doesn't prints actual values for time objects in output diff.

@sfate
sfate / change-codec.md
Last active January 10, 2023 17:56 — forked from dvf/change-codec.md
Enable High Quality mode on your headphones (Updated for macOS Catalina)

If you're using a high-end bluetooth headset on your Macbook Pro it's likely your mac is using an audio codec which favors battery efficiency over high quality. This results in a drastic degradation of sound, the SBC codec is the likely culprit, read more about it here.

Find out what codec you're using

  1. Play a song on your headphones
  2. Option (⌥) click the Bluetooth button at the top of your screen Inspect the Bluetooth Coded
  3. If you're using AAC or aptX, you can stop here—those are the highest quality codecs.

Change your codec to AAC or aptX

@sfate
sfate / install_postgis.sh
Created November 10, 2021 23:29
Install postgis with postgresql@12 for macOS
#!/bin/bash
TMP_DIR="./tmp"
mkdir -p $TMP_DIR
function install_sfcgal() {
SFCGAL_FORMULAE_PATH="$TMP_DIR/sfcgal.rb"
DOWNLOAD_URL="https://gist.githubusercontent.com/sfate/cc92b94657ed4fcf3b35b17849e4d65a/raw/69db8b4c9401c8914babf854af5512ab4f897e19/sfcgal.rb"
curl -s $DOWNLOAD_URL -o "$SFCGAL_FORMULAE_PATH"
@sfate
sfate / sfcgal.rb
Last active August 26, 2021 15:31
homebrew's formulae for sfcgal patched package (fixed build for macOS-arm64)
class Sfcgal < Formula
desc "C++ wrapper library around CGAL"
homepage "http://sfcgal.org/"
url "https://gitlab.com/sfate/SFCGAL/-/archive/v1.3.10/SFCGAL-v1.3.10.tar.gz"
sha256 "64a184ce4090508cbd3d947966ed295173632395452465856febc23e8641d5be"
license "LGPL-2.0-or-later"
bottle do
sha256 arm64_big_sur: "64a184ce4090508cbd3d947966ed295173632395452465856febc23e8641d5be"
sha256 big_sur: "d3db5932f5c16c7612a3491fe635aede4c3fdba1dcf4fb46641e13a42bb8242d"