Skip to content

Instantly share code, notes, and snippets.

View kevinhughes27's full-sized avatar

Kevin Hughes kevinhughes27

View GitHub Profile
@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 / 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 / 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 / robust_pca_project.py
Last active January 2, 2016 23:29
An Implementation of the robust subspace projection technique described in: A. Leonardis and H. Bischof. Robust recognition using eigenimages. Computer Vision and Image Understanding, 78:99--118, 2000. based off of source provided by the original authors
#!/usr/bin/env python
# robust_pca_project.py
#
# Author: Kevin Hughes
# Date: May 2013
"""
An Implementation of the robust subspace projection technique described in:
@kevinhughes27
kevinhughes27 / cv2sg.cpp
Last active December 24, 2015 05:39
Using OpenCV and Shogun Machine Learning
/* Using OpenCV and Shogun Machine Learning
* gist by Kevin Hughes
*/
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <shogun/base/init.h>
#include <shogun/lib/common.h>
#include <shogun/lib/SGMatrix.h>
@kevinhughes27
kevinhughes27 / eigen3_snips.cpp
Last active July 22, 2023 00:15
Eigen3 Snips
using namespace Eigen;
// these are the typedefs I like to work with
typedef Matrix< double, Dynamic, 1, ColMajor > EVector;
typedef Matrix< double, Dynamic, Dynamic, ColMajor > EMatrix;
// Mean
EVector mean = X.rowwise().sum() / X.rows();
// Standard Deviation
@kevinhughes27
kevinhughes27 / Eigen3_NumPy_Print.cpp
Last active December 21, 2015 18:29
NumPy style printing in C++ for Eigen 3
using namespace Eigen;
typedef Matrix< float64_t, Dynamic, Dynamic, ColMajor > EMatrix;
using std::cout;
using std::endl;
void print(EMatrix A)
{
int n = A.rows();
int m = A.cols();
@kevinhughes27
kevinhughes27 / opencv_blackfly.cpp
Last active January 24, 2024 19:39
A simple program showing how to capture from a Point Grey Research Camera and display the image using OpenCV
#include "FlyCapture2.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace FlyCapture2;
int main()
@kevinhughes27
kevinhughes27 / setdir.sh
Created April 4, 2013 16:17
Sets the directory for execution to be the lowest directory. This is helpful for ensuring relative paths work inside your program
#!/bin/bash
set -e
cd $(readlink -f $(dirname $0))
exec ./exe $*
@kevinhughes27
kevinhughes27 / CMakeLists.txt
Created April 4, 2013 15:57
PCL CMake File
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(HelloWorld)
set(EXE HelloWorld)
find_package(PCL 1.6 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})