Skip to content

Instantly share code, notes, and snippets.

@bencooling
bencooling / simple.js
Created January 14, 2017 06:48
javascript: serverless
class MyPlugin {
constructor() {
this.commands = {
graphiql: {
usage: 'Creates graphiql server',
lifecycleEvents: ['start'],
},
};
this.hooks = {
@bencooling
bencooling / GraphQLSchema.js
Created January 14, 2017 04:42
javascript: graphql
const {
graphql,
GraphQLSchema,
GraphQLObjectType,
GraphQLString
} = require('graphql');
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
@bencooling
bencooling / README.md
Last active March 2, 2018 03:27
javascript: http server

session-cookie.js

nodemon session-cookie.js
> 127.0.0.1:8000
# visit /login
> Redirects to /admin with cookie
# visit /logout
> Redirects to / with cookie deleted
@bencooling
bencooling / README.md
Last active July 11, 2016 05:15 — forked from anonymous/index.html
React Redux Bootstrap Thunk Hello WorldReact Redux Bootstrap Thunk Hello World// source http://jsbin.com/bufuxi

Minimal prototype of React, Redux, Redux Thunks +React Bootstrap + Bootstrap Material Design + fetch + jsonplaceholder.

@bencooling
bencooling / download-node-nightly.sh
Last active July 5, 2016 05:48
download-node-nightly.sh - simple script to fetch Node.js nightlies on OS X and Linux (x86, x64 & ARM)
#!/bin/sh
# Usage:
# sh download-node-nightly.sh
hasxz=$(which xzcat)
os=$(uname | tr '[A-Z]' '[a-z]')
arch=$(uname -m)
pwd=$(PWD)
@bencooling
bencooling / GIF-Screencast-OSX.md
Created February 29, 2016 09:59 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@bencooling
bencooling / 0. intro.md
Last active February 8, 2016 00:16 — forked from jquense/0. intro.md
Alternative ways to define react Components

The 0.13.0 improvements to React Components are often framed as "es6 classes" but being able to use the new class syntax isn't really the big change. The main thing of note in 0.13 is that React Components are no longer special objects that need to be created using a specific method (createClass()). One of the benefits of this change is that you can use the es6 class syntax, but also tons of other patterns work as well!

Below are a few examples creating React components that all work as expected using a bunch of JS object creation patterns (https://github.com/getify/You-Dont-Know-JS/blob/master/this%20&%20object%20prototypes/ch4.md#mixins). All of the examples are of stateful components, and so need to delegate to React.Component for setState(), but if you have stateless components each patterns tends to get even simpler. The one major caveat with react components is that you need to assign props and context to the component instance otherwise the component will be static. The reason is

@bencooling
bencooling / .eslint
Created November 20, 2015 00:10
eslint
{
"ecmaFeatures": {
"jsx": true,
"modules": true,
"arrowFunctions": true,
"blockBindings": true,
"defaultParams": true,
"objectLiteralShorthandProperties": true
},
"rules": {
@bencooling
bencooling / index.js
Created October 21, 2015 06:57
requirebin sketch
var async = require('async');
function waitSecond(cb) {
setTimeout(function(){
cb(null, 'waited 1 second');
}, 1000);
}
async.series([
waitSecond,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1">
<title>Document</title>
</head>
<body>