Skip to content

Instantly share code, notes, and snippets.

View livingston's full-sized avatar

Livingston Samuel livingston

View GitHub Profile
@livingston
livingston / OptimizeForWeb.jsx
Created March 16, 2010 13:25
Photoshop Script for Optimizing Images for the Web - Saves images as optimized jpeg
// Photoshop Script for Optimizing Images for the Web - Saves images as optimized jpeg
// Written by: Livingston Samuel
// Version 1.0.0
// Required Adobe Photoshop CS 2 and above
//Enable double clicking on Mac Finder & Windows Explorer
#target Photoshop
//Bring app to front
app.bringToFront()
@livingston
livingston / readme.md
Last active September 12, 2022 22:10
Vanilla JavaScript Templates

Usage

var welcome_user = new Template('#{welcome} #{name}!!');

welcome_user.parse({ welcome: "Hello", name: "John" });
//returns "Hello John!!"

welcome_user.parse({ welcome: "Hola", name: "Peter" });
@livingston
livingston / yarn-hoisting-algorithm.md
Created January 16, 2022 19:37
Yarn Hoisting Algorithm

High-level node_modules hoisting algorithm recipe

  1. Take input dependency graph and start traversing it, as you visit new node in the graph - clone it if there can be multiple paths to access the node from the graph root to the node, e.g. essentially represent the graph with a tree as you go, to make hoisting possible.

  2. You want to hoist every node possible to the top root node first, then to each of its children etc, so you need to keep track what is your current root node into which you are hoisting

  3. Traverse the dependency graph from the current root node and for each package name that can be potentially hoisted to the current root node build a list of idents in descending hoisting preference. You will check in next steps whether most preferred ident for the given package name can be hoisted first, and if not, then you check the less preferred ident, etc, until either some ident will be hoisted or you run out of idents to check (no need to convert the graph to the tree when you build this prefe

Yarn Plugin Hooks

Hook Description
registerPackageExtensions Called when the package extensions are setup
setupScriptEnvironment Called before a script is executed
wrapScriptExecution Called as a script is getting executed
wrapNetworkRequest Called when a network request is being made
globalHashGeneration Called before the build, to compute a global hash key that we will use to detect whether packages must be rebuilt (typically when the Node version changes)
reduceDependency Called during the resolution, once for each resolved package and each of their dependencies
@livingston
livingston / Readme.md
Last active August 27, 2021 16:31 — forked from CodeMyUI/animated-svg-avatar.markdown
Animated SVG Avatar

Animated SVG Avatar

Created a login form with an SVG avatar that responds to the input in the email field. Used the GSAP TweenMax library + GSAP's MorphSVG plugin for the animating.

Email validation is very simple and crude just for the purposes of getting this prototype working.

A Pen by Darin on CodePen.

License.

@livingston
livingston / SPOJ-01.js
Created April 24, 2010 20:58
SPOJ 1. Life, the Universe, and Everything
/* 1. Life, the Universe, and Everything
Problem code: TEST
Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything.
More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42.
All numbers at input are integers of one or two digits.
Example:
Input: 1 2 88 42 99
Output: 1 2 88
*/
@livingston
livingston / domHelper.js
Created March 24, 2010 20:10
DOM Helper Methods
/* Collection of DOM Helper Methods
* Livingston Samuel
*/
var DOM = {};
/* Get Next Element node Sibling - Equivalent of nextElementSibling */
DOM.next = function (elem) {
var sibling = elem.nextSibling;
@livingston
livingston / EventMonitor.js
Created September 30, 2011 12:20
Element event monitor, similar to Web Inspector's `monitorEvents`
(function (global) {
if ( !global.Event && !('keys' in Object) && !('bind' in Function) ) { return }
var eventProto = Event.prototype,
EVENTS = {
'mouse': [ 'click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout', 'drag', 'dragend', 'dragenter', 'dragleave', 'dragover', 'drop'],
'key': [ 'keydown', 'keypress', 'keyup', 'input'],
'res': [ 'load', 'unload', 'beforeunload', 'abort', 'error', 'resize', 'scroll', 'readystatechange' ],
'form': [ 'select', 'change', 'submit', 'reset', 'focus', 'blur' ],
'ui': [ 'DOMFocusIn', 'DOMFocusOut', 'DOMActivate', 'DOMCharacterDataModified', 'DOMNodeInserted', 'DOMNodeRemoved', 'DOMSubtreeModified' ],
@livingston
livingston / IP2Decimal.js
Created January 12, 2010 14:22
converts IP address to decimal format
/* IP2Decimal.js - converts IP address to decimal format
* @author - Livingston Samuel
*/
var IP2Decimal = function (ip) {
var ipSyntax = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, ipArr, i = 4, decVal = 0;
if (ipSyntax.test(ip)) {
ipArr = ip.split(".");