Skip to content

Instantly share code, notes, and snippets.

View CarsonMcKinstry's full-sized avatar

Carson McKinstry CarsonMcKinstry

View GitHub Profile
using System;
using Godot;
using Godot.Collections;
using ProjectTome.Utils;
namespace ProjectTome.Core.StateMachine;
[GlobalClass]
public partial class StateMachine : Node
{
import React from 'react';
// slot config allows 2 options:
// 1. Component to match, example: { leadingVisual: LeadingVisual }
type ComponentMatcher = React.ElementType<Props>;
// 2. Component to match + a test function, example: { blockDescription: [Description, props => props.variant === 'block'] }
type ComponentAndPropsMatcher = [ComponentMatcher, (props: Props) => boolean];
export type SlotConfig = Record<
string,
import * as fs from "fs";
export function memoryUsageLog(
file: string | Writable,
sampleRate: number = 1,
sampleTime: number = 60,
debug: boolean = false,
callback = () => {}
) {
const output = typeof file === "string" ? fs.createWriteStream(file) : file;
import { Observable, merge, interval } from "rxjs";
import { map, tap, pluck } from "rxjs/operators";
type KV = Record<any, any>;
interface Cacheable<K, V> {
delete: () => void;
get: (key: K) => V | undefined;
has: (key: K) => boolean;
set: (key: K, value: V) => this;
@CarsonMcKinstry
CarsonMcKinstry / gennode
Last active January 19, 2019 00:47
A small script for automating the creation of a new node project, complete with package creation, CoC creation, license creation, and remote repo creation
#!/bin/bash
# This script assumes that you have the following installed
# npm 5.2+ [https://www.npmjs.com/get-npm]
# hub [https://hub.github.com/]
if [ "$1" != "" ]; then
echo "Generating new node project $1..."
@CarsonMcKinstry
CarsonMcKinstry / ReactHooks.code-snippets
Created November 5, 2018 13:39 — forked from antmdvs/ReactHooks.code-snippets
Snippet for React *EXPERIMENTAL* `useState()` hook -- See https://reactjs.org/hooks
{
"Use State": {
"prefix": "us",
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"body": [
"const [${1}, set${1/(.*)/${1:/capitalize}/}] = useState($2);",
"$0"
],
"description": "(EXPERIMENTAL) React: Use State. See https://reactjs.org/hooks"
}
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export function withAppContext<
P extends { appContext?: AppContextInterface },
R = Omit<P, 'appContext'>
>(
Component: React.ComponentClass<P> | React.StatelessComponent<P>
): React.SFC<R> {
return function BoundComponent(props: R) {
return (
package main
import (
"crypto/md5"
"io"
"github.com/fogleman/gg"
)
type gridCell struct {
@CarsonMcKinstry
CarsonMcKinstry / LocationProvider.js
Last active July 2, 2020 09:12
A geo location provider built using the React v16.3 context API
import React, { Component } from 'react';
import { number, string } from 'prop-types';
export const { Provider, Consumer } = React.createContext();
export const locationConsumer = Component => props => {
return (
<Consumer>
{ ctx => <Component {...ctx} {...props}/> }
<div ng-app="myApp" ng-controller="myController" ng-cloak >
<form autocomplete="off">
<div class="input" ng-click="setFocus()">
<ul class="tokens">
<li arrow-lr class="token" ng-repeat="company in selected | limitTo:screenLimit" ng-click="removeThisCompany(company.id)" ng-keydown="removeFocused(this, $event)" data-tooltip="{{company.name}}" tabindex="-1">{{company.name | myFilter }}</li>
<li arrow-lr ng-if="selected.length > screenLimit" class="leftovers" tabindex="-1">
{{selected.length - screenLimit}} more...
<ul>
<li class="leftover" ng-repeat="company in selected | startFrom: screenLimit" ng-click="removeThisCompany(company.id)">
{{company.name}}