Skip to content

Instantly share code, notes, and snippets.

@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.
@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 / 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 / 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 / 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 / traverse-and-add.js
Created April 28, 2016 16:57
A function will traverse a tree passed as an argument. The function will add the number values contained on each node when available.
// Will traverse a tree passed as an argument. The function will add the number values contained on each node when available.
function traverseAndAdd(tree) {
// Init var to contain sum of values
var sum = 0;
// Function will traverse nodes
var recursiveCrawl = function (branch) {
for (i in branch) {
@artisanalcode
artisanalcode / zip-validation.js
Last active September 11, 2020 13:09
A method for jQuery Validation Plugin (http://jqueryvalidation.org/). It checks if a ZIP code entered contains one of a number of prefixes specified in an array. It can also check if a ZIP code is within a certain range or if it contains a specific format (e.g. USA, Canada, etc.). Client work.
/*
Version: 1.0
File: zip-validation.js
Author: Juan Garcia
Email: dev [at] soleilnoirmedia [dot] com
Description: zipValidation.js contains a method for jQuery Validation Plugin (http://jqueryvalidation.org/).
It checks if a ZIP code entered contains one of a number of prefixes specified in an array (A requirement from a client).
It can also check if a ZIP code is within a certain range or if it contains a specific format (e.g. USA, Canada, etc.).
Ideal to validate addresses for local deliveries.
*/
@artisanalcode
artisanalcode / java_properties_delimiter_whitespace_finder.regex
Last active May 12, 2016 15:39
RegEx to find whitespace around separator in the a Java properties file
/**
* Use a lookbehind to make sure we dont accidentaly find ` = ` in the value.
* Prefer the likeliness of missing positive, than getting false positives.
*/
(?<=[a-zA-Z].)+((\s)=(\s)){1}(?=[a-zA-Z])+
@artisanalcode
artisanalcode / csscomb.json
Created June 16, 2016 21:52
My CSSComb config
{
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "lower",
"block-indent": " ",
"color-shorthand": true,
"element-case": "lower",
"eof-newline": false,
"leading-zero": true,
"quotes": "double",
@artisanalcode
artisanalcode / focus-blur-debugger.js
Created August 17, 2016 16:21
Little script to help debug focus/blur events on Chrome.
/**
* Little script to help debug focus/blur events on Chrome.
* @note Since ChromeDev tools takes focus it creates an Observer Effect @see (https://en.wikipedia.org/wiki/Observer_effect_(physics).
* @author http://stackoverflow.com/users/2122682/aminimalanimal (Found in StackOverflow)
* @see http://stackoverflow.com/questions/8978039/debugging-onfocus-event-using-chrome-developer-tools-cant-return-focus-after-b
*/
$('*').on(
'focus blur',
function(event) {
console.log(event.type + " to:");