This example demonstrates rendering a D3 force-directed graph using Canvas rather than SVG. The performance is slightly better than SVG, but unlike the SVG version, the nodes in this one are not draggable.
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
| // Call arrayToObj() passing your array and function. | |
| function arrayToObj(array, keyValueMap) { | |
| var obj = {}; | |
| var len = array.length; | |
| // Your function will be called for each item in the array. | |
| for (var i = 0; i < len; i++) { | |
| var curVal = array[i]; | |
| // Just like with [].forEach(), your function will be passed the | |
| // curent item of the array, its index, and the array it's in. | |
| var keyValuePair = keyValueMap(curVal, i, 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
| // === Arrays | |
| var [a, b] = [1, 2]; | |
| console.log(a, b); | |
| //=> 1 2 | |
| // Use from functions, only select from pattern | |
| var foo = () => [1, 2, 3]; |
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
| import cv2 | |
| import time | |
| import math | |
| import numpy as np | |
| capture = cv2.VideoCapture(0) | |
| print capture.get(cv2.CAP_PROP_FPS) | |
| t = 100 | |
| w = 640.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
| import React, {DeviceEventEmitter} from 'react-native'; | |
| import {Observable} from 'rx-lite' | |
| /** | |
| * Creates an Observable to listen to any event of DeviceEventEmitter | |
| * @param type {string} Event type | |
| */ | |
| export default createObservableFromDeviceEventEmitter$ = type => { | |
| let subscription; | |
| return Observable.fromEventPattern( |
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
| upstream myapp_puma { | |
| server unix:/tmp/myapp_puma.sock fail_timeout=0; | |
| } | |
| # for redirecting to https version of the site | |
| server { | |
| listen 80; | |
| rewrite ^(.*) https://$host$1 permanent; | |
| } | |