Skip to content

Instantly share code, notes, and snippets.

@root42
root42 / silent-night-pi-buzzer.c
Last active December 18, 2018 12:36
Playing "Silent Night" on a piezo buzzer attached to RasPi pin 35 (GPIO19/PWM1)
// compile and run using (requires root access):
// gcc -W -Wall buzzer.c -o buzzer -lpigpio -lpthread && sudo ./buzzer
#include <pigpio.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
// GPIO19 is PWM1
@root42
root42 / # shellcheck - 2018-12-20_14-24-55.txt
Created December 20, 2018 13:27
shellcheck on Ubuntu 18.04.1 LTS - Homebrew build logs
Homebrew build logs for shellcheck on Ubuntu 18.04.1 LTS
Build date: 2018-12-20 14:24:55
@root42
root42 / # guile - 2019-01-15_05-52-06.txt
Created January 15, 2019 15:46
guile on "CentOS release 6.9 (Final)" - Homebrew build logs
Homebrew build logs for guile on "CentOS release 6.9 (Final)"
Build date: 2019-01-15 05:52:06
@root42
root42 / assignment.cc
Created November 14, 2019 09:19
Destructors when using shared_ptr assignments
#include <iostream>
#include <memory>
class Base
{
public:
Base() { std::cout << "Base constructor" << std::endl; }
virtual ~Base() { std::cout << "Base destructor" << std::endl; }
};
@root42
root42 / thread.cc
Created November 14, 2019 12:05
How to crash a thread with a shared_ptr reference
#include <memory>
#include <iostream>
#include <thread>
int main()
{
std::shared_ptr<std::thread> mythread;
mythread.reset(
@root42
root42 / fire.c
Created September 26, 2018 20:09
#include <stdio.h>
#include <stdlib.h>
#include <alloc.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>
#define VIDEO_INT 0x10
#define SET_MODE 0x00
#define VGA_256_COLOR_MODE 0x13
@root42
root42 / mode13.c
Created April 5, 2020 20:40
Using Turbo C with Inline Assembly
#include <conio.h>
#include <stdio.h>
int main()
{
unsigned char i;
int j;
asm mov ah, 0x00;
asm mov al, 0x13;
asm int 0x10;
@root42
root42 / firework.bas
Created December 30, 2020 21:33
Let's Code MS-DOS 0x19: Fireworks in PowerBasic
$CPU 80286
$LIB EGA ON
$ERROR ALL OFF
$OPTIMIZE SPEED
$COMPILE EXE
defint A-Z
REM =================
REM Global variables
@root42
root42 / viospa.asm
Created November 11, 2021 11:07
Detect video card in MS DOS
;*********************************************************************;
;* V I O S P A *;
;*-------------------------------------------------------------------*;
;* Task : Creates a function for determining the type *;
;* of video card installed on a system. This *;
;* routine must be assembled into an OBJ file, *;
;* then linked to a Turbo Pascal program. *;
;*-------------------------------------------------------------------*;
;* Author : Michael Tischer *;
;* Developed on : 10/02/88 *;
@root42
root42 / silent-night-omega2.py
Last active September 10, 2022 23:41
Plays "silent night" on a piezo buzzer attached to pin 18 of the Onion Omega2
#!/usr/bin/env python
# Plays "silent night" on a piezo buzzer attached to pin 18 of the Onion Omega2
# Things required: python lite, pwm needs to be enabled via:
# omega2-ctrl gpiomux set pwm0 pwm
from time import sleep
exportStr="/sys/class/pwm/pwmchip0/export"
periodStr="/sys/class/pwm/pwmchip0/pwm%s/period"
dutyStr="/sys/class/pwm/pwmchip0/pwm%s/duty_cycle"