Skip to content

Instantly share code, notes, and snippets.

View shaneparsons's full-sized avatar

Shane Parsons shaneparsons

View GitHub Profile
@shaneparsons
shaneparsons / ExportSymbolsAsPNG.jsx
Last active May 19, 2016 16:26
Illustrator Script - Batch Export Symbols as PNGs
var doc = app.activeDocument;
var symbolCount = doc.symbols.length;
if (symbolCount >= 1) {
if (confirm("Are all your layers hidden?")) {
// choose directory
var dest = Folder(doc.path).selectDlg();
@shaneparsons
shaneparsons / ExportSymbolsAsSVG.jsx
Last active May 19, 2016 16:26
Illustrator Script - Batch Export Symbols as SVGs
var doc = app.activeDocument;
var symbolCount = doc.symbols.length;
if (symbolCount >= 1) {
if (confirm("Are all your layers hidden?")) {
// choose directory
var dest = Folder(doc.path).selectDlg();
@shaneparsons
shaneparsons / elixir-extensions.js
Last active December 4, 2015 18:54
laravel-elixir-imagemin - minify images
var gulp = require('gulp');
var Elixir = require('laravel-elixir');
var changed = require('gulp-changed');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var Task = Elixir.Task;
Elixir.extend('images', function (src, output) {
new Task('images', function () {
@shaneparsons
shaneparsons / elixir-extensions.js
Last active December 4, 2015 18:54
laravel-elixir-svgstore - create svg sprites
var gulp = require('gulp');
var Elixir = require('laravel-elixir');
var changed = require('gulp-changed');
var svgstore = require('gulp-svgstore');
var Task = Elixir.Task;
Elixir.extend('sprites', function (src, output) {
new Task('sprites', function () {
return gulp.src(src)
@shaneparsons
shaneparsons / text-width.js
Last active April 27, 2016 18:17
jQuery - Calculate width of text from DOM element or string.
$.fn.textWidth = function (text, font, transform) {
if (!$.fn.textWidth.fakeEl) $.fn.textWidth.fakeEl = $('<span>').hide().appendTo(document.body);
$.fn.textWidth.fakeEl.text(text || this.val() || this.text())
.css('font', font || this.css('font'))
.css('text-transform', transform || this.css('text-transform'));
return $.fn.textWidth.fakeEl.width();
};
@shaneparsons
shaneparsons / text-height.js
Last active April 27, 2016 18:17
jQuery - Calculate height of text from DOM element or string.
$.fn.textHeight = function (text, font, transform) {
if (!$.fn.textWidth.fakeEl) $.fn.textWidth.fakeEl = $('<span>').hide().appendTo(document.body);
$.fn.textWidth.fakeEl.text(text || this.val() || this.text())
.css('font', font || this.css('font'))
.css('text-transform', transform || this.css('text-transform'));
return $.fn.textWidth.fakeEl.height();
};
@shaneparsons
shaneparsons / SceneAutoLoader.cs
Created July 25, 2016 15:45
SceneAutoLoader.cs - Unity
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
/// <summary>
/// Scene auto loader.
/// </summary>
/// <description>
/// This class adds a File > Scene Autoload menu containing options to select
/// a "master scene" enable it to be auto-loaded when the user presses play
/// in the editor. When enabled, the selected scene will be loaded on play,
@shaneparsons
shaneparsons / RegistersExceptionHandlers.php
Created October 4, 2016 14:17
Lumen - Custom 403 compatibility
<?php
namespace Laravel\Lumen\Concerns;
use Error;
use Exception;
use ErrorException;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Debug\Exception\FatalErrorException;
@shaneparsons
shaneparsons / Helpers.php
Last active August 23, 2021 04:06
Lumen - helpers compatibility
<?php
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Debug\Dumper;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
if (! function_exists('append_config')) {
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* If the incoming request is an OPTIONS request
* we will register a handler for the requested route
*/
class CatchAllOptionsRequestsProvider extends ServiceProvider {