Skip to content

Instantly share code, notes, and snippets.

@bnchdrff
bnchdrff / mvt-to-js.js
Created March 20, 2020 15:09
example of comparing mvt data
const fetch = require('node-fetch');
const Protobuf = require('pbf');
const { VectorTile } = require('@mapbox/vector-tile');
const { Headers } = fetch;
async function logTile(url) {
const res = await fetch(url);
@bnchdrff
bnchdrff / README.md
Created March 15, 2019 03:07
refactoring then to await
s%\(await .*\).then(\(.*\) => {%const \2 = \1;
s%.then(() =>\_.\W*\(.*\)%await \1
@bnchdrff
bnchdrff / .vimrc
Created November 8, 2018 21:30
my .vimrc
version 5.4
" pathogen!
call pathogen#infect()
call pathogen#helptags()
autocmd!
filetype on
filetype plugin on
syntax on
@bnchdrff
bnchdrff / StatsLoggerClient.js
Created July 11, 2018 14:35
Graphite logger
import net from 'net';
/**
* In production, log stats to graphite if a connection is available.
* In dev, console.log 'em.
*/
export default class StatsLoggerClient {
constructor(GRAPHITE_HOST, GRAPHITE_PORT) {
if (GRAPHITE_HOST && GRAPHITE_PORT) {
this.GRAPHITE_HOST = GRAPHITE_HOST;
@bnchdrff
bnchdrff / tricks.js
Last active February 5, 2018 21:26
cool git-related snippets
// toggle files in PR review
document.querySelectorAll('.file-actions button.js-details-target').forEach(function(el) {el.click()})
@bnchdrff
bnchdrff / dumbscope.cls
Created July 5, 2017 19:14
scope in salesforce apex
class FoobarTest {
String bar;
public String messyScope() {
String bar;
bar = 'messy';
return bar;
}
@bnchdrff
bnchdrff / thready.py
Created March 5, 2017 17:45
v simple threads
import os
import threading
import urllib2
class ThreadHandler(threading.Thread):
def __init__(self, blocking_function):
threading.Thread.__init__(self)
self.runnable = blocking_function
@bnchdrff
bnchdrff / makeadiffdir.sh
Created March 1, 2017 20:20
search only the difffs
# Search through only the diff files from https://archive.org/download/IRS990-efile
cd IRS990-efile/irs_form990_schemas
mkdir diffs
cd diffs
for diffdir in `find ../ -name '*Diffs*'`; do ln -s $diffdir; done
# Now, we have a directory full of symlinks to the diff dirs in each of the schema versions.
# We can grep freely now:
@bnchdrff
bnchdrff / py13_990.sql
Last active August 18, 2016 16:42
irs 990 schemas
CREATE TABLE py13_990 (
"EIN" VARCHAR(9) NOT NULL,
tax_pd INTEGER NOT NULL,
subseccd VARCHAR(2) NOT NULL,
s501c3or4947a1cd BOOLEAN NOT NULL,
schdbind BOOLEAN NOT NULL,
politicalactvtscd BOOLEAN NOT NULL,
lbbyingactvtscd BOOLEAN NOT NULL,
subjto6033cd BOOLEAN NOT NULL,
dnradvisedfundscd BOOLEAN NOT NULL,
@bnchdrff
bnchdrff / addext.php
Created July 26, 2016 15:38
add extensions to file_managed entities
<?php
use Drupal\Core\File\FileSystem;
use Drupal\file\Entity\File;
$container = \Drupal::getContainer();
$eq = $container->get('entity.query');
$fs = $container->get('file_system');