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
| sudo apt install -y autoconf automake build-essential python-dev libtool libssl-dev pkg-config | |
| cd /tmp | |
| git clone https://github.com/facebook/watchman.git | |
| cd watchman/ | |
| git checkout v4.9.0 | |
| ./autogen.sh | |
| ./configure | |
| make | |
| sudo make install |
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 {exec} = require('child_process') | |
| export default function runDeploy () { | |
| return new Promise((resolve, reject) => { | |
| exec('git pull origin master', (err, stdout1, stderr) => { | |
| if (err) return reject(stderr) | |
| exec('npm run update', (err, stdout2, stderr) => { | |
| if (err) return reject(stderr) | |
| return resolve([stdout1, stdout2]) | |
| }) |
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
| // getComponent is a function that returns a promise for a component | |
| // It will not be called until the first mount | |
| function asyncComponent(getComponent) { | |
| return class AsyncComponent extends React.Component { | |
| static Component = null; | |
| state = { Component: AsyncComponent.Component }; | |
| componentWillMount() { | |
| if (!this.state.Component) { | |
| getComponent().then(Component => { |
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
| /* | |
| limitLoop.js - limit the frame-rate when using requestAnimation frame | |
| Released under an MIT license. | |
| When to use it? | |
| ---------------- | |
| A consistent frame-rate can be better than a janky experience only | |
| occasionally hitting 60fps. Use this trick to target a specific frame- | |
| rate (e.g 30fps, 48fps) until browsers better tackle this problem |
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
| bctx.save() | |
| bctx.translate(500, 400); | |
| bctx.rotate((frame * -5) * Math.PI / 180) | |
| const animationSpeed = parseInt(frame / 2.7, 10) | |
| bctx.drawImage( | |
| images[0], | |
| (images[0].width / 5) * (animationSpeed % 5), 0, // sprite width * animationSpeed % spriteLength | |
| images[0].width / 5, images[0].height / 2, | |
| (images[0].width / 5) / - 2, (images[0].height / 2) / -2, | |
| images[0].width / 5, images[0].height / 2 |
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 setElementData(element, name, value, oldValue) { | |
| if (name === "key") { | |
| } else if (name === "style") { | |
| for (var i in merge(oldValue, (value = value || {}))) { | |
| element.style[i] = value[i] || "" | |
| } | |
| } else { | |
| var selectionStart = element.selectionStart | |
| var selectionEnd = element.selectionEnd |
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 http = require('http'), | |
| fileSystem = require('fs'), | |
| path = require('path') | |
| util = require('util'); | |
| http.createServer(function(request, response) { | |
| var filePath = 'path_to_file.mp3'; | |
| var stat = fileSystem.statSync(filePath); | |
| response.writeHead(200, { |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <style id="jsbin-css"> | |
| canvas { | |
| border: 1px solid black | |
| } |
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
| // send to current request socket client | |
| socket.emit('message', "this is a test"); | |
| // sending to all clients, include sender | |
| io.sockets.emit('message', "this is a test"); | |
| // sending to all clients except sender | |
| socket.broadcast.emit('message', "this is a test"); | |
| // sending to all clients in 'game' room(channel) except sender |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="description" content="Coding Challenge #30: Phyllotaxis"> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <style id="jsbin-css"> | |
| canvas { | |
| border: black 1px solid; |