Skip to content

Instantly share code, notes, and snippets.

View JeffreyMFarley's full-sized avatar

Jeff Farley JeffreyMFarley

View GitHub Profile
@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',
@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
@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
const logger = store => next => action => {
console.log( 'dispatching', action );
const result = next( action );
console.log( 'next state', store.getState() );
return result;
};
new BaseJobBuilder(
name: "pr-builder",
description: 'Run unit tests when a pull request is submitted',
).build(this).with {
GhUtils.ghPrWatcher(delegate,
[
ghProject: 'foo/bar',
ghHostname: 'github.com',
ghAuthId: '<#########>',
ghPermitAll: true,
@JeffreyMFarley
JeffreyMFarley / app.js
Last active May 18, 2018 14:38
HTTP via Middleware
import { applyMiddleware, createStore } from 'redux'
import reducers from './reducers';
import thunkMiddleware from 'redux-thunk'
import httpRequestHandler from './httpRequestHandler';
const middleware = [ thunkMiddleware, httpRequestHandler ];
const composeEnhancers = composeWithDevTools( {
// required for redux-devtools-extension
// Specify name here, actionsBlacklist, actionsCreators and other options