Skip to content

Instantly share code, notes, and snippets.

View JeffreyMFarley's full-sized avatar

Jeff Farley JeffreyMFarley

View GitHub Profile
@JeffreyMFarley
JeffreyMFarley / dups.sh
Last active August 25, 2020 14:17
Find Duplicated Javascript code
#!/bin/sh
files=frontend/src/static/js
pmd cpd --language ecmascript --minimum-tokens 25 --files "$files" --format csv \
| sed "1s/.*/lines,tokens,occurrences,L1,F1,L2,F2,L3,F3,L4,F4/" \
| sed "s|$(pwd)/$files|.|g" \
> dups.csv
@JeffreyMFarley
JeffreyMFarley / hack.html
Created February 3, 2017 14:05
input[type=date] with placeholder
<input type="text"
placeholder="from"
onfocus="(this.type='date')"
onblur="(this.type='text')"
ng-model="dateMin" />
@JeffreyMFarley
JeffreyMFarley / tfidf.py
Created March 6, 2017 19:11
Partial TFIDF implementation
# -*- coding: utf-8 -*-
import math
from collections import Counter
from decimal import *
from operator import itemgetter
from functools import partial
from collections import defaultdict
EXCLUSIONS = {'wherein', 'plurality', 'configure', 'thereof', 'comprise',
import unicodedata
def normalize(s):
t = buildTable()
# remove non-ASCII
b = unicodedata.normalize('NFKD', s)
return b.translate(t)
# Recommend caching this
@JeffreyMFarley
JeffreyMFarley / ascii_image.py
Created May 24, 2017 13:06
Create ASCII art from image file
# Adapted from https://www.hackerearth.com/practice/notes/beautiful-python-a-simple-ascii-art-generator-from-images/
# Tuned for album covers (i.e. known to be square)
# Tuned for display in the console (the fixed aspect ratio)
from PIL import Image
# Reverse the values to invert the image
ASCII_CHARS = [' ', '.', ',', ':', '-', '=', '+', '*', '#', '%', '@']
@JeffreyMFarley
JeffreyMFarley / webpack-upgrade-failure.md
Last active August 18, 2017 15:11
Trying to upgrade to Webpack 2 (or 3)

Upgrade npm packages

Gordian Knot version

  1. rm -rf package-lock.json
  2. rm -rf node_modules
  3. open package.json
  4. copy dependencies and devDependencies to temp file
  5. clear those blocks
  6. format the two blocks
#!/bin/bash
# -----------------------------------------------------------------------------
SRC_DIR=./path/to/files
# -----------------------------------------------------------------------------
direct-query() {
raw="$2"
@JeffreyMFarley
JeffreyMFarley / .travis.yml
Created August 23, 2017 20:00
A Travis file used for building assets and pushing to master
language: node_js
node_js:
- 8
install:
- npm install
script:
- npm test
aqualite ride the rhythm
art of noise close to the edit
astrud gilberto with stan getz the girl from ipanema
atari teenage riot kids are united
atari teenage riot sick to death
atari teenage riot speed
atomic babies purple
autechre second bad vilbel
aux 88 electro/techno
bally sagoo dil cheez
@JeffreyMFarley
JeffreyMFarley / looping-pu.sh
Last active October 13, 2017 15:20
pu.sh (infinite loop version)
#!/bin/sh
setup_git() {
# Set the user name and email to match the API token holder
# This will make sure the git commits will have the correct photo
# and the user gets the credit for a checkin
git config --global user.email "foo@users.noreply.github.com"
git config --global user.name "foo"
git config --global push.default matching