This file contains hidden or 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 ; | |
| } |
This file contains hidden or 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
| #foo{ | |
| height: 150px; | |
| width: 300px; | |
| margin: auto; | |
| position: absolute; | |
| top: 0; left: 0; bottom: 0; right: 0; | |
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
| class TimeTracker { | |
| constructor() { | |
| this.timers = {}; | |
| } | |
| logLoadTimes() { | |
| var loadTimes = chrome.loadTimes(); | |
| console.log( `commitLoadTime .............. ${( loadTimes.commitLoadTime - loadTimes.startLoadTime ).toFixed( 2 )}s` ); | |
| console.log( `finishDocumentLoadTime ...... ${( loadTimes.finishDocumentLoadTime - loadTimes.startLoadTime ).toFixed( 2 )}s` ); |
This file contains hidden or 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 nodes = [ | |
| { | |
| links: [ 1 ], // node 0 is linked to node 1 | |
| visited: false | |
| }, { | |
| links: [ 0, 2 ], // node 1 is linked to node 0 and 2 | |
| path: [], | |
| visited: false | |
| }, | |
| ... |
This file contains hidden or 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 average = arr => arr.reduce( ( p, c ) => p + c, 0 ) / arr.length; | |
| average( [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] ); | |
| // 5 |
This file contains hidden or 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 matrix = [], | |
| H = 4, // 4 rows | |
| W = 6; // of 6 cells | |
| for ( var y = 0; y < H; y++ ) { | |
| matrix[ y ] = []; | |
| for ( var x = 0; x < W; x++ ) { | |
| matrix[ y ][ x ] = "foo"; | |
| } | |
| } |
This file contains hidden or 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
| let partition = ( a, n ) => a.length ? [ a.splice( 0, n ), ...partition( a, n ) ] : []; | |
| partition( [ 1, 2, 3, 4, 5, 6, 7, 8 ], 2 ); | |
| // [ | |
| // [ 1, 2 ], | |
| // [ 3, 4 ], | |
| // [ 5, 6 ], | |
| // [ 7, 8 ] | |
| // ] |
OlderNewer