Skip to content

Instantly share code, notes, and snippets.

View xpepper's full-sized avatar
💭
😏

Pietro Di Bello xpepper

💭
😏
View GitHub Profile
@xpepper
xpepper / generate-commit.sh
Last active April 30, 2024 19:44
An AI-driven git commit message generator. It needs a valid OpenAI key set as an env variable`OPENAI_API_KEY`. It works on macOS, needs curl and jq in order to work.
#!/bin/bash
OPENAI_API_KEY="${OPENAI_API_KEY}"
HOST="https://api.openai.com"
MODEL="gpt-3.5-turbo"
# Check if the API key is set
if [ -z "$OPENAI_API_KEY" ]; then
echo "OpenAI API key is not set. Please set the OPENAI_API_KEY environment variable."
exit 1

If you want to invest your next learning session with a code kata (TL;DR: you should), here's an opinionated list of kata catalogs:

Remember, when tackling a kata, you should first have a clear idea of what you want to learn or what skills you want to sharpen (e.g., improving TDD skills, refactoring skills, code design skills, etc.). If you want to impr

@xpepper
xpepper / practicing ownership and borrowing.md
Last active April 20, 2024 14:27
practicing ownership and borrowing (chatGPT 4 Turbo via perplexity.ai)

Certainly! I'll provide you with some code examples that illustrate common mistakes related to ownership and borrowing in Rust. For each example, you can determine whether it would compile or not, and I'll explain why it should or should not compile based on Rust's rules.

Example 1: Multiple Ownership Attempt

fn main() {
    let s1 = String::from("hello");
    let s2 = s1;
    let s3 = s1;
@xpepper
xpepper / practicing ownership and borrowing.md
Created April 19, 2024 21:39
practicing ownership and borrowing (`mixtral-8x7b-instruct-v0.1`)

Sure, I'd be happy to help you practice recognizing ownership and borrowing violations in Rust! Here are some code examples for you to evaluate:

Example 1:

let mut s = String::from("hello");

let r1 = &s;
let r2 = &s;
println!("{}, {}", r1, r2);
@xpepper
xpepper / practicing ownership and borrowing.md
Last active April 19, 2024 21:53
practicing ownership and borrowing (perplexity.ai)

Here are some Rust code examples that involve ownership and borrowing. For each example, determine whether it will compile and explain why or why not based on Rust's ownership and borrowing rules.

Example 1

fn main() {
    let s1 = String::from("hello");
    let s2 = &s1;
    drop(s1);
    println!("s2 says: {}", s2);
}
@xpepper
xpepper / universal-switcher.md
Created November 24, 2023 07:56 — forked from jthodge/universal-switcher
Show macOS app switcher across all monitors
defaults write com.apple.dock appswitcher-all-displays -bool true && killall Dock
@xpepper
xpepper / ktor.kt
Created November 2, 2023 15:41
Testing Ktor response validation
import com.casavo.gluglu.core.infrastructure.http.installLoggingConfiguration
import com.casavo.gluglu.core.infrastructure.http.installUserAgentConfiguration
import io.ktor.client.HttpClient
import io.ktor.client.request.get
import io.ktor.client.request.url
import io.ktor.http.isSuccess
import kotlinx.coroutines.runBlocking
val client = HttpClient {
expectSuccess = true
@xpepper
xpepper / map.md
Created October 10, 2023 10:30
The Ultimate Guide to Developer Counter-Productivity
@xpepper
xpepper / aws_db_connections.sh
Last active November 15, 2022 21:21
Print the db connection count for an AWS RDS db
#!/usr/bin/env bash
export AWS_PAGER=""
db_connections () {
echo "## ${1}:"
aws cloudwatch get-metric-statistics \
--namespace AWS/RDS \
--dimensions Name=DBInstanceIdentifier,Value=$1 \
--metric-name DatabaseConnections \
@xpepper
xpepper / mega_uploader.sh
Last active October 29, 2022 17:24
Mega Uploader Script
#!/bin/bash
mega_user="<MEGA ACCOUNT EMAIL>"
mega_pass="<MEGA ACCOUNT PWD>"
mega_path="<MEGA REMOTE TARGET FOLDER>"
folder="${mega_path}/$(date +'%Y-%m-%d')"
megamkdir -u ${mega_user} -p ${mega_pass} "${folder}" --reload
megaput -u ${mega_user} -p ${mega_pass} --path "${folder}" *.mp3 --reload