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
| 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
| (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
| 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 BrownNoise(audioContext) { | |
| this.node = audioContext.createBufferSource(); | |
| var bufferSize = 2 * audioContext.sampleRate, | |
| buffer = audioContext.createBuffer(1, bufferSize, audioContext.sampleRate), | |
| data = buffer.getChannelData(0); | |
| lastOutput = 0; | |
| for (var i = 0, len = data.length; i < len; i++) { | |
| var white = 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 randomRGB() { | |
| const c = 0xffffff * Math.random(); | |
| return [c >> 16, c >> 8 & 255, c & 255]; | |
| } |
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/mrdoob/three.js/commit/8406cd7c6ecbdaca8e9d985158e5403492da48b5 | |
| import THREE from 'three'; | |
| export default function sortPoints(points, camera) { | |
| var vector = new THREE.Vector3(); | |
| // Model View Projection matrix | |
| var matrix = new THREE.Matrix4(); | |
| matrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); |
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 rules = []; | |
| function appendRule(path, callback) { | |
| rules.push([path, callback]); | |
| } | |
| function matchPath(path, currentPath) { | |
| let params = {}; | |
| // If there's a '/' in the end of path, trim it. |
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 e($element) { | |
| @at-root { | |
| #{&}__#{$element} { | |
| @content; | |
| } | |
| } | |
| } | |
| @mixin m($modifier) { | |
| @at-root { |
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 co = require('co'); | |
| co(function* () { | |
| var result = 0; | |
| result = yield Promise.resolve(1); | |
| console.log(result); // 1 | |
| result = yield Promise.resolve(result + 1); | |
| console.log(result); // 2 | |
| return 3; | |
| }).then(function(res) { |