Skip to content

Instantly share code, notes, and snippets.

@artisanalcode
artisanalcode / win-max.js
Created April 28, 2016 16:35
A "class"(object) with a method that takes an array and an integer as arguments and returns a new array composed of the bigger number of each of a series of windows on the array defined by the 'n' parameter.E.g. arrayExtender.winMax([1,4,3,1,5], 2); returns [4, 4, 3, 5], an array composed of the bigger number of each of the 2 element size …
// Creates a "class"(object) with 'helper' array methods
var arrayExtender = {
// Creates a method that takes an array and an integer as arguments and returns
// a new array composed of the bigger number of each of a series of windows on the
// array defined by the 'n' parameter
// E.g. arrayExtender.winMax([1,4,3,1,5], 2); returns [4, 4, 3, 5], an array composed of
// the bigger number of each of the 2 element size ('n') 'windows': [1,4],[4,3],[3,1],[1,5]
winMax : function (array, n) {
@artisanalcode
artisanalcode / square-canvas.jsx
Last active December 4, 2023 17:49
Photoshop script. Crops an image to make it square by resizing the canvas.
/*-----------------------------------------------------------------------------
File: square-canvas.jsx
Version: 1.0
Author: Juan Garcia
Language: JavaScript/ExtendScript
-----------------------------------------------------------------------------*/
var inputFolder = Folder.selectDialog("Select a folder");
var fileList = inputFolder.getFiles("*.PNG"); // Define type of file to manipulate
@artisanalcode
artisanalcode / first-unique.js
Created April 28, 2016 16:30
Return the value of the first unique value on the array. Return -1 if there are no unique values
var solution = function (arr) {
"use strict";
// Cache array length
var len = arr.length,
// Default value for no unique value
result = -1;
// Iterate over array
for(var i=0; i < len; i++) {
@artisanalcode
artisanalcode / conditional-execution.js
Created April 28, 2016 16:28
Executes code conditionally based on URL.
/**
* Checks current URL, executes specified content only on non-"blacklisted" URLs.
*/
(function () {
if (!/^\/url-segment-here>|^\/another-url-segment-here|^\/as-many-url-segments-as-needed-here/.test(window.location.pathname)) {
}
})();
@artisanalcode
artisanalcode / stand-up-template.md
Last active April 28, 2016 16:54
Stand-up meeting report template [SCRUM].

MO DAY YEAR

What did I accomplish?

:octocat: PR/CR:

  • Item.

🔬 V&V/Q&A:

  • Item.