Skip to content

Instantly share code, notes, and snippets.

@Nkawu
Nkawu / script-template.sh
Created December 18, 2020 06:05 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@Nkawu
Nkawu / perl_inline_c_asm.pl
Created June 11, 2019 22:35
perl script running inline C running inline ASM
#!/usr/bin/env perl
use Inline 'C';
my $a = 10;
my $b = 15;
print "$a + $b = ", add_c_asm($a, $b), "\n";
__END__
@Nkawu
Nkawu / pl_inlinec.pl
Last active June 11, 2019 22:42
Embedding assembly language into C into perl. Not sure if it serves any purpose other than being geeky.
#!/usr/bin/env perl
# cpanm Inline::C
use Inline 'C';
my $a = 10;
my $b = 15;
print "$a + $b = ", add_c_asm($a, $b), "\n";
@Nkawu
Nkawu / ATtiny85 PWM.ino
Last active April 24, 2022 15:12
PWM on the ATtiny85 with a complementary waveform & dead time
void setup()
{
// DDRB – Port B Data Direction Register (p64)
// 8-bit R/W [ : :DDB5:DDB4:DDB3:DDB2:DDB1:DDB0]
// PORTB = 1<<DDB1 | 1<<DDB0;
pinMode(0, OUTPUT); // 1<<DDB0: PWM output on pin 0 (^OC1A)
pinMode(1, OUTPUT); // 1<<DDB1: PWM output on pin 1 (OC1A)
// TCCR1 - Timer/Counter1 Control Register (p89)
// 8-bit R/W: [CTC1:PWM1A:COM1A1:COM1A0:CS13:CS12:CS11:CS10]