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 SA = function( a ) { | |
a.has = function( v ) { | |
var i = a.length; | |
for ( i; i--; ) | |
if ( a[ i ] === v ) | |
return true; | |
return false; | |
}; |
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 SD = { | |
create: function( tag, attrs ) { | |
tag = document.createElement( tag ); | |
for ( var attr in attrs ) tag[ attr ] = attrs[ attr ]; | |
return tag; | |
}, | |
get: function( selector, context, undefined ) { | |
var matches = { |
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() { | |
console.clear(); | |
var loadTimes = chrome.loadTimes(); | |
console.log( "requestTime................. " + ( loadTimes.startLoadTime - loadTimes.requestTime ).toFixed( 2 ) + 's' ); | |
console.log( "commitLoadTime.............. " + ( loadTimes.commitLoadTime - loadTimes.startLoadTime ).toFixed( 2 ) + 's' ); | |
console.log( "finishDocumentLoadTime...... " + ( loadTimes.finishDocumentLoadTime - loadTimes.startLoadTime ).toFixed( 2 ) + 's' ); | |
console.log( "finishLoadTime.............. " + ( loadTimes.finishLoadTime - loadTimes.startLoadTime ).toFixed( 2 ) + 's' ); | |
})() |
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
"abcdefghijklmnopqrstuvwxyz".match( /.{1,4}/g ); | |
// [ "abcd", "efgh", "ijkl", "mnop", "qrst", "uvwx", "yz" ] |
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 shuffle( a ) { | |
var m = a.length, t, i; | |
while ( m ) { | |
i = Math.floor( Math.random() * m-- ); | |
t = a[ m ]; | |
a[ m ] = a[ i ]; | |
a[ i ] = t; | |
} |
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 rgbToHex = ( r, g, b ) => "#" + ( ( 1 << 24 ) + ( r << 16 ) + ( g << 8 ) + b ).toString( 16 ).slice( 1 ); | |
var hexToRgb = ( hex ) => [ parseInt( hex.substring( 1, 3 ), 16 ), parseInt( hex.substring( 3, 5 ), 16 ), parseInt( hex.substring( 5, 7 ), 16 ) ]; | |
rgbToHex( 175, 25, 70 ); // #af1946 | |
hexToRgb( "#af1946" ); // [ 175, 25, 70 ] |
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
'#' + Math.floor( Math.random() * 16777215 ).toString( 16 ); |
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
// if no duplicate in the first list | |
a1.concat( a2.filter( i => a1.indexOf( i ) === -1 ) ); | |
// if duplicate in the first list | |
a1.concat( a2 ).reduce( function( p, c, i, a ) { | |
if ( p.indexOf( c ) === -1 ) p.push( c ); | |
return p; | |
}, [] ); |
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 factorial = ( i, a ) => i < 2 ? a || 1 : factorial( i - 1, ( a || 1 ) * i ); | |
console.log( factorial( 5 ) ); // 120 |
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 ua = navigator.userAgent, | |
isApple = /iPad/i.test(ua) || /iPhone/i.test(ua), | |
isAndroid = ua.toLowerCase().indexOf("android") > -1; | |
if(isAndroid || isApple) { | |
// do something ; | |
} |
OlderNewer