Skip to content

Instantly share code, notes, and snippets.

Joe Gaffey joegaffey

Block or report user

Report or block joegaffey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gamepad.ino
// Simple gamepad example that demonstraits how to read five Arduino
// digital pins and map them to the Arduino Joystick library.
//
// The digital pins are grounded when they are pressed.
//
// NOTE: This sketch file is for use with Arduino Leonardo and
// Arduino Micro only.
//
// Modified version of original code by Matthew Heironimus
// 2018-08-11
@joegaffey
joegaffey / scraper.js
Created Jul 25, 2018
Simple scraper snippet. Paste it into the console of a page with a list of links where you want to pull specific items from each link. Change selector consts according to your needs.
View scraper.js
const linksSelector = '.link-selector';
const itemSelectors = ['.item1', '.item1', '.item1'];
const anchors = document.querySelectorAll(linksSelector);
const links = [];
anchors.forEach((anchor) => { links.push(anchor.href) });
const results = [];
links.forEach((link) => {
@joegaffey
joegaffey / file_sort_month_num.sh
Last active Jan 1, 2018
Sort files into folders by month number. Pass file name pattern in a parameter in quotes e.g. '*.jpg'.
View file_sort_month_num.sh
#!/bin/bash
months=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
monthNums='01 02 03 04 05 06 07 08 09 10 11 12'
echo $monthNums | xargs mkdir
i=0
for monthNum in $monthNums
do
ls -l $1 | grep ${months[$i]} | awk '{print $NF}' | xargs -I {} mv {} ./$monthNum
@joegaffey
joegaffey / file_sort_month.sh
Last active Jan 1, 2018
Sort files into folders by month. Pass file name pattern in a parameter in quotes e.g. '*.jpg'.
View file_sort_month.sh
#!/bin/bash
months='Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'
echo $months | xargs mkdir
for month in $months
do
ls -l $1 | grep $month | awk '{print $NF}' | xargs -I {} mv {} ./$month
done
@joegaffey
joegaffey / D3 sequence diagram
Last active Mar 8, 2019
D3.js sequence diagram
View D3 sequence diagram
<!DOCTYPE html>
<meta name="robots" content="noindex">
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Sequence Diagram</title>
</head>
<body>
You can’t perform that action at this time.