Skip to content

Instantly share code, notes, and snippets.

View ryaninvents's full-sized avatar

Ryan Kennedy ryaninvents

View GitHub Profile
@ryaninvents
ryaninvents / debug-fn.js
Last active September 22, 2017 20:28
Quick debugging for JS functions
function debug(fn) {
return function () {
console.groupCollapsed(fn.name);
console.debug('Args:', arguments);
const result = fn.apply(this, arguments);
console.debug('Returns:', result);
console.groupCollapsed('Stack');
console.log(new Error().stack.split('\n').slice(1).join('\n'));
console.groupEnd();
console.groupEnd();
@ryaninvents
ryaninvents / api-gateway-terraform.tf
Created April 21, 2017 22:06 — forked from keeth/api.tf
Apex + Terraform + AWS Lambda + API Gateway + JSON Encoded Errors + CORS
resource "aws_api_gateway_rest_api" "myApi" {
name = "myApi-${var.env}"
description = "My awesome API (${var.env} environment)"
}
resource "aws_api_gateway_deployment" "myApi" {
depends_on = [
"aws_api_gateway_integration.myApi_myEndpoint_post",
"aws_api_gateway_integration_response.myApi_myEndpoint_post",
"aws_api_gateway_integration_response.myApi_myEndpoint_post_400",
@ryaninvents
ryaninvents / bar.js
Created March 30, 2017 16:07 — forked from sombriks/bar.js
mocha+chai+budo+nightmare
"use strict"
const Nightmare = require("nightmare");
const expect = require("chai").expect;
const budo = require("budo");
describe("\u263C basic tests \u263E", () => {
const b = budo("../src/main.js");
@ryaninvents
ryaninvents / SpinCounter.js
Created September 24, 2016 15:21
Fun React component for animating a changing number
import React from 'react';
/**
* @param {number} t Number between 0 and 1 indicating the progress of the ease.
* @param {number} startValue
* @param {number} endValue
*/
function easeOut(t, startValue, endValue) {
const c = endValue - startValue;
const p = t - 1;
@ryaninvents
ryaninvents / package.json
Created August 26, 2016 02:56
Rollup.js minimal PoC for bug
{
"name": "rollup-poc",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
@ryaninvents
ryaninvents / phaser.js
Last active August 15, 2016 15:55 — forked from crisu83/phaser.js
Wrapper module for running Phaser.js on Node.js.
// this is an ingenius hack that allows us to run Phaser without a browser
// ... and yes, it took some time to figure out how to do this
var Canvas = require('canvas')
, jsdom = require('jsdom')
, document = jsdom.jsdom(null)
, window = document.parentWindow
, Phaser;
// expose a few things to all the modules

Solutions to problems or quirks I shouldn't have.

Web dev

Stack overflow in React (`Maximum call stack size exceeded`) Triggered this one a week ago with something like the following (pseudocode):
class MyComponent extends React.Component {
@ryaninvents
ryaninvents / fun-with-bindings.js
Last active April 14, 2017 15:39
Use ES7 double-colon bind while still referring to original "this"
class Client {
constructor(foo) {
this.name = foo
}
}
class Message {
constructor(content) {
this.content = content
}
@ryaninvents
ryaninvents / keymap.cson
Created May 10, 2016 19:00
Atom keymap
# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
@ryaninvents
ryaninvents / unsubmodule.md
Created May 5, 2016 13:25
Convert git submodule to regular directory

From Stack Overflow.

# Fetch the submodule commits into the main repository
git remote add submodule_origin git://url/to/submodule/origin
git fetch submodule_origin

# Start a fake merge (won't change any files, won't commit anything)
git merge -s ours --no-commit submodule_origin/master