Skip to content

Instantly share code, notes, and snippets.

View moimikey's full-sized avatar
:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
View GitHub Profile
@max-mapper
max-mapper / index.js
Created September 11, 2017 19:34
scrape millions of html files in a folder structure
var $ = require('cheerio')
var fs = require('fs')
var walker = require('folder-walker')
var transform = require('parallel-transform')
var ndjson = require('ndjson')
var walk = walker('./pageblobs') // generated by abstract-blob-store
var scraper = transform(10, scrape)
var out = ndjson.serialize()
@lmiller1990
lmiller1990 / App.js
Created September 6, 2017 15:58
React Redux Async middleware example (use create-react-app)
import React, {Component} from 'react'
import {connect} from 'react-redux'
class App extends Component {
render() {
console.log(this.props)
return(
<div>
Ajax pending: {this.props.pending.toString()}
</div>
@max-mapper
max-mapper / csv.js
Last active August 1, 2018 16:31
streaming merge sort of two line delimited files (csv and json lines)
// output of above script pipe into here, converts it to smaller csv
var split = require('split2')
var through = require('through2')
console.log('doi,url')
var splitter = split()
var each = through(function (buf, enc, next) {
var _
try {
import React from "react";
import ResizeObserver from "resize-observer-polyfill";
import shallowEqual from "fbjs/lib/shallowEqual";
export default class PausableMeasure extends React.Component {
node = null;
state = {bounds: null};
componentWillMount() {
if (!this.props.dontMeasure) this.setup();
@max-mapper
max-mapper / download.js
Last active August 1, 2018 16:31
data.gov metadata downloader
var request = require('request')
var link = process.argv[2]
var start = process.argv[3]
if (!start) start = 0
else start = +start
dl(link, start, function (err) {
if (err) throw err
console.error('All done')
})
@jgautheron
jgautheron / errorHandler.js
Created May 10, 2017 14:52
Send client errors to the server
import ReactUpdates from 'react-dom/lib/ReactUpdates'
import ReactDefaultBatchingStrategy from 'react-dom/lib/ReactDefaultBatchingStrategy'
import 'isomorphic-fetch'
const logError = (err, extra = {}) => {
fetch('/logger', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@myshov
myshov / function_invocation.js
Last active August 19, 2024 12:23
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);
describe('Jest Electron Runner', function() {
it('has access to the window', function() {
expect(window).toEqual(global)
})
it('has access to the document', function() {
expect(document).toEqual(global.document)
})
@nuxodin
nuxodin / easy-console.js
Created December 8, 2016 15:13
Like to write to the console like this "console = xyz" instead of "console.log(xyz)" ?
!(function(){
var original = console;
Object.defineProperty(window, 'console', {
get:function(){
return original;
},
set:function(value){
original.log(value)
}
})
@grrowl
grrowl / Signature.js
Created November 19, 2016 02:35
React component to provide ed25519 key generation, signing and verification
import React, { Component, PropTypes } from 'react'
import elliptic, { eddsa as EdDSA } from 'elliptic'
function toHex(arr) {
return elliptic.utils.toHex(arr).toUpperCase()
}
function fromHex(hex) {
return elliptic.utils.toArray(hex, 'hex')