Skip to content

Instantly share code, notes, and snippets.

View jaxn's full-sized avatar

Jackson Miller jaxn

  • https://resaleai.com
  • Nashville, TN
  • X @jaxn
View GitHub Profile
@jaxn
jaxn / thermal_setup.md
Created November 2, 2017 02:20
Setup a thermal printer
  • Go to Devices & Printers (Control Panel\All Control Panel Items\Devices and Printers)
  • On the top menu, there is “Add a Printer”. (Windows 8.1)
  • Select “The printer I want isn’t listed” => Next
  • “Add a local printer with manual settings” => Next
  • “Use an Existing Port” and select “USB001 (Virtual Printer Port For USB)” => Next
  • Select “Generic” from Manufacturer, “Generic / Text Only” from Printers => Next
  • If it asked, which version you want, keep recommended option and => Next
  • Give a Printer Name, E.g.: “POS58” => Next
  • “Do not share” but if you want, share it.
  • Turn on your printer and click on “Print a test page”. It should print a long text.
@jaxn
jaxn / application_system_test_case.rb
Last active September 19, 2017 17:14
Migrate to chromedriver from capybara-webkit for Rails with WSL support
require 'test_helper'
# Capybara driver chosen based on the value of ENV['TEST_WITH_CHROME']
# - `false` - use capybara-webkit
# - `headless` - chromedriver in headless mode
# - `true` (or any other value) - chromedriver in a Window
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
if ENV['TEST_WITH_CHROME'] && ENV['TEST_WITH_CHROME'] != 'false'
require "selenium/webdriver"
@jaxn
jaxn / .bashrc
Created June 5, 2017 03:35
.bashrc for WSL
# shell function to compress image sizes
# smartresize inputfile.png 300 outputdir/
# credit: https://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/
smartresize() {
mogrify -path $3 -filter Triangle -define filter:support=2 -thumbnail $2 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB $1
}
@jaxn
jaxn / rails_setup.sh
Last active June 4, 2017 20:32
Ruby on Rails setup script for WSL
#!/bin/sh
# bash -c "$(curl -fsSL https://gist.github.com/jaxn/e1fd1442582141282d8bebdeec536fd8/raw)"
read -r -p "Would version of ruby would you like to install? " rubyversion
read -r -p "Would version of rails would you like to install? " railsversion
echo "Installing dependencies"
sudo apt-get --assume-yes -qq update
sudo apt-get --assume-yes -qq install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs openssh-server qt5-default libqt5webkit5-dev xvfb libmagickwand-dev
cd
if [ ! -d ~/.rbenv ] ; then
echo "Installing rbenv"
@jaxn
jaxn / interface_driver.rb
Last active January 5, 2017 19:11
Interface pattern for Single Table Inheritance model in Rails
# An example driver with multiple implementations
#
# Allows documentation on the parent class while implementing functionality on the child classes.
# Raises a NoMethodError if the child class does not implement a documented method
class InterfaceDriver < ActiveRecord::Base
self.inheritance_column = :type
def abstract( method ) #:nodoc:
raise NoMethodError.new("undefined abstract method `#{method}' called for InterfaceDriver <#{self.class}:#{self.id}>")
end