In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and
returning the cached result when the same
inputs occur again.
— wikipedia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function validateEmail(email) { | |
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) { | |
return 'Enter a valid email address!'; | |
} else return null; | |
} | |
export function validatePassword(password) { | |
if ( | |
!/(?=(.*[0-9]))((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.{8,}$/i.test( | |
password, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Mutilator(data, name, context) { | |
this.n = name || `mutilation-${+new Date()}`; | |
this.d = data; | |
this.c = context || window; | |
this.isArr = function(p) { | |
return this.d[p].constructor == Array; | |
}; | |
this.dispatch = function(p, v, t) { | |
this.c.dispatchEvent( | |
new CustomEvent(this.n, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NVM version shortcut | |
# change title name of tab in terminal | |
function title { | |
echo -ne "\033]0;"$*"\007" | |
} | |
cd() { | |
builtin cd "$@" || return | |
#echo $PREV_PWD | |
if [ "$PWD" != "$PREV_PWD" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = document.getElementsByTagName('body'); | |
var scope = angular.element(app[0]).scope(); | |
var rootScope = scope.$root | |
// Make app think you're offline | |
scope.$apply( function() { | |
rootScope.$broadcast('$cordovaNetwork:offline'); | |
}); | |
// Make app think you're online |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function countAngularWatchers(angular) { | |
var i, data, scope, | |
count = 0, | |
all = document.all, | |
len = all.length, | |
test = {}; | |
var mostWatchers = 0; | |
function countScopeWatchers(scope, element) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Right click an element and select "Inspect Element" | |
// Courtesy : http://michalostruszka.pl/blog/2013/09/24/angularjs-in-browsers-console/ & | |
// http://ionicframework.com/blog/angularjs-console/ | |
var scope = angular.element($0).scope(); | |
var rootScope = scope.$root | |
scope.$apply( function() { | |
rootScope.$broadcast('showOffline', {msg : 'goes here', duration : 1230}); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# | |
# This script fetches the current open tabs in all Safari windows. | |
# Useful to run remotely on your mac when you are at work and want | |
# to read a page you have open (remotely) at home but don't remember | |
# the url but can log in to your home system on the cmmand line | |
# | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When I developed an app for ios by phonegap, I had a trouble in changing the <input> input cursor color. | |
but now, there is a solution for it: | |
--------------- | |
<style> | |
input { | |
color: rgb(60, 0, 248); /* change [input cursor color] by this*/ | |
text-shadow: 0px 0px 0px #D60B0B; /* change [input font] by this*/ | |
-webkit-text-fill-color: transparent; |
NewerOlder