This file contains 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 getGroupsById = (state, ids) => ids.map(id => state.groups[id]) | |
const getUsersWithGroupsById = (state, ids) => ids.map(id => ({...state.users[id], groups: getGroupsById(state.users[id].groups)})) |
This file contains 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 fs = require("fs"); | |
const util = require("util"); | |
const readFile = util.promisify(fs.readFile); | |
async function long() { | |
const content = await readFile("./dummy1000000.csv", "utf-8"); | |
content.split(/\n/); | |
} | |
const arr = []; |
This file contains 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, { Component } from "react"; | |
import logo from "./logo.svg"; | |
import "./App.css"; | |
const Child = ({ onClick }) => <button onClick={onClick}>Click me</button>; | |
class Parent extends Component { | |
field = "hello"; | |
handleClick = e => { |
This file contains 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
// css is | |
// .day {color: black; background-color:white} | |
// .night {color: white; background-color:blue} | |
const DivChanging = ({ text }) => { | |
if (new Date().getHours() > 12) { | |
return <div class="night">{text}</div>; | |
} else { | |
return <div class="day">{text}</div>; | |
} |
This file contains 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
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"$id": "http://shone.com/anorak.json", | |
"title": "Anorak", | |
"description": "Portable Realtime Maritime Navigational Data Protocol", | |
"oneOf": [ | |
{ "$ref": "#subscribeMessage" }, | |
{ "$ref": "#unsubscribeMessage" }, | |
{ "$ref": "#getMessage" }, | |
{ "$ref": "#deltaMessage" }, |
This file contains 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 scrapeProduct (url) { | |
// the same code as you have ... | |
return {srcText, price, title}; | |
} | |
async function main() { | |
const results = await scrapeProduct("..."); | |
// here you can do something with results = {srcText, price, title}; |
This file contains 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 isInside(pos, rect) { | |
return ( | |
pos[0] > rect[0] && pos[1] > rect[1] && pos[0] < rect[2] && pos[1] < rect[2] | |
); | |
} | |
const rect1 = new Uint16Array([10, 10, 100, 1000]); | |
const rect2 = new Uint16Array([0, 0, 10, 10]); | |
const pos1 = new Uint16Array([250, 50]); | |
const pos2 = new Uint16Array([20, 20]); |
This file contains 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
thread 'main' panicked at 'assertion failed: `(left == right)` | |
left: `Ok(())`, | |
right: `Err(ERROR_DEVICE_LOST)`', C:\Users\Baptiste\.cargo\git\checkouts\gfx-e86e7f3ebdbc4218\0244e34\src\backend\vulkan\src\lib.rs:1476:9 | |
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | |
thread 'main' panicked at 'assertion failed: `(left == right)` | |
left: `1`, | |
right: `0`: Allocator dropped before all sets were deallocated', C:\Users\Baptiste\.cargo\git\checkouts\gpu-descriptor-a05b99db0270c787\df74fd8\gpu-descriptor\src\allocator.rs:117:9 | |
stack backtrace: | |
0: 0x7ff7e7edea0e - std::backtrace_rs::backtrace::dbghelp::trace | |
at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:108 |
This file contains 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 fs = require("fs"); | |
function dateCompress(d) { | |
return d.replace(/\.\d{3}\+\d{2}:\d{2}$/g, "Z"); | |
} | |
function getSize(d) { | |
return Math.ceil(d.length / 1024).toLocaleString() + "kB"; | |
} |
This file contains 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 DIM = 5; | |
/** | |
* -1-DIM -DIM +1-DIM | |
* -1 i +1 | |
* -1+DIM +DIM +1+DIM | |
*/ | |
const _compute = (m, out) => { | |
for (let x = 1; x < DIM; x++) { | |
for (let y = 1; y < DIM; y++) { |