Skip to content

Instantly share code, notes, and snippets.

@pcardune
pcardune / Cloneable.ts
Created July 12, 2018 21:55
Example of some complicated typescript typings
class Cloneable<T extends object> {
protected readonly data: T;
public static kind: string;
protected constructor(data: T) {
this.data = data;
}
static create<T extends object>(data: T) {
console.log('Creating a cloneable', this.kind);
@pcardune
pcardune / main.go
Created July 1, 2018 23:53
Clifford Attractor Animation
// after running this program you can run
// ffmpeg -framerate 30 -i out/%06d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p out2.mp4
package main
import (
"fmt"
"image"
"image/color"
"image/jpeg"
"math"
@pcardune
pcardune / ipld-test.js
Last active February 15, 2018 23:34
Simple example of storing data in your local ipfs node using ipld. Note that this only works when your local ipfs node is not running.
import dagCBOR from 'ipld-dag-cbor';
import IPLDResolver from 'ipld-resolver';
import BlockService from 'ipfs-block-service';
import IPFSRepo from 'ipfs-repo';
const repo = new IPFSRepo(process.env.HOME + '/.ipfs');
const ipfsBlockService = new BlockService(repo);
const resolver = new IPLDResolver(ipfsBlockService);
const node1 = {
0xfc45546bB62A57EbC96536fb8B58A0beb6c6cD44
0x775fC81CBa62045E37987074B5C5675D42357ec0
/* @flow */
type IdentityFunc = <A>(a: A) => A;
declare var identity: IdentityFunc;
const aNumber:number = identity(1);
const aString:string = identity("foo");
/* @flow */
type IdentityFunc<A> = (a: A) => A;
declare var identity: IdentityFunc<mixed>;
const aNumber:number = identity(1);
const aString:string = identity("foo");
/* @flow */
type IdentityFunc<A> = (a: A) => A;
declare var identity: IdentityFunc<number>;
const aNumber:number = identity(1);
const aString:string = identity("foo");
function identity(a) {
return a;
}
@pcardune
pcardune / redux_v3.x.x.jsx
Last active April 27, 2017 08:43
This gist shows how to add support for redux-thunk and redux-promise-middleware to the flowtype libdefs for redux
// flow-typed signature: ba132c96664f1a05288f3eb2272a3c35
// flow-typed version: c4bbd91cfc/redux_v3.x.x/flow_>=v0.33.x
declare module 'redux' {
/*
S = State
A = Action