Skip to content

Instantly share code, notes, and snippets.

View pianomanfrazier's full-sized avatar

Pianomanfrazier pianomanfrazier

View GitHub Profile
#!/bin/bash
#By Dave Newton from SmashingMagazine article
#This function is from https://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/
#I am puting this here so I can find it when I need it. Super helpful for web image resizing.
#
# usage:
# smartresize inputfile.png 300 outputdir/
smartresize() {
@pianomanfrazier
pianomanfrazier / search.py
Last active August 16, 2018 22:07
Fuzzy search openstorefront permissions (run on WSL)
#!./venv/bin/python
import os, sys, glob, re
from fuzzywuzzy import fuzz
LOWER = 60
UPPER = 99
pattern = re.compile(r'".+?"|\'.+?\'')
permFile = "/mnt/c/dev/openstorefront/server/openstorefront/openstorefront-core/model/src/main/java/edu/usu/sdl/openstorefront/core/entity/SecurityPermission.java"
rootDir = "/mnt/c/dev/openstorefront/server/openstorefront"
@pianomanfrazier
pianomanfrazier / vscode_settings.json
Last active August 21, 2018 02:44
My vscode settings
{
"vim.disableAnnoyingNeovimMessage": true,
"files.associations": {
"*.mmark":"markdown"
},
"extensions.ignoreRecommendations": false,
"window.zoomLevel": 1,
"emmet.syntaxProfiles": {
"javascript": "vue"
},
@pianomanfrazier
pianomanfrazier / i3-config.txt
Created August 26, 2018 04:11
My i3 config for my laptop
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@pianomanfrazier
pianomanfrazier / README.md
Last active October 12, 2018 16:42
A simple JSON Flask test

Run the app as follows:

# install flask and requests
virtualenv venv -p python3
source ./venv/bin/activate
pip install flask requests
FLASK_APP=app.py FLASK_DEBUG=1 flask run
# add this to your bashrc to generate a weekly git report
# useage: $ report
alias report='git log --branches=* --pretty=format:"%ad - %an: %s" --after=$(date +%Y-%m-%d -d "-9 day") --until=$(date +%Y-%m-%d) --author="YOUR NAME"'
@pianomanfrazier
pianomanfrazier / fact.rs
Last active January 1, 2019 23:48
A factorial test in Rust
use std::cmp::Ordering;
use std::io;
const ONE: u64 = 1;
fn main() {
loop {
let mut guess = String::new();
io::stdin()
@pianomanfrazier
pianomanfrazier / references.fs
Created January 2, 2019 00:57
Playing around with Rust ownership
fn main() {
let x = String::from("hello"); // allocate from the heap
let mut y = x;
// let mut y = x.clone(); // clone if you want to use x again
y.push_str(", world! ");
append(&mut y);
print(&y);
append(&mut y);
print(&y);
@pianomanfrazier
pianomanfrazier / check_escaped_utf8.py
Created January 10, 2019 21:22
The product export from the database had mangled characters in it. This function grabs all the decimal encoded characters and writes it to an html file for inspection.
import xml.etree.ElementTree as ET
import html
def inspect_escape_characters():
filename = "products.xml"
print(f'XML file: {filename}')
tree = ET.parse(filename)
root = tree.getroot()
all_descriptions = []
count = 0