Skip to content

Instantly share code, notes, and snippets.

View jessejjohnson's full-sized avatar

Jesse Johnson jessejjohnson

View GitHub Profile
action_pool_depth
Current value (from the default) = -1
From //build/toolchain/BUILD.gn:11
Pool for non goma tasks.
added_rust_stdlib_libs
Current value (from the default) = []
From //build/config/rust.gni:44
@jessejjohnson
jessejjohnson / Headers.ts
Created June 14, 2025 05:39
Typed HTTP Headers
// https://www.iana.org/assignments/http-fields/http-fields.xhtml
export type RequestHeader =
| 'A-IM'
| 'Accept'
| 'Accept-Additions'
| 'Accept-CH'
| 'Accept-Charset'
| 'Accept-Datetime'
| 'Accept-Encoding'
@jessejjohnson
jessejjohnson / StatusCodes.ts
Created June 14, 2025 05:38
Typed HTTP Status Codes
export type InfoStatusCode = 100 | 101 | 102 | 103
export type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226
export type DeprecatedStatusCode = 305 | 306
export type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308
export type ClientErrorStatusCode =
| 400
@jessejjohnson
jessejjohnson / lte_mbim_from_scratch.md
Created August 3, 2024 17:51 — forked from Juul/lte_mbim_from_scratch.md
How to use 4G LTE modems like the MC7455 on both Debian/Ubuntu and OpenWRT using MBIM

The purpose of this document is to get you familiar with the concepts and command line tools involved with connecting to the internet using modern 4G LTE modems on both Debian/Ubuntu and OpenWRT.

This writeup is based on my experiences with the Sierra Wireless AirPrime MC7455 modem and a Calyx (Sprint) SIM card, but it should apply to most modern 4G LTE modems.

High level overview

These are the steps required:

  • Physically connect antennas
@jessejjohnson
jessejjohnson / runDevBrowser.mjs
Last active May 13, 2025 06:56 — forked from SomeHats/runDevBrowser.mjs
A hacky local version of cloudflare's browser rendering API. To use this, copy either runDevBrowser.ts or runDevBrowser.mjs and install the puppeteer and ws packages from npm. Run the dev server alongside wranger with `node runDevServer.mjs` or `tsx runDevServer.ts`
/* eslint-disable no-console */
/***
* This is a little server that emulates the protocol used by cloudflare's browser rendering API. In
* local development, you can run this server, and connect to it instead of cloudflare's (strictly
* limited) API. e.g. in your worker you might use a function like this:
*
* ```ts
* import { Browser, launch as launchPuppeteer } from '@cloudflare/puppeteer'
* function launchBrowser(env: Environment) {
* if (env.LOCAL_BROWSER_ORIGIN) {
@jessejjohnson
jessejjohnson / stealth.js
Last active February 15, 2024 19:55
Headless browser stealth scripts
/**
* Mock GPU information with real values. Check using: https://bot.sannysoft.com/
*/
WebGLRenderingContext.prototype.getParameter = function(origFn) {
const paramMap = {};
paramMap[0x9245] = "Google Inc. (NVIDIA Corporation)"; // UNMASKED_VENDOR_WEBGL
paramMap[0x9246] = "ANGLE (NVIDIA Corporation, Quadro P400/PCIe/SSE2, OpenGL 4.5.0)"; // UNMASKED_RENDERER_WEBGL
paramMap[0x1F00] = "WebKit"; // VENDOR
paramMap[0x1F01] = "WebKit WebGL"; // RENDERER
paramMap[0x1F02] = "WebGL 1.0 (OpenGL ES 2.0 Chromium)"; // VERSION
@jessejjohnson
jessejjohnson / Process Async Helper
Last active May 13, 2025 06:57 — forked from AlexMAS/ProcessAsyncHelper.cs
The right way to run external process in .NET (async version)
using System;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
public static class ProcessAsyncHelper
{
public static async Task<ProcessResult> ExecuteShellCommand(string command, string arguments, int timeout)
{
var result = new ProcessResult();
@jessejjohnson
jessejjohnson / IMapFrom.cs
Created October 4, 2021 19:11
AutoMapper Domain Mapping Profiles
using AutoMapper;
namespace Application.Common.Mappings
{
public interface IMapFrom<T>
{
void Mapping(Profile profile) => profile.CreateMap(typeof(T), GetType());
}
}
@jessejjohnson
jessejjohnson / UnitTest.cs
Created September 30, 2021 18:16
Notable code snippets discovered in real-world solutions
try
{
throw new Exception("test");
}
catch (Exception ex)
{
Assert.Equal("test", ex.Message);
}
@jessejjohnson
jessejjohnson / Snowflake ID Generator
Last active May 13, 2025 06:56
Generate Twitter Snowflake ID's
public class SnowflakeIdGenerator
{
public const byte DefaultMachineIdBits = 6;
public const byte DefaultSequenceBits = 12;
private readonly long _machineId = 0;
private readonly byte _machineIdBits = 0;
private readonly byte _sequenceBits = 0;
private readonly long _maxSequence = 0;
private readonly Stopwatch _stopwatch = Stopwatch.StartNew();
private readonly object _lockObject = new object();