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 / IP2Octal.js
Created January 12, 2010 16:24
converts IP address to octal format
/* IP2Octal.js - converts IP address to Octal format
* @author - Livingston Samuel
*
* @requires - padString.js - http://gist.github.com/275259#file_pad_string.js
*/
var IP2Octal = function (ip) {
var ipSyntax = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, ipArr, i = 4, result = [];
if (ipSyntax.test(ip)) {
@livingston
livingston / String.pad.js
Created January 12, 2010 15:00
pads string with specified character, with defined length
/* String.pad.js - String prototype method to pad string with specified character, with defined length
* @author - Livingston Samuel
*/
String.prototype.pad = function (char, len) {
var str = this, l = str.length;
if (arguments.length !== 2 || String(char).length !== 1 || str.length >= len) {
return str;
}
@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(".");
@livingston
livingston / formatCurrency.js
Created January 5, 2010 10:25
number to currency formatting
/* formatCurrency.js - number to currency formatting
* @author - Livingston Samuel
*/
var formatCurrency = function (num, separator, decimal) {
var format_separator = separator || ",",
decimal_separator = decimal || ".",
parts = parseFloat(num, 10).toString().split(decimal_separator);
parts[0] = parts[0].split("").reverse().join("").match(/(\d{1,3})/g).join(format_separator).split("").reverse().join("");
@livingston
livingston / hasFirebug.js
Created January 2, 2010 19:30
hasFirebug - detects the activation status of firebug
/* hasFirebug.js, alternate version - detects the activation status of firebug
* @author Livingston Samuel
*/
var hasFirebug = (function () {
return !!(window.console && window.console.firebug)
}());
/*
hasFirebug => false, if Firebug is not installed or not activated for the current page