Skip to content

Instantly share code, notes, and snippets.

View RyanCCollins's full-sized avatar

Ryan Collins RyanCCollins

View GitHub Profile
@getify
getify / ex1-prototype-style.js
Last active January 7, 2024 11:58
OLOO (objects linked to other objects) pattern explored (with comparison to the prototype style of the same code)
function Foo(who) {
this.me = who;
}
Foo.prototype.identify = function() {
return "I am " + this.me;
};
function Bar(who) {
Foo.call(this,"Bar:" + who);
@getify
getify / gist:1b26accb1a09aa53ad25
Last active September 7, 2023 12:43
first draft sketch of a "Worker" polyfill
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Worker Polyfill</title>
<script src="polyfill.worker.js"></script>
</head>
<body>
<h1>Worker Polyfill</h1>
<script>
@timruffles
timruffles / functors.ts
Created June 7, 2016 09:30
functor in TypeScript - this is probably in violation of many functor laws :/
interface Functor<T> {
map(mapper: (x: T) => T): Functor<T>;
ret(x: T): Functor<T>;
}
class Maybe<T> implements Functor<T> {
constructor(private value: T) {}
private nowt() {
@samwgoldman
samwgoldman / gist:1fcceea36206e1544414
Last active February 18, 2017 16:07
Maybe type in JS/Flow
/* @flow */
type Maybe<T,U> = (pattern: {
some(x: T): U;
none(): U;
}) => U;
function map<A,B,C>(maybe: Maybe<A,C>, f: (a: A) => B): Maybe<B,C> {
return function(pattern) {
return maybe({
import React from "react";
import { render } from "react-dom";
const ParentComponent = React.createClass({
getDefaultProps: function() {
console.log("ParentComponent - getDefaultProps");
},
getInitialState: function() {
console.log("ParentComponent - getInitialState");
return { text: "" };