Skip to content

Instantly share code, notes, and snippets.

View dgaitsgo's full-sized avatar

David Gaitsgory dgaitsgo

View GitHub Profile
@dgaitsgo
dgaitsgo / compare.json
Created February 26, 2019 23:40
Models to Compare Json
{
"e27390fd-e2a2-57d5-ad4f-a2d63371c851": {
"model": {
"id": "e27390fd-e2a2-57d5-ad4f-a2d63371c851",
"name": "Fabia Wagon"
},
"defaultOptions": {
"data": [
{
"id": "73dc2d3b-b071-5802-8b81-b4c7f3bd354b"
@dgaitsgo
dgaitsgo / index.js
Created February 27, 2019 04:18
Local storage helper
import PouchDB from 'pouchdb'
import PouchDBFind from 'pouchdb-find'
import PouchDbQuickSearch from 'pouchdb-quick-search'
PouchDB.plugin(PouchDBFind)
PouchDB.plugin(PouchDbQuickSearch)
//convenience function do get individual error handling for an array of Promises
const to = promise =>
promise.then(data => [null, data])
@dgaitsgo
dgaitsgo / .gitignore
Last active March 2, 2019 09:43
Typescript React Native - App Setup
# OSX
#
.DS_Store
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
@dgaitsgo
dgaitsgo / ssh-active-docker-machine.sh
Created March 7, 2019 05:00
SSH into active docker machine
#!/bin/bash
docker_machine_name=$(docker-machine active)
docker_ssh_user=$(docker-machine inspect $docker_machine_name --format={{.Driver.SSHUser}})
docker_ssh_key=$(docker-machine inspect $docker_machine_name --format={{.Driver.SSHKeyPath}})
docker_ssh_port=$(docker-machine inspect $docker_machine_name --format={{.Driver.SSHPort}})
ssh -i $docker_ssh_key -p $docker_ssh_port $docker_ssh_user@localhost
@dgaitsgo
dgaitsgo / asyncForEach.js
Created March 11, 2019 23:46
Async For Each
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
@dgaitsgo
dgaitsgo / cycleIndices.js
Created March 16, 2019 12:32
Cycle Indices
// down
const nextIndex = ( currIdx - 1 + elems.length ) % elems.length
// up
const nextIndex = ( currIdx + 1) % elems.length
@dgaitsgo
dgaitsgo / get_cdc_measles_data.py
Created August 6, 2019 10:19
Fetching and parsing CDC for cumulative year to date total measles cases by state, territory and region
# coding: utf-8
# In[30]:
import os
import json
from contextlib import closing
from bs4 import BeautifulSoup
import csv
@dgaitsgo
dgaitsgo / polynomial.ne
Created October 10, 2019 04:58
2nd Degree Polynomial Nearley Parser
main ->
polynom
polynom ->
_ add_sub _
| _ add_sub _ "=" _ add_sub _
parens ->
"(" _ add_sub _ ")"
| term
@dgaitsgo
dgaitsgo / number.ne
Created October 13, 2019 09:59
Improved canonical nearley number parser
number ->
int {% id %}
| float {% id %}
| "-" int {% function(d) { return(d[0] + d[1]) } %}
| "-" float {% function(d) { return(d[0] + d[1]) } %}
float ->
int "." [0-9]:+ {% function(d) { return(d[0] + d[1] + d[2].join("")) } %}
| "." [0-9]:+ {% function(d) { return(d[0] + d[1].join("")) } %}
@dgaitsgo
dgaitsgo / Polynomial-no-parens.ne
Last active October 13, 2019 15:42
Single variable polynomial parser without parens
@{%
const filter = d => d.filter(dp => dp)
%}
main ->
_ add_sub _ {% filter %}
| _ add_sub _ "=" _ add_sub _ {% filter %}
exp ->
add_sub _ "^" _ exp