Skip to content

Instantly share code, notes, and snippets.

View agryson's full-sized avatar

Alexander Gryson agryson

View GitHub Profile
@agryson
agryson / pngexport.sh
Created March 18, 2017 17:32
Exports pngs and svgs in current folder to a big spritesheet.
#!/bin/bash
# Creates a spritesheet of all png and svg images in the current folder in
# 16, 24, 32 and 64px on light, mid-grey and dark backgrounds.
#
# Requirements: Inkscape, Imagemagick, optipng
#
# Arguments: ["dev"] Optional, if present, will export and then get all the
# exported sheets and combine them in a global sheet.
# If absent, will simply export to pngs and create a light, dark and mid-grey spritesheet
@agryson
agryson / export_png.sh
Last active January 17, 2017 21:20
Exports all svgs in the current folder to png's of the specified size (64px by default)
#!/bin/bash
input=${1:-64}
#Creates output directory if it doesn't exist and empties it.
mkdir ~/Pictures/exportOutput
rm ~/Pictures/exportOutput/*.png
for file in *.svg
do
@agryson
agryson / small_icons.sh
Created December 15, 2016 11:33
Loops through icons in a folder and alerts to any icons below standard size
#!/bin/bash
for file in *.svg
do
height=$(/usr/bin/inkscape -H $file)
width=$(/usr/bin/inkscape -W $file)
#Generally the icons have a bit of margin around them, so tune this value appropriately
if [[ $height < 55 ]] && [[ $width < 55 ]]; then
echo $file" : "$height" x "$width
fi
@agryson
agryson / freecad_metadata.sh
Last active December 18, 2016 13:26
Updates the metadata of all svgs in a folder to sensible defaults if empty, doesn't change the field if not
#!/bin/bash
# Loops through all svg files in a directory
# Fields with an existing value are left alone
# Empty fields are filled with sensible defaults
# Licensing or Rights information is flagged for manual review
for file in *.svg
do
me="[agryson] Alexander Gryson"
@agryson
agryson / Notifier.js
Last active December 15, 2016 12:11
A Google App Script to notify someone specific when a file has been added to a folder.
/**
* Attribution: Alexander Gryson (agryson.net)
* This script stores a listing of the files in a folder.
* If a new item is placed in the folder, an email will be sent.
* LIMITATION: This script can only handle about 70 listings due to the 9kb limit for properties.
* If the number of listings goes above 50, a warning will be sent.
*/
function listFilesInFolder() {
var folderID = '1234567890AZERTYUIOPQSDFGHJKLM_EXAMPLE'; //ID of the folder to watch
var admin = 'admin_example@gmail.com'; //Email of the person to notify
@agryson
agryson / classChanger.js
Last active December 15, 2016 12:11
This function will append or remove a class from an element cleanly by ensuring whitespace is how it should be.
/**
* Attribution: Alexander Gryson (agryson.net)
* Appends or removes a class to/from an element
* @param {boolean} bool True if appending class, false if removing
* @param {string} targetID ID of target element
* @param {string} classString Class to be added / removed (case sensitive)
*/
function classChange(bool, targetID, classString){
var target = document.getElementById(targetID);