Skip to content

Instantly share code, notes, and snippets.

View ricokahler's full-sized avatar
💭
recovering from burnout

Rico Kahler ricokahler

💭
recovering from burnout
View GitHub Profile
@ricokahler
ricokahler / Component.ts
Created September 15, 2016 01:08
Structured Component for Cycle
/**
* Component module to enforce model update view
*/
import xs, {MemoryStream, Stream} from 'xstream';
import {DOMSource, VNode} from '@cycle/dom';
import {Record} from 'immutable';
export interface ComponentSource { DOM: DOMSource }
@ricokahler
ricokahler / example.js
Last active February 20, 2017 22:37
Evaluate JS to JSDOM
const applu = require('./index');
const html = `
<html>
<head></head>
<body>
<p id="content"></p>
<body>
</html>
`;
@ricokahler
ricokahler / test.js
Last active April 25, 2017 04:45
My Gist
// Generated by JSIL v0.8.2 build 13182. See http://jsil.org/ for more information.
'use strict';
var $asm00 = JSIL.GetAssembly("1dd27d7b, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
var $asm01 = JSIL.GetAssembly("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
var $asm02 = JSIL.GetAssembly("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
/* Generated by JSIL v0.8.2 build 13182. See http://jsil.org/ for more information. */
'use strict';
var $asm00 = JSIL.DeclareAssembly("1dd27d7b, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
class Polynomial:
def __init__(self, coefficient, exponent, next = None):
self.coefficient = coefficient
self.exponent = exponent
self.next = next
def _add(term_a, term_b):
if term_a == None:
return term_b
@ricokahler
ricokahler / map-promises.ts
Created February 7, 2018 17:02
map promises
export async function sequentially<T, R>(list: T[], asyncFunction: (t: T) => Promise<R>) {
const newList = [] as R[];
for (const i of list) {
newList.push(await asyncFunction(i));
}
return newList;
}
/*
// then use like so:
@ricokahler
ricokahler / index.html
Last active March 9, 2018 21:08
simple web app
<html>
<head>
<title>what up</title>
</head>
<body>
<h1 class="foo"></h1>
<div class="stuff"></div>
<script>
async function loadData() {
const response = await fetch('https://api.github.com/users/ricokahler/gists');
@ricokahler
ricokahler / map-reduce.ts
Created April 7, 2018 15:10
map - reduce in javascript
class Something {
foo: string;
bar: string;
x: number;
constructor(x: number) {
this.x = x;
this.foo = 'foo';
this.bar = 'bar';
}
}
@ricokahler
ricokahler / .gitignore
Last active June 7, 2018 13:02
Material-ui typescript bug
node_modules
@ricokahler
ricokahler / api.ts
Last active July 3, 2018 14:05
Retain Data API
interface Request {
queries: Array<Query>;
filters?: Filter;
}
interface Response extends Array<Result> {}
interface Result {
id: string;
results: Array<number>;
@ricokahler
ricokahler / Component.js
Created September 19, 2019 03:08
Only add the event listener once
import React, { useCallback } from 'react';
function usePullValue(value) {
const ref = useRef(value);
useLayoutEffect(() => {
ref.current = value;
}, [value]);
return useCallback(() => {