Skip to content

Instantly share code, notes, and snippets.

@CodeAlDente
CodeAlDente / import_pocketbase.bash
Created September 30, 2024 03:30
Import data from a json file into a pocketbase collection using admin auth
#!/bin/bash
# This script automates the process of importing data from a JSON file into a specified collection
# within a PocketBase instance. It requires the PocketBase URL, the collection name, and the path to the
# JSON file as inputs. The script handles authentication using admin credentials, which can be loaded
# from a .env file or entered manually by the user if the file is not found.
#
# Key functionalities:
# - Validates input parameters, including the PocketBase URL, collection name, and JSON file path.
# - Handles authentication with the PocketBase API to retrieve an access token using admin credentials.
@CodeAlDente
CodeAlDente / shorturl-domains.txt
Created June 12, 2024 20:30
Domains to provide shorturls like bit.ly
0rz.tw
126.am
1link.in
1tk.us
1un.fr
1url.com
1url.cz
1-url.net
1wb2.net
23o.net
@CodeAlDente
CodeAlDente / fetch_buymeacoffee_profile_json_data.bash
Created December 16, 2023 00:22
Fetch JSON-data from a BuyMeACoffee profile page
#!/bin/bash
# Script Description:
# This Bash script fetches JSON data associated with a BuyMeACoffee profile
# for a specified username and decodes specific HTML entities in the retrieved data.
# Function to decode HTML entities in a string
html_entity_decode() {
# Use sed to replace HTML entity " with a double quote (")
echo "$1" | sed -e 's/"/"/g'
@CodeAlDente
CodeAlDente / slugify.bash
Created January 19, 2023 04:45
Simple "slugify" to give filenames a unified structure to handle them
# Slugify
#
# URL: https://duncanlock.net/blog/2021/06/15/good-simple-bash-slugify-function/
#
# Transliterate everything to ASCII
# Strip out apostrophes
# Anything that's not a letter or number to a dash
# Strip leading & trailing dashes
# Everything to lowercase
function slugify() {
@CodeAlDente
CodeAlDente / validateDomain.php
Created June 15, 2022 04:38
Validate domain names in PHP out-of-the-box
<?php
function validateDomain(string $domain) :bool {
/**
* First remove any whitespaces and set string to lowercase.
*/
$domain = trim($domain);
$domain = mb_strtolower($domain, "UTF-8");
/**
@CodeAlDente
CodeAlDente / check-urls-from-file.bash
Last active June 9, 2024 18:52
Check multiple URLs from file using bash
#!/bin/bash
#
# URL Status Checker
#
# This script reads a file containing URLs (one per line) and checks their HTTP status codes.
# The results are written to a temporary file located in the ~/tmp directory.
# It utilizes curl to perform HTTP HEAD requests and captures the status codes.
#
@CodeAlDente
CodeAlDente / stats.pwn
Last active January 21, 2018 19:05
Adjust this command to see other player's stats as well
// Displays the statictics of the player
COMMAND:stats(playerid, params[])
{
// Setup local variables
new StatsMsg[1000], TitleMsg[128], StatsPlayer;
// Send the command to all admins so they can see it
SendAdminText(playerid, "/stats", params);
// Check if the player has logged in
@CodeAlDente
CodeAlDente / PPC_Toll.inc
Last active January 24, 2018 16:33
Open toll gate if player is in range, keep it open while player is still in range (with trailer), close it only if player leaves the range (e.g. drives away, died, left server)
// This file holds all functions for the toll-system
forward Toll();
public Toll()
{
// Loop through all players
for(new playerid; playerid < MAX_PLAYERS; playerid++)
{
// If the player isn't connected, skip to the next player
if (APlayerData[playerid][LoggedIn] == false)
@CodeAlDente
CodeAlDente / PPC_Toll.inc
Created January 14, 2018 20:18
PPC Trucking - Close toll gate if player is no longer in range
// This file holds all functions for the toll-system
forward Toll();
public Toll()
{
// Loop through all players
for(new playerid; playerid < MAX_PLAYERS; playerid++)
{
// If the player isn't connected, skip to the next player
if(APlayerData[playerid][LoggedIn] == false) continue;
@CodeAlDente
CodeAlDente / snippet.pwn
Last active February 16, 2019 13:52
PPC Trucking: AdminLevel in external filterscripts; Updates admin level automatically if it has been changed
// place this somewhere in ~/pawno/include/PPC_Speedometer.inc
// i recommend at line 340, right after the money and score check
if (GetPVarInt(playerid, "AdminLevel") != APlayerData[playerid][PlayerLevel])
SetPVarInt(playerid, "AdminLevel", APlayerData[playerid][PlayerLevel]);