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.

@DevinClark
DevinClark / JavaCandR.sublime-build
Created January 18, 2012 16:18
This is a build script for Sublime Text 2 that will compile and run the open java file by simply pressing cmd + B. I am very new at Java so feel free to point out problems with this script. You can just drop this file in the User Packges folder and restar
{
"cmd": ["javac", "$file_name"],
"cmd": ["java", "$file_base_name"],
"working_dir": "${project_path:${folder}}",
"selector": "source.java"
}
@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
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
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
watch: {
sass: {
files: ['scss/*.scss'],
tasks: ['compass']
},