Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from "react";
import express from "express";
import path from "path";
import { renderToStream, toNodeStream, streamTemplate } from "rapscallion";
import { Route, StaticRouter } from "react-router-dom";
class App extends Component {
render() {
return (
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@divmain
divmain / esnextbin.md
Last active August 10, 2016 22:26
esnextbin sketch
// The only difference between a stub and a spy is this:
// - a spy wraps existing function and allows you to assert against its behavior
// - a stub replaces an existing function and allows you to assert against its behavior
// This creates a normal function that can be invoked.
const spy = sandbox.spy();
// Do something with it... and then you can make assertions against it later.
expect(spy).to.have.been.calledOnce;
// This wraps `someObject.someMethod` in another function. After wrapping,
{
"type": "Program",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "FunctionExpression",
"id": null,
@divmain
divmain / gist:e02d6218acd044328d59fb2314ae8079
Created April 29, 2016 07:18 — forked from zer4tul/gist:6477470
Cisco's Anyconnect CSD WRAPPER for OpenConnect
#!/bin/sh
# Cisco Anyconnect CSD wrapper for OpenConnect
CSTUB="$HOME/.cisco/hostscan/bin/cstub"
$ARCH=$(uname -m)
if [[ "$ARCH" == "x86_64" ]]
then
@divmain
divmain / osx-for-hackers.sh
Created April 29, 2016 04:56 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@divmain
divmain / find-version-commits.sh
Created March 9, 2016 23:52
Find commits where `package.json` version was bumped.
filename="package.json"
pattern=' "version": "([0-9]+\.[0-9]+\.[0-9]+).*'
git log --pretty="format:%H" -- package.json | {
while read current_hash; do
if [ -n "$previous_hash" ]; then
new_version=`git diff $previous_hash $current_hash -- $filename | sed -n -E -e "s/^\-$pattern/\1/p"`
if [ -n "$new_version" ]; then
echo version bumped to $new_version with $previous_hash
fi
if (typeof Object.assign != 'function') {
(function () {
Object.assign = function (target) {
'use strict';
if (target === undefined || target === null) {
throw new TypeError('Cannot convert undefined or null to object');
}
var output = Object(target);
@divmain
divmain / gist:7815457
Created December 5, 2013 22:50
new visualization
//http://api.nytimes.com/svc/search/v2/articlesearch.json?q=israel+iran&fq=source:("The New York Times")&api-key=f25c99da2f24daefca165f7a452d05ec:1:35029882
var pagesOfStoriesToRequest = 9;
var requestsPromises = [];
var keywordsArray = [];
var uniqueKeywordsArray;
var templateVectorMap = {};
var featureVectorsRaw = [];
var coordinates = []; //array of arrays for d3 to scatterplot...