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 digitNegativeNumbers(): any { | |
| return { | |
| restrict: 'A', | |
| require: 'ngModel', | |
| link(scope: IScope, element: HTMLElement, attrs: any, ngModelCtrl: any) { | |
| function inputValue(val: string) { | |
| if (val) { | |
| const transformedValue = val.replace(/([^-\d.]+)?((-{0,1}\d*\.?\d*)(.*)?$)/, '$3'); | |
| if (transformedValue !== val) { | |
| ngModelCtrl.$setViewValue(transformedValue); |
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 docViewTop = $(window).scrollTop(); | |
| var docViewBottom = docViewTop + $(window).height(); | |
| var elemTop = $(elem).offset().top; | |
| var elemBottom = elemTop + $(elem).height(); | |
| return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); |
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 isYoutube = videoUrl.match(/(?:youtu|youtube)(?:\.com|\.be)\/([\w\W]+)/i); | |
| var isVimeo = videoUrl.match(/^.*(?:vimeo.com)\/(?:channels\/|channels\/\w+\/|groups\/[^\/]*\/videos\/|album\/\d+\/video\/|video\/|)(\d+)(?:$|\/|\?)/); |
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 Person = function(name) { | |
| this.name = name; | |
| } | |
| Person.prototype.greet = function(){ | |
| console.log("Hi, " + this.name); | |
| } | |
| var Developer = function(name, skills) { | |
| Person.apply(this.arguments); |
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 hiddenClone(element) { | |
| var clone = element.cloneNode(true); | |
| var style = clone.style; | |
| style.position = 'relative'; | |
| style.top = window.innerHeight + 'px'; | |
| style.left = 0; | |
| document.body.appendChild(clone); | |
| return clone; | |
| } |
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(){ | |
| 'use strict'; | |
| var tau = Math.PI * 2; | |
| var width, height; | |
| var scene, camera, renderer, pointCloud; | |
| function onDocumentReady(){ | |
| initialize(); | |
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 byteString; | |
| if (dataURI.split(',')[0].indexOf('base64') >= 0) | |
| byteString = atob(dataURI.split(',')[1]); | |
| else | |
| byteString = unescape(dataURI.split(',')[1]); | |
| // separate out the mime component | |
| var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; | |
| // write the bytes of the string to a typed array |
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
| if (!file) { | |
| return $q.reject(false); | |
| } | |
| return $q(function (resolve, reject) { | |
| var reader = new FileReader(); | |
| reader.onloadend = function (response) { | |
| var src = response.target.result; | |
| var imgPromise = srcToDataURI(src); |
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
| const stream = { | |
| each: (callback) => { | |
| setTimeout(() => callback(1), 1000); | |
| setTimeout(() => callback(2), 2000); | |
| setTimeout(() => callback(3), 3000); | |
| } | |
| } | |
| createStream.each(console.log) |
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
| const dog = () => { | |
| const sound = 'woof' | |
| return { | |
| talk: () => console.log(sound) | |
| } | |
| } | |
| const obj = dog(); | |
| obj.talk(); |
NewerOlder