Skip to content

Instantly share code, notes, and snippets.

@Cerealkillerway
Cerealkillerway / utilities.js
Last active December 3, 2015 11:59
Useful js functions
// possible useful functions found on the web
//https://github.com/padolsey/string.prototype/blob/master/string.js
// left trim
String.prototype.ltrim = function () {
return this.replace(/^\s+/, '');
};
// right trim
@Cerealkillerway
Cerealkillerway / materializeOverrides.js
Last active August 29, 2015 14:23
Override for materialize's tooltip function to use with single page apps
(function ($) {
$.fn.ckTooltip = function (options) {
var timeout = null,
counter = null,
started = false,
counterInterval = null,
margin = 5;
// Defaults
var defaults = {
@Cerealkillerway
Cerealkillerway / GoogleMaps-jsAPI-V3.js
Last active August 29, 2015 14:20
Google maps javascript APIs V3 snippets
// GOOGLE MAPS JS API V3
//creates a google map in #mapCanvas DOM element
var coordinates = {
lat: 15.1564541,
lng: 9.456456
}
function createMap(coordinates) {
//google map
var mapOptions = {
// REGEXP TRICKS
//test string against array of strings
var string = "string";
var tests = ["test1", "test2", "test3"];
(new RegExp('\\b' + tests.join('\\b|\\b') + '\\b')).test(string) // -> false
tests.push("string");
(new RegExp('\\b' + tests.join('\\b|\\b') + '\\b')).test(string) // -> true
//test for valid email address