Skip to content

Instantly share code, notes, and snippets.

View ProdigySim's full-sized avatar

Michael Busby ProdigySim

View GitHub Profile
@ProdigySim
ProdigySim / fix-amplify-jank.sh
Created July 15, 2019 17:31
Some junk that nobody should have to use
#!/bin/bash
## aws-amplify-react-native uses a weird export syntax that breaks our jest/babel config:
## https://github.com/aws-amplify/amplify-js/issues/2686
## https://github.com/aws-amplify/amplify-js/pull/3102
## This fix just edits those files to use a more normal syntax.
function fix_imports() {
@ProdigySim
ProdigySim / fake_hook_impl.ts
Created July 1, 2019 18:48
Here's my naiive assumption of how hooks are implemented.
let global_currentHooks: object[] | null = null;
let global_currentHookIndex: number | null = null;
function getNextHook() {
return global_currentHooks![global_currentHookIndex!];
}
const state = new Map();
// build a safe, comparable string from a semver!
function semver(str) {
const bits = str.split('.');
const padLength = 1 + Math.max(...bits.map(s => s.length));
return bits.map(s => s.padStart(padLength, '0')).join('');
}
@ProdigySim
ProdigySim / values.ts
Created January 15, 2019 04:53
Tyescript Values macro
// Get the types of all properties of T:
type Values<T> = T[keyof T];
@ProdigySim
ProdigySim / filterMap.ts
Created August 16, 2018 17:08
Doing some neat typescript stuff.
type FilterFn<T> = (item: T) => boolean;
type FilterMap<T> = Record<string, FilterFn<T>>;
function filterMap<T, U extends FilterMap<T>>(items: T[], filterMap: U) {
const filters = new Map<string, FilterFn<T>>();
Object.keys(filterMap).forEach((key) => filters.set(key, filterMap[key]));
const itemMap: Partial<Record<keyof U, T>> = {};
for (const item of items) {
const matchedFilter = Array.from(filters).find(([key, filterFn]) => {
const fs = require('fs');
const crateData = JSON.parse(fs.readFileSync('crates-neater.json', 'utf-8'));
function crateWithAny(data) {
const itemNames = typeof data == 'string' ? Array.from(arguments) : data;
return crateData.filter(crate => itemNames.reduce((hasItem, item) => hasItem || item in crate, false));
}
const l3cc = crateWithAny('Level 3 Backpack', 'Level 3 Helmet', 'Level 3 Military Vest').length;
@ProdigySim
ProdigySim / gist:1acc6edf67601cd9c025
Created May 13, 2015 00:48
passcard verification
Verifying I am +prodigysim on my passcard. https://onename.com/prodigysim
/*
Finale Can't Spawn Glitch Fix (C) 2014 Michael Busby
All trademarks are property of their respective owners.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
@ProdigySim
ProdigySim / cterrorplayer_updatezombiefrustration.cpp
Created July 8, 2014 10:39
CTerrorPlayer::UpdateZombieFrustration()
// Reverse-engineered CTerrorPlayer::UpdateZombieFrustration().
// I can claim no copyright for this code.
// This representation of code was produced by reverse engineering for interoperability.
// Any resemblance to original source is completely accidental.
void CTerrorPlayer::UpdateZombieFrustration()
{
if ( !ZombieFrustration.GetBool())
|| this->GetTeamNumber() != 3
|| this->GetClass() != 8
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
public class Class1
{
static Class1()
{
DoThing();
}