Skip to content

Instantly share code, notes, and snippets.

View franciscolourenco's full-sized avatar

Francisco Lourenço franciscolourenco

View GitHub Profile
@wildhart
wildhart / dateProtypes.js
Last active March 21, 2023 02:11
Date prototype functions
Date.prototype.addMins = function(mins) {
var dat = new Date(this.valueOf()); // make a new date coz we can't change the original
dat.setMinutes(dat.getMinutes() + mins*1); // force mins to be integer instead of string
return dat;
};
Date.prototype.addDays = function(days) {
var dat = new Date(this.valueOf()); // make a new date coz we can't change the original
dat.setDate(dat.getDate() + days*1); // force days to be integer instead of string
return dat;
@leodutra
leodutra / parseNumber.js
Last active June 8, 2019 10:37
A parseNumber accepting: currency / decimal / float / whatever number ( for JavaScript )
function parseNumber(str)
{
str = (str + '').replace(/[^\d,.-]/g, '') // just digits, separators and sign
var sign = str.charAt(0) === '-' ? '-' : '+' // store sign
var minor = str.match(/[.,](\d+)$/) // filter decimals
str = str.replace(/[.,]\d*$/, '').replace(/\D/g, '') // remove decimals and any integer separator
return Number(sign + str + (minor ? '.' + minor[1] : '')) // build number
}
@iansoper
iansoper / CodaLight.scpt
Created December 15, 2010 15:35
Open your web development project in TextMate + Transmit + Terminal (kinda like Coda)
-- Coda Light
--
-- By Henrik Nyh <http://henrik.nyh.se>, 2007-04-26
-- His original script: http://henrik.nyh.se/2007/04/coda-light-applescript
--
-- Changes for Transmit 4 and AppleScript 2 by Ian Soper <http://iansoper.com>, 2010-12-15
--
-- An AppleScript to start working on a web development project by
-- * opening the project in TextMate,
-- * opening related URLs in the default browser,