Skip to content

Instantly share code, notes, and snippets.

View kevinhughes27's full-sized avatar

Kevin Hughes kevinhughes27

View GitHub Profile
@kevinhughes27
kevinhughes27 / cv2_video_starter.py
Created February 8, 2014 02:42
a simple starting framework for grabbing frames from a camera or video file using OpenCV and python.
import cv2
CAMERA_INDEX = 0
CODEC = cv2.cv.CV_FOURCC('D','I','V','X')
FPS = 15
def main():
cam = cv2.VideoCapture()
cam.open(CAMERA_INDEX)
@kevinhughes27
kevinhughes27 / the_arborist.rb
Last active January 7, 2022 22:53
find un-deleted branches from closed PRs
#!/usr/bin/env ruby
require 'octokit'
require 'highline/import'
require 'colorize'
require 'byebug'
require 'csv'
require 'active_support/time'
username = ask("Enter your Github username: ") { |q| q.echo = true }
@kevinhughes27
kevinhughes27 / product_update
Created April 3, 2014 16:20
update shopify product inventory with the API
I start by getting the product data from Shopify for the product in question, you might already have this data in your database. Using the Shopify API gem for ruby this looks like:
ruby > product = ShopifyAPI::Product.find(183524354)
which returns the following JSON:
{"body_html":"A Baseball Cap","created_at":"2014-03-14T19:25:19-04:00","handle":"moose","id":183524354,"product_type":"hat","published_at":"2014-03-14T19:25:05-04:00","published_scope":"global","template_suffix":null,"title":"Hat","updated_at":"2014-04-03T12:06:34-04:00","vendor":"kevins_sweet_test_shop","tags":"","variants":[{"barcode":null,"compare_at_price":null,"created_at":"2014-03-14T19:25:19-04:00","fulfillment_service":"manual","grams":0,"id":419761934,"inventory_management":"shopify","inventory_policy":"deny","option1":"Red","option2":null,"option3":null,"position":1,"price":"10.00","product_id":183524354,"requires_shipping":true,"sku":"","taxable":true,"title":"Red","updated_at":"2014-04-03T12:06:34-04:00","inventory_quantity":10,"old
@kevinhughes27
kevinhughes27 / gh_issue_maker.rb
Created December 29, 2014 23:19
One time I didn't have internet so I wrote up a bunch of issues in json and then used this script to push them up to Github
require 'json'
require 'octokit'
Octokit.configure do |c|
c.login = 'pickle27'
c.password = '<github token>'
end
repo = ARGV[0]
file = ARGV[1]
@kevinhughes27
kevinhughes27 / hydra.lua
Created January 22, 2015 15:48
my half done config for hydra (osx window manager, now https://github.com/sdegutis/mjolnir) using thirds
-- autostart hydra
autolaunch.set(true)
-- watch for changes
pathwatcher.new(os.getenv("HOME") .. "/.hydra/", hydra.reload):start()
-- notify on start
hydra.alert("Hydra config loaded", 0.5)
-- open a repl
@kevinhughes27
kevinhughes27 / sleepy-bash.sh
Last active April 2, 2017 04:18
bash sleep prank
#!/usr/bin/env bash
# sleepy-bash
# kevin hughes
# [email protected]
# 2015
# on each run this script reads a var increments
# it then sleeps for that long.
@kevinhughes27
kevinhughes27 / zuluru-scrape-polys.js
Last active August 29, 2015 14:25
scrape the actual polygon points from zuluru field drawings
// run by pasting the function into dev console then call it
// can also use something like Custom JavaScript for websites:
// https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija
// name and field are set by Zuluru
function scrape() {
data = ""
fields.forEach(function(field){
@kevinhughes27
kevinhughes27 / my-fitness-pal-scrape.py
Created August 23, 2015 17:36
scrape date between 2 date ranges from my fitness pal. Scrapes current nutrients being tracked but you can change your settings and re-run the scraper
import myfitnesspal # pip install myfitnesspal
import ipdb
print 'logging in ...'
client = myfitnesspal.Client('username', 'password')
days = []
for i in range(2, 18+1):
print 'fetching 2015, 6,', i
days.append( client.get_date(2015, 6, i) )
@kevinhughes27
kevinhughes27 / coding-timer.sh
Created November 28, 2015 01:10
A simple program to display a warning message if I have been coding for more than 90 mins
#!/usr/bin/env bash
# add to cron tab
# crontab -e
# then append:
# */30 * * * * /home/kevin/coding-timer.sh
# need to have:
# xhost local:mpromber > /dev/null
# in bashrc
@kevinhughes27
kevinhughes27 / avgEpisode.py
Created January 10, 2016 18:16
the script I used to average every episode of That 70's Show into a singe video
# first mount the samba share (use the gui)
# then link the mounted smb share somewhere more convientent
# sudo ln -s /run/user/1000/gvfs/smb-share:server=dlink-71f6dd,share=volume_1-1 /mnt/network
# then run as usual
# python avgEpisode.py /mnt/network/TV\ Shows/That\ \'70s\ Show/ output.avi
import os
import sys