Skip to content

Instantly share code, notes, and snippets.

View christopherscott's full-sized avatar
👍
asdf

Christopher Scott Hernandez christopherscott

👍
asdf
View GitHub Profile
@christopherscott
christopherscott / js-inheritance-lib-classes-instances
Created February 11, 2013 22:11
Prototypical inheritance in JavaScript with 'classes' and 'instances'
var Lib = {
extend: function (props) {
var sub = mixin(Object.create(this), props);
sub.super = this;
return sub;
},
create: function () {
var instance = Object.create(this);
if (instance.init) { instance.init.apply(instance, arguments); }
return instance;
var Lib2 = {
extend: function (props) {
var sub = Object.create(this);
sub = mixin(sub, props);
sub.super = this;
return sub;
}
};
var Person = Lib.extend({
@christopherscott
christopherscott / gist:5017707
Last active December 14, 2015 02:59
The Walrus And The ECMAScripter
// Another attempt at understanding monads by translating into my lingua franca
// http://www.infoq.com/presentations/Why-is-a-Monad-Like-a-Writing-Desk
// the return operation is prefixed with underscore because 'return' is a reserved name in ECMAScript
// Part 1: The door
// ================
// Is it true that this could be a monadic return operation?
var _return = function(v) {
@christopherscott
christopherscott / in-memory-list-react.jsx
Last active September 28, 2018 16:42
adding/removing limited num items, react
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
state = {
contacts: [],
}
@christopherscott
christopherscott / react-portal-animated-modals.jsx
Created September 20, 2018 14:44
Difference between react-spring and react-transition-group animated modals
import Component from "@reach/component-component";
import { Transition } from 'react-spring';
import { Transition as Transition2 } from 'react-transition-group';
import ReactDOM from 'react-dom';
import React from 'react';
import logo from './logo.svg';
import './App.css';
const style = {
padding: 10,
@christopherscott
christopherscott / ExcelToJsDate.js
Created May 24, 2012 16:40
Convert Excel date values to JavaScript date objects
// Convert Excel dates into JS date objects
//
// @param excelDate {Number}
// @return {Date}
function getJsDateFromExcel(excelDate) {
// JavaScript dates can be constructed by passing milliseconds
// since the Unix epoch (January 1, 1970) example: new Date(12312512312);