Skip to content

Instantly share code, notes, and snippets.

View capnmidnight's full-sized avatar
💭
Apparently...

Sean T. McBeth capnmidnight

💭
Apparently...
View GitHub Profile
// ==UserScript==
// @name HN Prominent User Names
// @namespace Violentmonkey Scripts
// @grant none
// @version 1.0
// @author Sean T. McBeth - sean.mcbeth@gmail.com
// @description Make user names on Hacker News more prominent, so we can start to remember people.
// @match https://news.ycombinator.com/*
// ==/UserScript==
'use strict';
@capnmidnight
capnmidnight / ExampleClient.ts
Last active December 12, 2020 00:57
Workerizing Async code
import { WorkerClient } from "./WorkerClient";
import { fibonacci as _fibonacci } from "./ExampleFunction";
// We'll have a pool of 10 workers from which to run.
const worker = new WorkerClient("ExampleServer.bundle.js", "ExampleServer.bundle.min.js", 10);
// We can provide a UI-thread fallback, in case we're running on a system that doesn't support workers
export const fibonnaci = worker.createExecutor<number>(
(n: number, onProgress?: progressCallback) => worker.execute("fibonacci", [n], onProgress),
(n: number, onProgress?: progressCallback) => _fibonacci(n, onProgress));
@capnmidnight
capnmidnight / DateTimeExt.cs
Created February 26, 2018 21:57
Fix DateTime values in Unity on Android when building with .NET 4.6 support
public static class DateTimeExt
{
#if UNITY_ANDROID && NET_4_6 && !UNITY_EDITOR
static int cachedOffset = 0;
#endif
static int MillisecondsOffset
{
get
{
#if !UNITY_ANDROID || !NET_4_6 || UNITY_EDITOR
@capnmidnight
capnmidnight / SaveScores.cs
Last active May 3, 2017 23:42
Resolve missing directories and save a file.
class ScoreTable {
// blah blah blah
}
static string ScoreFilePath = PathX.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AndTheory", "Dodgewall", "scores.js");
void Save(ScoreTable scoreObject)
{
var parts = ScoreFilePath.Split(Path.DirectorySeparatorChar);
var rebuild = parts[0];
var path = PathX.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AndTheory", "Dodgewall", "scores.js");
var parts = path.Split(Path.DirectorySeparatorChar);
var rebuild = parts[0];
for(int i = 1; i < parts.Length - 1; ++i)
{
rebuild = PathX.Combine(rebuild, parts[i]);
if(!Directory.Exists(rebuild))
{
Directory.CreateDirectory(rebuild);
}
/* global require, __dirname */
var socketio = require( "socket.io" ),
http = require( "http" ),
mime = require( "mime" ),
path = require( "path" ),
fs = require( "fs" ),
format = require( "util" ).format,
serialPort = require( "serialport" ),
os = require( "os" ),
spawn = require( "child_process" ).spawn,
// I don't know why I did this as a define instead of a const int.
#define NUM_FINGERS 5
// This is a configuration for the pins on which the motors are hooked up.
// I do most of my projects this way so I can move pins around easily and
// not have to worry about rewriting a lot of code
const int FINGER_PINS[NUM_FINGERS] = {4, 5, 6, 11, 12};
// Holds the byte read in from the serial port. I statically allocate everything
// because there is no reason not to on such a simple application. This way,
vertexShader:
"varying vec2 vUv;\n\
\n\
void main() {\n\
vUv = uv;\n\
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
}",
fragmentShader:
"uniform float amount;\n\
@capnmidnight
capnmidnight / gist:2b5df1fe3743ce6552e8
Last active November 26, 2015 03:03
Keyboard and Mouse behaviors of Steam Controller
Keyboard and Mouse behaviors of Steam Controller
You can configure most of this in Steam > Big Picture > Settings > Controller > Configurations > Desktop configuration
Left trigger (analog): N/A
Left trigger (click): right click
Left bumper: left ctrl
Left grip: browser back
Right trigger (analog): N/A
Right trigger (click): left click