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
| blender -b bedroom.blend -E CYCLES -o /home/ubuntu/work/renders/bedroom_##### -f 1 -- --cycles-device CUDA |
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 CHUNK_SIZE = 10000000; // 10MB | |
| async function main() { | |
| for await(const chunk of generateChunks('./file', CHUNK_SIZE)) { | |
| // do someting with data | |
| } | |
| } | |
| main(); |
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
| async function* generateChunks(filePath, size) { | |
| const sharedBuffer = Buffer.alloc(size); | |
| const stats = fs.statSync(filePath); // file details | |
| const fd = fs.openSync(filePath); // file descriptor | |
| let bytesRead = 0; // how many bytes were read | |
| let end = size; | |
| for(let i = 0; i < Math.ceil(stats.size / size); i++) { | |
| await readBytes(fd, sharedBuffer); | |
| bytesRead = (i + 1) * size; |
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 readBytes(fd, sharedBuffer) { | |
| return new Promise((resolve, reject) => { | |
| fs.read( | |
| fd, | |
| sharedBuffer, | |
| 0, | |
| sharedBuffer.length, | |
| null, | |
| (err) => { | |
| if(err) { return reject(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
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: grafana-deployment | |
| spec: | |
| selector: | |
| matchLabels: | |
| run: grafana | |
| replicas: 1 | |
| template: |
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 CHUNK_SIZE = 10000000; // 10MB | |
| async function start() { | |
| const stream = fs.createReadStream('./file', { highWaterMark: CHUNK_SIZE }); | |
| for await(const data of stream) { | |
| // do something with data | |
| } | |
| } | |
| start(); |
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 CHUNK_SIZE = 10000000; // 10MB | |
| const data = fs.readFileSync('./file'); | |
| for(let bytesRead = 0; bytesRead < data.length; bytesRead = bytesRead + CHUNK_SIZE) { | |
| // do something with data | |
| } |
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, { useEffect, useState } from "react"; | |
| const App = () => { | |
| cosnt [article, setArticle] = useState({}); | |
| useEffect(() => { | |
| fetch('https://api.example.com') | |
| .then(res => res.json()) | |
| .then(data => setArticle(data)); | |
| }); |
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 Promyse { | |
| constructor(userFunction) { | |
| this.state = 'pending'; | |
| this.thenCallback = null; | |
| this.errorCallback = null; | |
| userFunction(this._resolve.bind(this), this._reject.bind(this)); | |
| } | |
| _resolve(data) { |
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 FORCE_ERROR = false; | |
| function countUsersInDatabase() { | |
| return new Promise(function(resolve, reject) { | |
| setTimeout(function() { | |
| if(FORCE_ERROR) { | |
| return reject(new Error('database error')); | |
| } else { | |
| return resolve(44); | |
| } |
NewerOlder