This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { applyPatch } from 'fast-json-patch/index.mjs'; | |
import justDiff from 'just-diff'; | |
const { diff, jsonPatchPathConverter } = justDiff; | |
const doc = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; | |
const patch = diff(doc, [], jsonPatchPathConverter); | |
console.log(patch); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Batman shooting dmt-fibers with a grapple gun | |
// | |
// _____ _____ | |
// ,-'``_.-'` \ / `'-._``'-. | |
// ,` .' |`-'| `. `. | |
// ,` ( /\ | | /\ ) `. | |
// / `--' `-' `-' `--' \ | |
// | | | |
// \ .--. ,--. ,--. ,--. / | |
// `. ( \/ lt.\ / \/ ) ,' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function | |
function: | |
- match: \b(function)\s+({{identifier}}) | |
captures: | |
1: storage.type.function | |
2: entity.name.function | |
push: | |
- function-body | |
- returns-declaration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
function lpad(str, padString, length) { | |
while (str.length < length) str = padString + str; | |
return str; | |
} | |
// converts string '110' to integer 6 | |
function binaryToByte(bin) { | |
return parseInt(bin, 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FormulaParser = require('hot-formula-parser').Parser; | |
const parser = new FormulaParser(); | |
const Excel = require('exceljs'); | |
const workbook = new Excel.Workbook(); | |
function getCellResult(worksheet, cellLabel) { | |
if (worksheet.getCell(cellLabel).formula) { | |
return parser.parse(worksheet.getCell(cellLabel).formula).result; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
#include <WiFiUdp.h> | |
#include <ArduinoOTA.h> | |
#include "ota.h" | |
#include "sounds.h" | |
WiFiServer server(80); | |
const char* ssid = "ssid"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var colors = require('colors'); // npm install colors | |
var moment = require('moment'); // npm install moment | |
var Web3 = require('web3'); // npm install web3 | |
let port = process.argv[2]; | |
function tryWeb3(port) { | |
let web3 = new Web3(); | |
web3.setProvider(new web3.providers.HttpProvider(`http://localhost:${port}`)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://gist.github.com/davidhq/eae55136adc1973b524f7b41746b78ac | |
import Graphics.Collage exposing (..) | |
import Graphics.Element exposing (..) | |
import Color exposing (..) | |
import Keyboard | |
import Time | |
import Debug | |
-- Model | |
type alias Model = { x : Float, y : Float, radius: Float } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Window toggling (switch back and forth between last two focused windows) for Sublime | |
# Add to Key Bindings - User: | |
# { | |
# "keys": ["f3"], | |
# "command": "toggle_windows" | |
# }, | |
# then put toggle_windows.py (this file) into ~/Library/Application Support/Sublime Text 3/Packages/User | |
import os | |
import sublime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git helpers - davidhq | |
function git_repo { | |
local root=$(git rev-parse --show-toplevel || echo ".") | |
local cwd=`pwd` | |
cd $root | |
local origin=$(git remote -v | grep origin | grep push | sed 's/origin//g' | sed 's/[email protected]://g' | sed 's/https:\/\/github.com\///g' | sed 's/.git (push)//g' | xargs) | |
cd $cwd | |
eval "$1=$origin" | |
} |