Skip to content

Instantly share code, notes, and snippets.

View callmehiphop's full-sized avatar
👾

Dave Gramlich callmehiphop

👾
  • Detroit, MI
View GitHub Profile
const {Readable} = require('stream');
class PageStream extends Readable {
constructor(requestFn) {
super({objectMode: true});
this.request = requestFn;
this.nextQuery = {};
this.pending = [];
}
async _read() {
@callmehiphop
callmehiphop / README.md
Last active March 14, 2019 05:22
duplexify ts subclass

microsoft/TypeScript#19675

$ npm install
$ npx tsc

index.ts:3:24 - error TS2507: Type '{ default: DuplexifyConstructor; obj(writable?: Writable | undefined, readable?: Readable | undefined, streamOptions?: DuplexOptions | undefined): Duplexify; }' is not a constructor function type.

3 class MyDuplex extends Duplexify {}
 ~~~~~~~~~
@callmehiphop
callmehiphop / spread.js
Last active October 5, 2016 19:38
simple Promise#spread decorator
function decorate(Promise) {
Promise.prototype.spread = function(yep, nope) {
var args = [yep ? resolver(yep) : null];
if (nope) {
args.push(resolver(nope));
}
return this.then.apply(this, args);
};
@callmehiphop
callmehiphop / post-dedupe.json
Created September 27, 2016 00:30
shrinkwrap tests!
{
"name": "test",
"version": "0.0.0",
"dependencies": {
"@google-cloud/bigquery": {
"version": "0.3.0",
"from": "@google-cloud/bigquery@>=0.3.0 <0.4.0",
"resolved": "https://registry.npmjs.org/@google-cloud/bigquery/-/bigquery-0.3.0.tgz"
},
"@google-cloud/bigtable": {
{
"id": "bigtable",
"type": "class",
"name": "Bigtable",
"overview": "<p>\n This class allows you interact with Google Cloud Bigtable.\n</p>\n\n<p>\n First, install <code>@google-cloud/bigtable</code> with npm:\n</p>\n\n<div hljs language=\"bash\">$ npm install --save @google-cloud/bigtable</div>\n\n<p>\n If you are running your app on Google Compute Engine, you won't need to worry about supplying connection configuration options to <code>@google-cloud/bigtable</code>— we figure that out for you.\n</p>\n\n<p>\n However, if you're running your app elsewhere, you will need to provide project details to authenticate API requests.\n</p>\n\n<h4>Compute Engine</h4>\n<div hljs language=\"javascript\">\nvar bigtable = require('@google-cloud/bigtable')();\n</div>\n\n<h4>Elsewhere</h4>\n<div hljs language=\"javascript\">\nvar bigtable = require('@google-cloud/bigtable')({\n projectId: 'grape-spaceship-123',\n keyFilename: '/path/to/keyfile.json'\n});\n</div>\n\n<p>\n The full set of options which can be
{
"id": "bucket",
"metadata": {
"name": "Bucket",
"description": null
},
"methods": [{
"metadata": {
"constructor": true,
"name": "Bucket",
@callmehiphop
callmehiphop / dox.py
Created February 11, 2016 18:35 — forked from jgeewax/dox.py
import argparse
import json
from parinx.parser import parse_docstring
import pdoc
def main():
parser = argparse.ArgumentParser(description='Document Python modules.')
parser.add_argument('module', nargs='*',

BigTable

var bigtable = gcloud.bigtable();

getZones

bigtable.getZones(function(err, zones, apiResponse) {});
@callmehiphop
callmehiphop / example.js
Last active August 29, 2015 14:08
the worst idea ever!
var Thing = Weird.extend({
myProp: 'hello',
getMyProp: function () {
return myProp;
},
setMyProp: function (value) {
myProp = value;
@callmehiphop
callmehiphop / preload.js
Created August 13, 2014 16:05
angular image preloader
angular
.module('preload', [])
.factory('preload', function ($q) {
'use strict';
function getImage (src, ignoreFailure) {
var defer = $q.defer();
var img = new Image();
var resolve = defer.resolve.bind(defer, img);