Skip to content

Instantly share code, notes, and snippets.

View benjamine's full-sized avatar

Benjamín Eidelman benjamine

View GitHub Profile
@benjamine
benjamine / trie-fp.js
Last active December 19, 2018 22:49
trie.js
class Trie {
head = {
key: "",
children: {}
};
add(key) {
var curNode = this.head,
newNode = null,
curChar = key.slice(0, 1);
@benjamine
benjamine / trie.js
Created December 19, 2018 22:37 — forked from alexandervasyuk/trie.js
Trie
function Trie() {
this.head = {
key : ''
, children: {}
}
}
Trie.prototype.add = function(key) {
var curNode = this.head
@benjamine
benjamine / mongo-batch-fix.js
Last active January 29, 2018 23:50
node script to fix mongo docs with controlled concurrency
#!/usr/bin/env node
/*
Requirements:
- node v8.9.3+
- npm install mongodb
- npm install p-queue
*/
const PQueue = require('p-queue');
const mongodb = require('mongodb');
@benjamine
benjamine / keybase.md
Last active October 18, 2016 19:34
keybase.md

Keybase proof

I hereby claim:

  • I am beneidel on github.
  • I am beneidel (https://keybase.io/beneidel) on keybase.
  • I have a public key ASDsB6M0V-pPHMO1aW1pfw961Iguy8pzo5Hyo2E9_cZOLAo

To claim this, I am signing this object:

@benjamine
benjamine / github-markdown-diff-richify.user.js
Last active September 23, 2016 02:56
Enhances Github Markdown Diffs
// ==UserScript==
// @name GithubMarkdownDiffRichify
// @namespace http://tampermonkey.net/
// @version 0.1
// @description enhances markdown diffs in github, makes links clickable and embeds images (only images in the repo)
// @author https://github.com/benjamine
// @match https://github.com/*/pull/*
// @match https://github.com/*/compare/*
// @match https://github.com/*/commit/*
// @grant none
@benjamine
benjamine / screen-record.sh
Last active March 27, 2018 01:06
record screen (with webcam overlay)
#!/bin/sh
# brew install ffmpeg
ffmpeg -thread_queue_size 50 \
-f avfoundation -framerate 30 -i "1" \
-thread_queue_size 50 -f avfoundation -framerate 30 -video_size 640x480 -i "0" \
-c:v libx264 -crf 18 -preset ultrafast \
-filter_complex 'overlay=main_w-overlay_w-10:main_h-overlay_h-10' -r 30 screen-capture.mkv
@benjamine
benjamine / bootstrap-grid-bookmarklet.js
Created February 23, 2015 16:09
bootstrap grid bookmarklet
/*
<style type="text/css">
#grid {
display: none;
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
@benjamine
benjamine / README.md
Last active August 29, 2015 14:10
driver-agnostic page objects

this is a preview of a page object model that works independently of the browser driver. page and component object define a hierarchy, and each of this objects expose a .s property that has an absolute css selector to find the element (eg. using document.querySelector), the way that property is built is by space-concatenating the css selectors of it's ancestors.

  var page = this.page('checkout');
  // page.orderConfirmation.purchase.s === ['#main .order-confirmation', 'button.purchase-btn'].join(' ')
  browserDriver.click(page.orderReview.purchase.s);
@benjamine
benjamine / its-programmers-day.js
Created September 13, 2014 18:27
it's programmer's day
itsProgrammersDay=((j1=new Date()).setMonth(0, 0),Math.round((new Date()-j1)/8.64e7)===Math.pow(2, 8));
@benjamine
benjamine / thirteen.js
Created August 18, 2014 21:56
thirteen.js
function sort(s) { return s.split('').sort().join(''); }
sort("eleven plus two") === sort("twelve plus one");