Skip to content

Instantly share code, notes, and snippets.

@nramsbottom
nramsbottom / main.c
Last active March 25, 2023 22:45
SDL Quickstart
#include <stdio.h>
#include <SDL2\SDL.h>
// assumes installed using vcpkg
#ifdef _DEBUG
#pragma comment(lib, "SDL2d")
#pragma comment(lib, "SDL2maind")
#else
#pragma comment(lib, "SDL2")
using System.Globalization;
using System.Text;
using CsvHelper;
using CsvHelper.Configuration;
var sourcePath = @"C:\Users\nramsbottom\Desktop\Food Shopping.csv";
var reader = new StreamReader(sourcePath, Encoding.UTF8);
var parser = new CsvReader(reader, new CsvConfiguration(CultureInfo.InvariantCulture)
@nramsbottom
nramsbottom / AzureQueueWriter.cs
Last active June 28, 2021 21:23
Azure Queue Writer
using System;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Azure.Storage.Queues; // Azure.Storage.Queues@12.7.0
namespace GitHub.nramsbottom.Azure.Storage.Queues
{
public class AzureQueueWriter<T> where T : class, new()
{
@nramsbottom
nramsbottom / boot.asm
Created January 18, 2021 20:32
Simple Bootloader
; dd if=/dev/zero of=boot.img count=1440 bs=1k
; nasm boot.asm -f bin -o boot.bin
; dd if=boot.bin bs=512 of=boot.img conv=notrunc
; od -t x1 -A n boot.bin
; A simple boot sector that prints a message to the screen using a BIOS routine.
;
mov ah,0x0e ; int 10/ ah = 0eh -> scrolling teletype BIOS routine
mov al,'H'
int 0x10
@nramsbottom
nramsbottom / IsFileLocked.cs
Created September 4, 2020 19:40
C#: Check if file is locked
public static bool IsFileLocked(string path)
{
try
{
using var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.None);
}
catch (IOException ex)
{
if (ex.HResult == -2147024864)
return true; // file is locked
@nramsbottom
nramsbottom / ReadAsciiZeroString.cs
Created March 29, 2020 02:32
Read ASCII zero terminated string from byte array
private string ReadAsciiZeroString(byte[] bytes)
{
for (int n = 0; n < bytes.Length; n++)
{
if (bytes[n] == '\0')
return System.Text.Encoding.ASCII.GetString(bytes, 0, n);
}
return string.Empty;
}
@nramsbottom
nramsbottom / rebuild-all.sh
Created March 29, 2020 00:02
Rebuild MP4
#!/bin/bash
# this is a script that was made to extract the video and *second* audio stream
# from an all the mp4 files in the current directory and rebuild them to contain
# just the video and the second audio stream
for filename in *.avi; do
ffmpeg -y -i "$filename" -an -vcodec copy video.mp4
ffmpeg -y -i "$filename" -map 0:2 -vn -acodec copy audio.mp3
void show_bits(unsigned int i) {
printf("|32 |24 |16 |8 |\n");
for (int n = 31; n >= 0; n--) {
printf("%u", (0x1 << n) & i ? 1 : 0);
}
printf(" %8X %u", i, i);
printf("\n");
}
@nramsbottom
nramsbottom / Program.cs
Created October 14, 2019 13:24
LogFilter - Simple application for filtering content from large w3c logs.
using System.IO;
namespace LogFilter
{
class Program
{
static void Main(string[] args)
{
const string InputPath = @"D:\Temp\u_ex191014.log";
const string OutputPath = @"D:\Temp\output.log";
@nramsbottom
nramsbottom / Program.cs
Created July 25, 2019 11:47
Generate Audio Tone
using System;
using System.IO;
namespace GenerateTone
{
class Program
{
static void Main(string[] args)
{
// generate one second of 1khz audio