Skip to content

Instantly share code, notes, and snippets.

View DevinClark's full-sized avatar

Devin Clark DevinClark

View GitHub Profile
@DevinClark
DevinClark / fuzzySearch.ts
Last active December 13, 2021 17:20
Simple fuzzy searching algorithm
/**
* A fuzzy match algorithm.
* @param {string} needle the string to search for
* @param {string} haystack the string to search in
*/
export function fuzzyMatch(needle: string = "", haystack: string = "") {
const haystackLen = haystack.length;
const needleLength = needle.length;
needle = needle.toLowerCase();
@DevinClark
DevinClark / unique-viewport-links.js
Created October 21, 2021 15:49
Get unique links in viewport of a page

Keybase proof

I hereby claim:

  • I am devinclark on github.
  • I am dddev (https://keybase.io/dddev) on keybase.
  • I have a public key ASBskmZ3qM25Ebyknx2SPjI1KvjP9sS229__NQpZ79i4Awo

To claim this, I am signing this object:

@DevinClark
DevinClark / day2.js
Created December 3, 2019 18:41
Advent of Code
const { deepStrictEqual } = require('assert');
const fs = require('fs');
const ADDITION = 1;
const MULTIPLCATION = 2;
const EOF = 99;
const DEBUG = false;
function executeProgram(input) {
const program = input.split(',').map((v) => parseInt(v));
@DevinClark
DevinClark / index.js
Created May 21, 2018 15:33
given a list of dependencies, grab their version, license information, and dependencies, then grab version and license information for the dependencies. Outputs an html list.
const fs = require('fs');
const getLatestVersion = require('latest-semver');
const semver = require('semver');
require('isomorphic-fetch');
const NPM = 'https://registry.npmjs.com';
function getPackage(name) {
return fetch(`${NPM}/${name}`)
.then(function (response) {
@DevinClark
DevinClark / info.md
Created August 29, 2016 15:39
CommonsChunkPlugin

It takes the modules that are common between X number of your entry points and puts them in a "common.js" file.

So if I have 3 entry points (one for each page of my application) and they all require React, the common.js file will have react in it. I can cache this file longer than the pageX.js files and my pageX.js bundles will be smaller because they don't have React.

var glob_entries = require('webpack-glob-entries');
var webpack = require('webpack');
var validate = require('webpack-validator');
var env = process.env.NODE_ENV || 'development';
var entries = glob_entries('./src/js/component/page/*.js');
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
var webpackConfig = {
// create multiple entry points from all of the page level components
@DevinClark
DevinClark / Issue.md
Created November 13, 2015 20:53
Mapbox GL Raster Rendering Issues

We have a tile server for radar data. (It also serves up country tiles (for whatever reason) so I am using that for my first example).

@DevinClark
DevinClark / btsync
Created April 3, 2015 03:24
UFW Application Profile for BitTorrent Sync
[btsync]
title=BitTorrent Sync
description=Fast, private file sharing for teams and individuals.
ports=3000/tcp|1900/udp|58610/udp|3838/udp|19717/tcp|50443/udp
$stateProvider
.state({
name: 'root',
url: '',
abstract: true,
templateUrl: '/templates/root.html',
controller: 'MainController',
controllerAs: 'Main',
resolve: {
token: function ($q, Auth) {