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
import React from 'react';
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = { counter: 0 };
this.increment = this.increment.bind(this);
}
increment() {
@mcdougal
mcdougal / _error.js
Created September 28, 2018 11:53
Using @sentry/browser with Next.js for client and server-side rendering
import * as Sentry from '@sentry/browser';
import getConfig from 'next/config';
import React from 'react';
const { SENTRY_DSN } = getConfig().publicRuntimeConfig;
Sentry.init({ dsn: SENTRY_DSN });
/**
* Send an error event to Sentry.
@oliveratgithub
oliveratgithub / emojis.json
Last active May 24, 2024 08:06
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "👩‍👩‍👧‍👧", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "👩‍👩‍👧‍👦", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "👩‍👩‍👦‍👦", "category": "People & Body (family)", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "👨‍👩&z
@moimikey
moimikey / fill-array.js
Created December 5, 2017 01:35
fill array with value of variable in javascript in 49 bytes
const o = { a: true };
[...Array(9)].map(Function.prototype.valueOf, o);
@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({