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 clearLocalStorage() { | |
| var len = window.localStorage.length; | |
| while (len >= 0) { | |
| window.localStorage.removeItem(window.localStorage.key(len--)); | |
| } | |
| } |
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
| # StepAction helps to get rid of nesting setTimeout | |
| # | |
| # Function.prototype.bind feature is used. | |
| # Only support IE9+ for now | |
| class StepAction | |
| constructor: (@steps, @initDelay) -> | |
| @_timer = null | |
| @_onStep = 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
| <!--[if lte IE 9]> | |
| <script src="https://stringencoders.googlecode.com/svn/trunk/javascript/base64.js"></script> | |
| <script> | |
| if (!window.btoa) window.btoa = base64.encode; | |
| if (!window.atob) window.atob = base64.decode; | |
| </script> | |
| <![endif]--> |
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
| -- Switch to English (Run in CLI) | |
| -- defaults write NSGlobalDomain AppleLanguages "(en, ja, \"zh-Hans\", \"zh-Hant\", fr, de, es, it, pt, \"pt-PT\", nl, sv, nb, da, fi, ru, pl, ko, ar, cs, hu, tr, th, ca, hr, el, he, ro, sk, uk)" | |
| -- Switch to Japanese (Run in CLI) | |
| -- defaults write NSGlobalDomain AppleLanguages "(ja, en, \"zh-Hans\", \"zh-Hant\", fr, de, es, it, pt, \"pt-PT\", nl, sv, nb, da, fi, ru, pl, ko, ar, cs, hu, tr, th, ca, hr, el, he, ro, sk, uk)" |
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 getDataURLfromSVG (svg) { | |
| var code = (new XMLSerializer).serializeToString(svg); | |
| var b64 = window.btoa(unescape(encodeURIComponent(code))); // Workaround on UTF-8 char | |
| return "data:image/svg+xml;base64," + b64; | |
| } |
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
| // Normalize requestAnimationFrame | |
| var fps = 30; | |
| var requestAnimationFrame = window.requestAnimationFrame || | |
| window.mozRequestAnimationFrame || | |
| window.webkitRequestAnimationFrame || | |
| window.msRequestAnimationFrame || | |
| function (callback) { | |
| return setTimeout(callback, 1000 / fps); | |
| }; | |
| var cancelAnimationFrame = window.cancelAnimationFrame || |
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
| /* Mixin */ | |
| @mixin media($point) { | |
| @if $point == papa-bear { | |
| @media (max-width: 1600px) { @content; } | |
| } | |
| @else if $point == mama-bear { | |
| @media (max-width: 1250px) { @content; } | |
| } | |
| @else if $point == baby-bear { |
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 Promise | |
| then: (@onResolved, @onRejected) -> | |
| return | |
| resolve: (val) -> | |
| @onResolved val | |
| return | |
| reject: (err) -> | |
| @onRejected err |
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
| do (win = window, doc = window.document, exports = window) -> | |
| floor = Math.floor | |
| class Xorshift | |
| vec: [ 1812433254, 3713160357, 3109174145, 64984499 ] | |
| constructor: (seed = +new Date)-> | |
| x = 123456789 | |
| y = 362436069 | |
| z = 521288629 |