Skip to content

Instantly share code, notes, and snippets.

@JC3
JC3 / gensignals2.py
Last active February 17, 2025 20:24
example data generator
import math
import numpy as np
BCD_LENGTH = 100
BCD_SINE_CENTER = 300
A_CURVE = 1.5
B_SINE_AMP = 25
C_SINE_AMP = 50
D_SINE_AMP = 100
E_LENGTH = 100
@JC3
JC3 / crystalfontz.py
Last active February 3, 2024 17:03
Crystalfontz CFA-735 Display Example
# This demonstrates how to send/receive packets to a Crystalfontz
# display and also display text on the display. It does not demonstrate
# keypad input or anything like that but the CrystalFontz class can be
# used as a basis for adding whatever.
# -----------------------------------------------------------------------
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# This is free and unencumbered software released into the public domain.
@JC3
JC3 / Qt 5.15.2 Output.txt
Created November 3, 2022 17:37
Qt meta property ULongLong -> enum conversion tests
---
pass 2 Example::Red QVariant(int, 0) QVariant(int, 0)
pass 2 Example::Green QVariant(int, 1) QVariant(int, 1)
pass 2 Example::Blue QVariant(int, 2) QVariant(int, 2)
pass 3 Example::Red QVariant(uint, 0) QVariant(int, 0)
pass 3 Example::Green QVariant(uint, 1) QVariant(int, 1)
pass 3 Example::Blue QVariant(uint, 2) QVariant(int, 2)
FAIL 4 Example::Red QVariant(qlonglong, 0) QVariant(int, 3)
FAIL 4 Example::Green QVariant(qlonglong, 1) QVariant(int, 3)
FAIL 4 Example::Blue QVariant(qlonglong, 2) QVariant(int, 3)
@JC3
JC3 / example.cpp
Last active November 1, 2022 14:44
Qt: CSV row parsing (Excel style)
// example usage:
QFile csv(filename);
csv.open(QFile::ReadOnly | QFile::Text);
QTextStream in(&csv);
QStringList row;
while (readCSVRow(in, &row))
qDebug() << row;
@JC3
JC3 / factorio_item_tiers.md
Created October 28, 2022 15:35
Factorio Items By Tier

notes

  • a "tier" consists only of recipes whose ingredients are all either in a previous tier
  • nauvis represents natural resources
  • fake-steam just represents boilers and heat exchangers
  • fake-used-up-uranium-fuel-cell just represents a nuclear reactor

items by tier

products are listed in parentheses, ingredients are listed under each recipe.

@JC3
JC3 / camwiring.drawio
Created November 21, 2021 14:43
camwiring.drawio
<mxfile host="app.diagrams.net" modified="2021-11-21T14:37:56.386Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36" etag="QwgjRVQRrSWNwM3ymqs_" version="15.5.6" type="google"><diagram id="5Vq94SHMy1QQqwDmQbMv" name="Page-1">7Z1Bc6IwFIB/jcedAYKWHqttdy+7s7PuzJ6pRGSLxInY6v76DTUB4SmICoTpaw+V8EhC8r4S+HQckMly+5W7q8V35tFwYBnedkAeB5ZlGsQRf5KS3b5k6MgCnweeDMoKpsE/qo6UpZvAo+tcYMxYGAerfOGMRRGdxbkyl3P2ng+bszDf6sr1KSiYztwQlv4JvHixL3WGRlb+jQb+QrVsGnLP0lXBsmC9cD32flBEngZkwhmL96+W2wkNk8FT47I/7vnE3rRjnEbxOQf83m1fgvGSvf24n3rc5M/c+PtFde7NDTfyjGVv450aAp+zzUqGUR7T7bGBd19UuAE7ZqanK/KEsiWN+U6EyIosNWQyRUxVxXs24LaKWRwMNlGBrpxkP607GwfxQg5FjWGxwaiMwLDQyHtIEkxsRSwSheNFvBStPJripRiyyKNJE4bYWsecvdIJCxn/OJYY4mc+T/eozBKDNJ6zKJYYmKMkYuXOgsiXe+XWLzkISeWh+0LDsTt79T8aVa14dO5uwjgNYNyjXO2UHd6fE/UAAtnUlWQNnNCDCRsemS9VxmnoxsFbvtFjcyhb+MkC0Z0sP0aFaV+zDZ9RGXVIgDpwW0iiUxXFLvdpDCoS0+zuDsJWScD6SAe3hQQutHOqX2k/dnkgTsWLE6kX75T2R7zYn2HGSzqnlyM0AggNESFdEEr/5V6LEKioIYSqUryIUBVyRYQq453S/jSDkAMQc
@JC3
JC3 / VideoProbeSurface.h
Last active June 22, 2021 19:15
VideoProbeSurface for when your QVideoProbe isn't working.
#ifndef VIDEOPROBESURFACE_H
#define VIDEOPROBESURFACE_H
#include <QAbstractVideoSurface>
#include <QVideoSurfaceFormat>
/* A bit of a hack, but...
*
* Example:
*
@JC3
JC3 / ParseCIDR.cs
Created May 30, 2021 17:56
C# Parse CIDR IP address and mask
// quick and dirty, not very strict (accepts ipv6 on either side, and dotless ipv4)
static (IPAddress address, IPAddress mask) ParseCIDR (string str) {
string[] parts = str.Split('/');
if (parts.Length > 2)
throw new FormatException("Invalid CIDR string.");
else if (parts.Length == 1)
return (IPAddress.Parse(parts[0]), IPAddress.Broadcast);
else if (int.TryParse(parts[1], out int maskbits) && maskbits >= 0 && maskbits <= 32)
return (IPAddress.Parse(parts[0]), new IPAddress(0xFFFFFFFFL & IPAddress.HostToNetworkOrder(unchecked((int)0x80000000) >> (maskbits - 1))));
else
@JC3
JC3 / xvsync.cpp
Created November 3, 2019 22:53
x sync extension system counter list and test
// link to -lX11 -lXext
#include <cstdio>
#include <X11/Xlib.h>
#include <X11/extensions/sync.h>
#include <inttypes.h>
#include <sys/time.h>
#include <unistd.h>
static void testCounterFrequency (Display *display, XSyncSystemCounter *sc) {
@JC3
JC3 / RevisionDraft
Created April 6, 2015 22:59
Revision Draft
I am 33. I'm a freelance programmer in NYC. As a freelancer, I set my own schedule. I can fully commit. I value teaching others how to help themselves -- doing so creates better programmers, which creates a better future.
A community moderator should be accessible, open to criticism, and fair, accomplish big picture goals without alienating individuals in the process, and represent the community at all times. I believe in moderators as an extension of the community. I value low noise, individuals' parts in a larger whole, and transparency.
I believe in firm but *flexible* moderation: Communities grow organically, I will uphold evolving values. The community organically makes the correct decisions in matters that it has the power to make decisions on, and a moderator only exists to do the rest. I'm patient with even the most frustrating users, firm but gentle when needed. Frustration often stems from deeper systemic issues (but I know a troll when I see one).
I want to improve and organize general site doc