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
| /* | |
| https://codepen.io/codercatdev/pen/eYVjxjK | |
| */ | |
| const rating = stars => `★★★★★☆☆☆☆☆`.slice(5 - stars, 10 - stars); |
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
| javascript:(function(d){d.designMode='on'})(document) |
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 splitter(arr,size) { | |
| var i,j,temparray=[], splitarray=[]; | |
| for (i=0,j=arr.length; i<j; i+=size) { | |
| temparray = arr.slice(i,i+size); | |
| splitarray.push(temparray); | |
| } | |
| return splitarray; | |
| } |
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
| /* https://github.com/github/fetch/issues/175 */ | |
| function timeout(ms, promise) { | |
| return new Promise(function(resolve, reject) { | |
| setTimeout(function() { | |
| reject(new Error("timeout")) | |
| }, ms) | |
| promise.then(resolve, reject) | |
| }) | |
| } |
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
| DECLARE @current_date DATE = GETDATE() | |
| SELECT EOMONTH (@current_date, 0) AS LastDayOfCurrentMonth | |
| SELECT EOMONTH (@current_date, 1) AS LastDayOfNextMonth | |
| SELECT EOMONTH (@current_date, -1) AS LastDayOfPrevMonth |
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(reComments, reParams, reNames) { | |
| getParamNames = function(fn) { | |
| return ((fn + '').replace(reComments, '').match(reParams) || [0, ''])[1].match(reNames) || []; | |
| }; | |
| })( | |
| /\/\*[\s\S]*?\*\/|\/\/.*?[\r\n]/g, | |
| /\(([\s\S]*?)\)/, | |
| /[$\w]+/g | |
| ); |
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 tableToArray(tbl, opt_cellValueGetter) { | |
| opt_cellValueGetter = opt_cellValueGetter || function(td) { return td.textContent || td.innerText; }; | |
| var twoD = []; | |
| for (var rowCount = tbl.rows.length, rowIndex = 0; rowIndex < rowCount; rowIndex++) { | |
| twoD.push([]); | |
| } | |
| for (var rowIndex = 0, tr; rowIndex < rowCount; rowIndex++) { | |
| var tr = tbl.rows[rowIndex]; | |
| for (var colIndex = 0, colCount = tr.cells.length, offset = 0; colIndex < colCount; colIndex++) { | |
| var td = tr.cells[colIndex], text = opt_cellValueGetter(td, colIndex, rowIndex, tbl); |
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 diffDates(startDate, endDate) { | |
| var t, multiplier = 1; | |
| if (startDate > endDate) { | |
| t = startDate; | |
| startDate = endDate; | |
| endDate = t; | |
| multiplier = -1; | |
| } | |
| var millisTotal = endDate - startDate, |
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 maximizeFontSize(elem, maxWidth, maxHeight, opt_dontChangeFontSize) { | |
| var canBeBigger, | |
| display = elem.style.display, | |
| fontSize = elem.style.fontSize, | |
| font = elem.style.font, | |
| computedFont = window.getComputedStyle(elem, null).getPropertyValue('font'), | |
| doc = elem.ownerDocument, | |
| parentNode = elem.parentNode, | |
| tempParent = doc.createElement('div'), | |
| nextSibling = elem.nextSibling, |
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 getVideoImage(path, secs, callback) { | |
| var me = this, video = document.createElement('video'); | |
| video.onloadedmetadata = function() { | |
| if ('function' === typeof secs) { | |
| secs = secs(this.duration); | |
| } | |
| this.currentTime = Math.min(Math.max(0, (secs < 0 ? this.duration : 0) + secs), this.duration); | |
| }; | |
| video.onseeked = function(e) { | |
| var canvas = document.createElement('canvas'); |
NewerOlder