Skip to content

Instantly share code, notes, and snippets.

View baetheus's full-sized avatar

Brandon Blaylock baetheus

View GitHub Profile
@baetheus
baetheus / baetheus.c
Last active July 26, 2016 19:55
Planck Keymap 1
// This is the canonical layout file for the Quantum project. If you want to add another keyboard,
// this is the style you want to emulate.
#include "planck.h"
#include "action_layer.h"
#include "audio.h"
#include "eeconfig.h"
extern keymap_config_t keymap_config;
@baetheus
baetheus / tsconfig.json
Created July 29, 2017 21:35
tsconfig.json
{
"compilerOptions": {
"target": "ES2015",
"module": "commonjs",
"declaration": true,
"sourceMap": true,
"outDir": "./dist/",
"rootDir": "./src/",
"removeComments": true,
"strict": true,
/// <reference path="../node_modules/@types/node/index.d.ts" />
'use strict'
import { newStream, tap, runEffects } from '@most/core';
import { newDefaultScheduler } from '@most/scheduler';
import { Sink, Scheduler } from 'most';
import { IncomingMessage, ServerResponse, createServer } from 'http';
interface Ctx {
@baetheus
baetheus / remove-java.sh
Created August 10, 2017 17:23
Remove Java
sudo rm -rf /Library/Java/*
sudo rm -rf /Library/PreferencePanes/Java*
sudo rm -rf /Library/Internet\ Plug-Ins/Java*
@baetheus
baetheus / example.ts
Last active October 26, 2017 23:17
fromStream POC
/// <reference path="../node_modules/@types/node/index.d.ts" />
'use strict';
import { fromStream } from './index';
import { createReadStream } from 'fs';
import 'rxjs/add/operator/reduce';
const stream = createReadStream('./example.ts', {encoding: 'utf-8'});
const obs = fromStream(stream, ['data'], ['error'], ['end', 'close']);
@baetheus
baetheus / scan-lodash.js
Last active August 23, 2017 04:42
Scan and lodash
/*
This will turn your arrays into a keyed object like:
{
1: <Obj 1>,
2: <Obj 2>,
3: <Obj 3>
}
Newest values will over-write old values.
*/
const keyedSource = source.scan((acc, arr) => _.assign(acc, _.keyby(arr, 'id'));
@baetheus
baetheus / cancellableEffectFactory.ts
Last active November 7, 2022 14:15
A factory function POC for cancellable ngrx effects
import { Action, Effect } from "@ngrx/store";
import { Observable } from "rxjs/Observable";
import { of } from "rxjs/observable/of";
import "rxjs/add/operator/switchMap";
import "rxjs/add/operator/takeUntil";
import "rxjs/add/operator/filter";
import "rxjs/add/operator/map";
// For POC typechecking force payloads on Actions.
export interface CancellableAction<T> extends Action {
@baetheus
baetheus / actionWrapper.ts
Last active January 23, 2018 23:08
POC for reducing action boilerplate
// This is where the magic is
export class PayloadAction<T, P = undefined> {
readonly type: T;
constructor(public readonly payload: P) {};
}
// These would be existing interfaces
export interface SomePayload {
stuff: string;
things: number[];
@baetheus
baetheus / rec-mergeMap.ts
Created November 14, 2017 16:44
Recursive rxjs mergeMap
function repeat(n: number): Observable<number> {
return of(n).pipe(
mergeMap(o => of(o).pipe(
merge(repeat(n+1))
))
);
}
repeat(0).subscribe(n => console.log('Got me a number', n), e => console.error(e), () => console.log('All done'));
@baetheus
baetheus / typeNarrowingProblem1.ts
Last active January 23, 2018 21:10
typeNarrowingProblem1
export enum SomeIds {
ONE = 'one',
TWO = 'two',
}
export enum SomeType {
RED = 'red',
BLUE = 'blue',
}