Skip to content

Instantly share code, notes, and snippets.

View BolajiOlajide's full-sized avatar

Bolaji Olajide BolajiOlajide

View GitHub Profile
@BolajiOlajide
BolajiOlajide / op.sh
Created January 6, 2025 21:35
unmask .env file with 1password secret references into it's plain text equivalent. (entries must be in the format `KEY="op://..."` )
#!/bin/bash
# Input and output file paths
INPUT_FILE="api.env" # Replace with your file name
OUTPUT_FILE="api-output.env" # The file to write resolved secrets
# Clear or create the output file
: > "$OUTPUT_FILE"
# Process each line in the input file
@BolajiOlajide
BolajiOlajide / err.go
Created December 30, 2024 01:55
Go error stack with slog
func Error(val error) slog.Attr {
stack := make([]byte, 4096)
n := runtime.Stack(stack, false)
return slog.Group("error",
slog.String("exception.message", val.Error()),
slog.String("exception.stacktrace", fmt.Sprintf("%s", stack[:n])),
)
}
package main
import (
"bytes"
"fmt"
"image/color"
"github.com/BolajiOlajide/testrun"
"github.com/yeqown/go-qrcode/v2"
"github.com/yeqown/go-qrcode/writer/standard"
@BolajiOlajide
BolajiOlajide / compress_video
Created August 22, 2024 11:19 — forked from trvswgnr/compress_video
portable shell script to compress videos with ffmpeg
#!/bin/sh
print_usage() {
echo "usage: compress_video <input_file>"
echo "supported formats: mp4, webm, mkv, mov, avi, flv"
}
get_extension() {
f="${1##*/}"
case "$f" in
@BolajiOlajide
BolajiOlajide / abstract_class.kt
Last active August 6, 2024 00:16
abstract_class.kt
fun main() {
Repository.startFetch()
getResult(Repository.getCurrentState())
Repository.finishFetch()
getResult(Repository.getCurrentState())
Repository.error()
getResult(Repository.getCurrentState())
}
@BolajiOlajide
BolajiOlajide / enums.kt
Last active August 6, 2024 00:02
Enums and State in Kotlin
fun main() {
Repository.startFetch()
getResult(Repository.getCurrentState())
Repository.finishFetch()
getResult(Repository.getCurrentState())
Repository.error()
getResult(Repository.getCurrentState())
}
@BolajiOlajide
BolajiOlajide / oop_kotlin.kt
Last active August 5, 2024 23:52
OOP in Kotlin
/**
* You can edit, run, and share this code.
* play.kotlinlang.org
*/
fun main() {
val myCar = Car()
println(myCar.color)
println(myCar.model)
myCar.drive()
@BolajiOlajide
BolajiOlajide / learn_kotlin.kt
Last active July 31, 2024 01:17
learning kotlin synthax
/**
* You can edit, run, and share this code.
* play.kotlinlang.org
*/
fun main() {
val amount = 90
when (amount) {
in 1..10 -> println("in between one and ten")
!in 11..20 -> println("not in between 11 and 20")
@BolajiOlajide
BolajiOlajide / csv_strip_dupes.go
Created June 25, 2024 02:50
Remove duplicate emails from a csv and output the result to a new one.
package main
import (
"encoding/csv"
"fmt"
"os"
"strings"
)
func main() {
@BolajiOlajide
BolajiOlajide / gradient.js
Created October 26, 2023 12:59
svelte-paint-gradient.js
export function paint(context, t) {
const { width, height } = context.canvas;
const imageData = context.getImageData(0, 0, width, height);
for (let p = 0; p < imageData.data.length; p += 4) {
const i = p / 4;
const x = i % width;
const y = (i / width) >>> 0;
const red = 64 + (128 * x) / width + 64 * Math.sin(t / 1000);