Skip to content

Instantly share code, notes, and snippets.

/* use v7.9.0 */
/* v0, just async */
(async function() {
var sleep = async function() {
return 'done';
}
var result = await sleep();
console.log('v0 result', result);
})();
@shaohua
shaohua / gist:f1fa43f0617ff4810867261958d92e9e
Last active October 12, 2016 23:30
The sweet spot for Cassandra secondary indexing (from www.wentnet.com/blog/?p=77)

The sweet spot for Cassandra secondary indexing Posted on October 21, 2013 Secondary indexes

Secondary indexes have been in Cassandra since 0.7 and can be incredibly useful. For example, if you were implementing a user accounts database, you might have the schema

1 2 3 4

@shaohua
shaohua / README.md
Created July 13, 2016 16:55 — forked from joshdover/README.md
Idiomatic React Testing Patterns

Idiomatic React Testing Patterns

Testing React components seems simple at first. Then you need to test something that isn't a pure interaction and things seem to break down. These 4 patterns should help you use a pattern that is repeatable and readable for the type of test you need.

Setup

I recommend doing all setup in the most functional way possible. If you can avoid it, don't set variables in a beforeEach. This will help ensure tests are isolated and make things a bit easier to reason about. I use a pattern

@shaohua
shaohua / installing_cassandra.md
Created April 20, 2016 17:43 — forked from hkhamm/installing_cassandra.md
Installing Cassandra on Mac OS X

Installing Cassandra on Mac OS X

Install Homebrew

Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@shaohua
shaohua / gist:e183a596e8d12db7c508
Created May 22, 2015 16:53
Generate random size js
#!/usr/bin/env node
/*
https://gist.github.com/stangah/04e7ce784ab64beb9919
Call from command line to create files of various sizes:
node fileCreatorThingy.js 1 10 100 200 300
*/
var fs = require('fs');
function find_deviation(v, d) {
var seq = [],
diff = 0,
seqMax = [];
for(var i=0; i<v.length + 1 -d; i++){
console.log('v', v);
seq = v.slice(i, i + d);
console.log('seq', seq);
seq.sort(function(a, b){
return a-b;
<!DOCTYPE html>
<html>
<head>
<title>Empty gadget</title>
</head>
<body>
Behold your gadget
<iframe src="https://app.box.com/embed_widget/s/rytekckemew26i37kjvd?view=list&sort=name&direction=ASC&theme=blue" width="500" height="400" frameborder="0"allowfullscreen webkitallowfullscreen msallowfullscreen></iframe>
<script type="text/javascript">
window.addEventListener("message", function(event){
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">