Skip to content

Instantly share code, notes, and snippets.

@brianmed
brianmed / Program.cs
Created December 3, 2023 20:27
Download Email via IMAP with MailKit
using MimeKit;
using MailKit;
using MailKit.Search;
using MailKit.Security;
using MailKit.Net.Imap;
namespace MailKitDownloadImap;
class Program
{
Main XAML:
<TableView Intent="Data" HasUnevenRows="true">
<TableRoot>
<TableSection
Title="Images"
x:Name="ImagesTableSection">
</TableSection>
@brianmed
brianmed / gogo.sh
Created June 27, 2023 01:02
.NET CLI Bash Script for Cleaning, Publishing, and Launching Maui apps. Currently iOS specific.
#! /bin/bash
set -e
GNU_GETOPT=getopt
# TODO: icky
if [ -d "/usr/local/Cellar/gnu-getopt/2.39/bin" ]; then
GNU_GETOPT="/usr/local/Cellar/gnu-getopt/2.39/bin/getopt"
fi
@brianmed
brianmed / ffmpegBatchTranscode.sh
Created June 18, 2023 18:05
Bash script to batch transcode to H265
#!/bin/bash
#
# FFmpeg Batch convert files to HEVC
#
# Auto rename files to "{source}.HEVC.CQ-RF18.mp4"
#
# Batch transcode video files recursively from input directory, and create a
# empty, mirrored directory tree of input directory to new "output" directory.
#
@brianmed
brianmed / canvasWithWorker.html
Created June 6, 2023 13:53
Webcam in Chrome with offscreen rendering and a Worker and GetUserMedia
<html>
<head>
<title>Joy</title>
</head>
<body>
<button id="joy-button">Joy</button>
<canvas id="canvas0" width="1280" height="720"></canvas>
<script>
@brianmed
brianmed / joy.c
Created June 2, 2023 10:33
Decode H264 Frame with FFmpeg
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
void my_log_callback(void *ptr, int level, const char *fmt, va_list vargs)
@brianmed
brianmed / Program.cs
Created May 24, 2023 00:44
C# macOS getrlimit example via DllImport
using System.Runtime.InteropServices;
namespace getrlimit;
class Program
{
[DllImport("libc", CallingConvention = CallingConvention.Cdecl)]
public static extern int getrlimit(int resource, IntPtr rlp);
[StructLayout(LayoutKind.Sequential)]
@brianmed
brianmed / launch.json
Created April 6, 2023 00:24
Visual Studio Code Remote Debugging Example
{
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"program": "app.dll",
"args": ["--urls=http://*:8000"],
"cwd": "/home/bpm/appDirectory",
"stopAtEntry": false,
@brianmed
brianmed / Program.cs
Last active February 11, 2023 20:22
C# Repeat Slow Task
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
namespace JoyRepeateTask;
public class Program
{
@brianmed
brianmed / FFmpegProbePackets
Created December 18, 2022 02:39
Small Program that Outputs Number of Streams in a Container via FFmpeg
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>