Skip to content

Instantly share code, notes, and snippets.

View CodeAlDente's full-sized avatar

Code al Dente CodeAlDente

View GitHub Profile
@CodeAlDente
CodeAlDente / Trucking ranks (PPC Trucking GM)
Last active February 16, 2019 13:53
Returns the name of the rank of a trucker (PPC Trucking GM)
// PPC_Defines.inc
// Define trucker ranks
enum TTruckerRanks
{
RankStats, // Holds the required stats to get this rank
RankName[50] // Holds the name of the rank
}
new ATruckerRanks[][TTruckerRanks] =
{
@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]);
@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 / 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 / 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 / check-urls-from-file.bash
Created December 22, 2021 00:22
Check multiple URLs from file using bash
#!/bin/bash
#
# How to check status of URLs from text file
# https://stackoverflow.com/a/25136723
#
# This script reads a file with URLs (line-by-line) and checks their http status code
# The results will be written to a temporary file locaed in ~/tmp
#
@CodeAlDente
CodeAlDente / snippet__do_not_run_with_sh.bash
Last active May 25, 2022 22:06
[snippet] Don't run bash script with sh
#!/bin/bash
# Force a shell script to run under bash instead of sh
# https://stackoverflow.com/a/17752318
if [[ ! ${BASH_VERSION} ]]; then
echo "Sorry, please run this script with 'bash' only." 1>&2
exit 1
fi
@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 / 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 / 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 &quot; with a double quote (")
echo "$1" | sed -e 's/&quot;/"/g'