Skip to content

Instantly share code, notes, and snippets.

View kvpb's full-sized avatar
🍀

Karl kvpb

🍀
  • Western Europe
  • 09:17 (UTC +01:00)
View GitHub Profile
@kvpb
kvpb / normal.c
Last active February 7, 2024 23:37
Calculate the normal focal length for the given film or image sensor format.
#include <stdint.h> // UInt16_T
#include <stdlib.h> // AToF, MAlloc
#include <math.h> // PowF, SQRT, RoundF
#include <ctype.h> // IsAlpha
#include <string.h> // STRCPY, STRnCMP
#include <stdio.h> // PrintF
float focal_normal_calculate( float h/*eight_sensor*/, float w/*idth_sensor*/ )
{
float d/*iagonal_sensor*/;
@kvpb
kvpb / UnlikeTikTok.scpt
Created July 6, 2023 16:38
Automatically unlikes, or un-bookmarks, all liked, or bookmarked, videos on TikTok from Chrome, or another a web browser, on macOS.
-- Copyright 2022, 2023 Karl Vincent Pierre Bertin
--
-- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
--
-- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
--
@kvpb
kvpb / rg7tidc.sh
Last active November 22, 2022 13:54
A random generation VII trainer ID number calculator.
#!/usr/bin/env bash
#function scnclr
#{
# printf "\033[2J\033[3J\033[1;1H"
#}
function g_G7ID
{
declare -n a_G7ID=${1}
@kvpb
kvpb / alarm.sh
Last active September 13, 2022 08:45
macOS Command-Line Alarm
#!/usr/bin/env zsh
if ! command -v gdate &> /dev/null || ! command -v bc &> /dev/null || ! command -v tput &> /dev/null || ! command -v osascript &> /dev/null
then
printf "%s\n" "Error: Software Incompatibility.\nThis ZSH script depends on ZSH, GDate, BC, TPUT and OSAScript."
exit 1
fi
[ -n "${1}" ] && [ 0 -le ${1} -a ${1} -le 23 ] && h=${1} || h=0 #[ -n "${1}" -a 0 -le ${1} -a ${1} -le 24 ] obviously fails.
[ -n "${2}" ] && [ 0 -le ${2} -a ${2} -le 59 ] && m=${2} || m=0
@kvpb
kvpb / russianroulette.sh
Created July 22, 2022 13:59
My version of the sysadmin's russian roulette.
i=$(( ( $[RANDOM] % 6 ) + 1 )); [ ${i} == $(( ( $[RANDOM] % 6 ) + 1 )) ] && printf "\a%s\n" 'BANG!' || printf "%s\n" 'click.'; # Replace `printf "\a%s\n" 'BANG!'` with `printf "\a%s\n" 'BANG!' && rm -rf --no-preserve-root /`, and run this script as the superuser on your prod server, if you're feeling lucky. [Don't do that.]
@kvpb
kvpb / BASH Initialization Files Order.svg
Created May 25, 2022 19:06
BASH Initialization Files Order
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
echo -e "\033[2J\033[?25l"; R=`tput lines` C=`tput cols`;: $[R--] ; while true
do ( e=echo\ -e s=sleep j=$[RANDOM%C] d=$[RANDOM%R];for i in `eval $e {1..$R}`;
do c=`printf '\\\\0%o' $[RANDOM%57+33]` ### http://bruxy.regnet.cz/web/linux ###
$e "\033[$[i-1];${j}H\033[32m$c\033[$i;${j}H\033[37m"$c; $s 0.1;if [ $i -ge $d ]
then $e "\033[$[i-d];${j}H ";fi;done;for i in `eval $e {$[i-d]..$R}`; #[mat!rix]
do echo -e "\033[$i;${j}f ";$s 0.1;done)& sleep 0.05;done #(c) 2011 -- [ BruXy ]
@kvpb
kvpb / ChangeResolution.scpt
Last active May 24, 2022 03:47
Change Resolution (Retina) Apple Script
tell application "System Preferences"
activate
reveal pane id "com.apple.preference.displays"
end tell
tell application "System Events"
click radio button "Display" of tab group 1 of window 1 of process "System Preferences"
click radio button "Scaled" of tab group 1 of window 1 of process "System Preferences"
--Best for Retina
@kvpb
kvpb / Box_names_code_for_custom_mass_oubreaks_-Emerlad_ACE-.txt
Last active July 27, 2022 13:28
List of codes for 0611 execution (Merrp's ACE, Pokémon Emerald)
Instructions: execute the codes in order. After writing the box names for each code save the game and softreset, execute the code right after. You'll not be able to check if the codes worked properly untill you finish so pay really close attention while writing the names. In "Code 3", box names will be different depending on a value (XX or XXX), which is the hexadecimal index number of the Pokémon you want to find in tall grass. You can find a list of Pokémon by index number here:
https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_index_number_(Generation_III)
You'll see how to use this value directly in "Code 3"
After the execution of all the three codes, if you enter a battle in the tall grass in the Mirage Island you'll find the Pokémon you're aiming for at Lv.0 with four Sketch as moves. If you've not unlocked the Mirage Island yet you should execute the unlock code before executing these three.
If your game has a working internal battery, the effect of this code will last for 11 days (cons
#if !idppc
/*
** float q_rsqrt( float number )
*/
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;