Skip to content

Instantly share code, notes, and snippets.

View agritheory's full-sized avatar

Tyler Matteson agritheory

View GitHub Profile
@agritheory
agritheory / HID_scanner.js
Created December 13, 2018 12:06
HID_scanner.js
// USB Event Detection
const usbDetect = require('usb-detection');
// USB HID library used to interface with USB devices
const HID = require('node-hid');
class Scanner {
constructor(config, socket) {
this.socket = socket;
this.device = null;
sudo apt-get install git
sudo apt-get install python-minimal
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.ubuntu-tw.org/mirror/mariadb/repo/10.3/ubuntu xenial main'
sudo apt-get update
sudo apt-get install mariadb-server-10.3
sudo apt-get install libmysqlclient-dev
sudo apt install python-pip
# do not upgrade pip; breaks in pip bench install
@agritheory
agritheory / ocr.py
Last active September 27, 2018 01:16
Tesseract + Python Stub for Python project night
# install tesseract per instructions for your os
# ubuntu: sudo apt-get install tesseract-ocr
# sudo pip install pytesseract
# sudo pip install python-Levenshtein
# sudo pip install fuzzywuzzy
# load image(s) in working directory
import re
import pytesseract
import pillow
@agritheory
agritheory / datenight.py
Created July 26, 2018 19:41
NH python datetime code
# datetime
# dateutil
# parser is awesome: https://dateutil.readthedocs.io/en/stable/parser.html, built into pendulum and Maya
# datetime
# arrow vs pendulum: https://www.reddit.com/r/Python/comments/595tcd/please_stop_using_arrow_for_your_datetime/
# timestring -> similar to ctparse
@agritheory
agritheory / opening_invoice_creation_tool.py
Last active May 22, 2018 21:24
Open invoice tool edits - lines 176 - 181
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _, scrub
from frappe.utils import flt, nowdate
from frappe.model.document import Document
@agritheory
agritheory / bench_setup.sh
Last active May 21, 2018 17:51
Bench and setup commands to remember
# Manual Install:
git clone https://github.com/frappe/bench bench-repo
pip install --user -e bench-repo
#delete existing site databases if reinstalling:
sudo mysql -u root - p # then it expects root MySQL password
show databases;
drop database alskjdfhalsdfhasldfj;
# name the bench based on client or workflow desired eg "Evaqua" or frappe-bench-backup
@agritheory
agritheory / manch_vegas.py
Created April 27, 2018 11:31
Hypothesis Example from NH Python project night 4/26/18
import unittest
import datetime as dt
from hypothesis import assume, given, example
from hypothesis.strategies import text, integers, floats, dates, composite, shared
# also discuss: from_regex, random and shared strategies: http://hypothesis.readthedocs.io/en/latest/data.html
class TestTransaction(unittest.TestCase):
@composite