Skip to content

Instantly share code, notes, and snippets.

View novelistparty's full-sized avatar

novelistparty novelistparty

View GitHub Profile
@merlinmann
merlinmann / wisdom.md
Last active April 17, 2024 21:52
Merlin's Wisdom Project (Draft)

Merlin's Wisdom Project

Or: “Everybody likes being given a glass of water.”

By Merlin Mann.

It's only advice for you because it had to be advice for me.

@rlcamp
rlcamp / inline_c.sh
Last active October 11, 2022 22:54
for when you really just need to run a bit of C logic from a bash script
#!/bin/bash
TMPFILE=$(mktemp)
cc -Wall -Wextra -Wshadow -Os -lm -o ${TMPFILE} -x c <(tail -n+$(awk '/^exit$/ { print NR + 1 }' $0) $0) && chmod +x ${TMPFILE} && ${TMPFILE} "$@"
rm ${TMPFILE}
exit
#include <stdio.h>
#include <unistd.h>
int main(const int argc, const char ** const argv) {
@rlcamp
rlcamp / tunnel_wireguard_over_serial.c
Last active May 19, 2022 16:18
allow Wireguard to replace ppp
/* isc license probably */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
@rlcamp
rlcamp / configure
Last active February 1, 2024 20:38
#!/usr/bin/env bash
# richard campbell
# isc license
#
# assumptions/caveats:
# - this script is run by bash 3.2+, produces a Makefile suitable for gnu make 3.81+
# - targets to build have a main function in a .c file of the same name
# - each module depended upon is in the same directory
# - each module depended upon consists of one .c and one .h file
# - if you need to link in external libraries, you still need to manually provide those to make via LDLIBS

Getting started developing/debugging on embedded STM32 ARM microcontrollers with Visual Studio Code on Windows

Straight to the point

If you're only interested in the setup process, skip to Step 1 below and ignore my rantings.

Background

I spent a lot of time over the past few years with embedded projects in various IDE's from different silicon companies, all based on Eclipse, and all equally painful and horrible to use. Eclipse is an ancient and stagnant platform, filled with bugs, lacking many features some would consider mandatory in a modern IDE. The process of writing code in Eclipse drains every drop of joy out of the process, like muddy water squeezed out of a wet rag.

I couldn't take it anymore. Something had to change. If I couldn't have code completion, fast intelligent code navigation or even a working visual debugger, why even use an IDE in the first place?

@katef
katef / life-utf8.c
Last active May 5, 2024 21:56
XBM to UTF-8 braille image things
/*
* John Conway's Game of Life.
*
* This is written for POSIX, using Curses. Resizing of the terminal is not
* supported.
*
* By convention in this program, x is the horizontal coordinate and y is
* vertical. There correspond to the width and height respectively.
* The current generation number is illustrated when show_generation is set.
*
@mmalex
mmalex / allpasstest.cpp
Created March 4, 2020 14:55
quick timing test of different ways of writing a chain of serial allpasses
#include "stdafx.h"
#include <Windows.h> // for performance counter
// quick test of the theory in https://gist.github.com/mmalex/3a538aaba60f0ca21eac868269525452
// we try running a simple impulse train (click every 4096 samples) through 6 allpasses with random lengths
// we time how long it takes to process 1 million samples, structuring the loop 3 ways:
// - a sample at a time with self contained allpass structures,
// - a sample at a time with a single big buffer
// - a block at a time using self contained allpass structures, operating in place on a 256 sample buffer.
// using this naive code, on a single core of my AMD threadripper, with default release compile settings on visual studio 2015,
// I see
@rlcamp
rlcamp / coroutine.c
Last active March 4, 2022 22:53
Coroutines for generator functions, sequential pipelines, state machines, and other uses in C
see https://github.com/rlcamp/coroutine
@jemmons
jemmons / Create Input with Block.swift
Last active November 17, 2022 07:04
Sample CoreMIDI code…
// See: https://forums.developer.apple.com/thread/65997
MIDIInputPortCreateWithBlock(midiClient, "Instrument" as CFString, &inPort, {
(unsafePacketList: UnsafePointer<MIDIPacketList>, pointer: UnsafeMutableRawPointer?) in
let packetList = unsafePacketList.pointee
if packetList.numPackets == 1 {
let packet = packetList.packet
if packet.length == 3 && packet.data.0 == 144 {
/* Note-On */
let note = packet.data.1
@MonsieurV
MonsieurV / createImageBitmap.js
Last active February 16, 2021 11:04
createImageBitmap polyfill with Blob and ImageData source support
/*
* Safari and Edge polyfill for createImageBitmap
* https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap
*
* Support source image types Blob and ImageData.
*
* From: https://dev.to/nektro/createimagebitmap-polyfill-for-safari-and-edge-228
* Updated by Yoan Tournade <yoan@ytotech.com>
*/
if (!('createImageBitmap' in window)) {