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 WhiteNoise(audioContext) { | |
| this.node = audioContext.createBufferSource(); | |
| var bufferSize = 2 * audioContext.sampleRate, | |
| buffer = audioContext.createBuffer(1, bufferSize, audioContext.sampleRate), | |
| data = buffer.getChannelData(0); | |
| for (var i = 0, len = data.length; i < len; i++) { | |
| data[i] = Math.random() * 2 - 1; | |
| } |
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(global) { | |
| function App () { | |
| this.controllers = {}; | |
| this.modules = {}; | |
| this.router = new Router(this); | |
| $(window).on('load', this.init.bind(this)); | |
| }; |
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
| str = "ありがとう" | |
| result = re.search(r"[^\x00-\x7F]", str) | |
| if result: | |
| print(result.start()) # 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 output = {someKey: "someValue"}; | |
| var blob = new Blob([JSON.stringify(output)], {type: 'application/json'}); | |
| var anchor = document.createElement('a'); | |
| anchor.setAttribute('href', window.URL.createObjectURL(blob)); | |
| anchor.setAttribute('download', 'data' + Date.now() + '.json'); | |
| anchor.click(); |
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 |
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
| /* 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
| // 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
| 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; | |
| } |