Skip to content

Instantly share code, notes, and snippets.

View kvpb's full-sized avatar
🍀

Karl kvpb

🍀
  • Paris, France
  • 08:33 (UTC +02: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 / script72.sh
Last active July 28, 2022 11:14
Test Script 72: delete directory from user home
#!/usr/bin/env bash
if [ -d "${symbolic_link_or_directory}" ]; # If symbolic_link_or_directory exists...
then
if [ -L "${symbolic_link_or_directory}" ]; # If symbolic_link_or_directory is a symbolic link...
then
rm "${symbolic_link_or_directory}"; # Remove symbolic_link_or_directory.
else # Else, i.e. if symbolic_link_or_directory is a directory...
if [ $(ls -A "${symbolic_link_or_directory}") ]; # If symbolic_link_or_directory is empty...
then
@kvpb
kvpb / script71.sh
Last active July 28, 2022 11:13
Test Script 71: BASH pseudorandom brute-forcing
#!/usr/bin/env bash
mkdir directory && cd directory
for i in {0..99}
do
> file${i}
printf "make file${i}\n"
done #for i in {0..0}{0..9}{0..9}; do > file${i}; echo file${i}; done
@kvpb
kvpb / script69.sh
Last active July 28, 2022 11:12
Test Script 69: set macOS keyboard speed
#!/usr/bin/env bash
osascript -e 'tell application "System Preferences" to quit' #
defaults delete com.apple.universalaccess slowKey
defaults write com.apple.universalaccess slowKey -bool FALSE # Disable Slow Keys. (i) Required from macOS 10.12 Sierra onwards to set faster key repeat rates.
defaults delete com.apple.universalaccess slowKeyDelay
#defaults write com.apple.universalaccess slowKeyDelay -int 5 #
defaults delete NSGlobalDomain ApplePressAndHoldEnabled
@kvpb
kvpb / script73.sh
Last active July 28, 2022 11:08
Test Script 73: BASH pairwise comparison without duplicates
#!/usr/bin/env bash
var=( {0..9} ); #var=( $({0..$[RANDOM%+9]}) );
printf "Set: {$(var2=$(printf ", %s" "${var[@]}") && var2=${var2:2} && printf "${var2}\n";)}"'\n'"Pairs: "'\n';
for (( i = 0; i < ${#var[@]}; i++ ));
do
for (( j = i + 1; j < ${#var[@]}; j++ ));
do
# printf "(${i}, ${j}): "'%d\n'; #printf "(${!var[${i}]}, ${!var[${j}]}): "'%d\n'; # array element nummbers
@kvpb
kvpb / script70.sh
Last active July 28, 2022 10:56
Test Script 70: BASH pseudo-multidimensional array iteration over any dimension
#!/usr/bin/env bash
var1=([0]="first" [1]="second" [2]="third" [5]="sixth" [10]="eleventh");
n=([0]="0" [1]="1" [2]="2" [5]="5" [10]="10");
var2=([0]="zero" [1]="one" [2]="two" [5]="five" [10]="ten");
printf '\n`echo \"${var1[@]}\"` s output:\t'; echo "${var1[@]}";
printf '`echo \"${!var1[@]}\"` s output:\t'; echo "${!var1[@]}";
printf '\nWith `${var1[@]}`:\n';
#if !idppc
/*
** float q_rsqrt( float number )
*/
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;