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 { noise } from '@chainsafe/libp2p-noise'; | |
| import { bootstrap } from '@libp2p/bootstrap'; | |
| import { tcp } from '@libp2p/tcp'; | |
| import { webSockets } from '@libp2p/websockets'; | |
| import { createLibp2p } from 'libp2p'; | |
| import { yamux } from '@chainsafe/libp2p-yamux'; | |
| import { floodsub } from '@libp2p/floodsub'; | |
| import { createFromJSON } from '@libp2p/peer-id-factory'; | |
| const node1 = { |
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
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.0; | |
| import {UD60x18} from "@prb/math/UD60x18.sol"; | |
| import {SD59x18} from "@prb/math/SD59x18.sol"; | |
| library PRBMathRounding { | |
| SD59x18 constant iONE = SD59x18.wrap(1e18); | |
| SD59x18 constant iTEN = SD59x18.wrap(10e18); | |
| UD60x18 constant ONE_THOUSAND = UD60x18.wrap(1000e18); |
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 getEvent(tx: any, event: string) { | |
| let receipt = await tx.wait(); | |
| return receipt.events?.filter((x) => { | |
| return x.event == event; | |
| }); | |
| } | |
| async function getEventArgs(tx: any, event: string) { | |
| return (await getEvent(tx, event))[0].args; | |
| } |
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 returnedArray = []; | |
| if (cluster.isMaster) { | |
| console.log(`Master ${process.pid} is running`); | |
| // Fork workers | |
| for (let i = 0; i < numCPUs; i++) { | |
| const worker = cluster.fork(); | |
| } | |
| } else { | |
| app.post('/api/multiThread', (req, res) => { |
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 spawnedProcess = spawn('python3', ['./python/pdfConverter.py']) | |
| var referenceJson = { turfs: [] } | |
| spawnedProcess.stderr | |
| .on('data', (data) => { | |
| console.log(`error:${data}`); | |
| res.sendStatus(500) | |
| }) | |
| .on('close', () => { | |
| try { |
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 spawnedProcess = spawn('python3', ['./python/pdfConverter.py']) | |
| spawnedProcess.stderr | |
| .on('data', (data) => { | |
| console.log(`error:${data}`); | |
| res.sendStatus(500) | |
| }) | |
| .on('close', () => { | |
| try { | |
| createInterface({ |
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 draw() { | |
| var canvas = document.getElementById('canvas'); | |
| if (canvas.getContext) { | |
| var ctx = canvas.getContext('2d'); | |
| ctx.beginPath(); | |
| var scale = 10; | |
| var spacing = 20; |
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
| // Note this only shows the function being called in the parent component. The child component | |
| // passes the event and contract address to the parent... I can make this more complete if requested... | |
| uploadFile = async (event, contractAddress) => { | |
| event.stopPropagation(); | |
| event.preventDefault(); | |
| const { web3, accounts } = this.state; |
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
| // Swap Case | |
| // Below is a function that takes in a string and reverses the case of every character and returns the new string. | |
| // It is currently in a broken state and does not run properly. | |
| // It is possible to fix the code by only modifying the existing code, not adding new lines. | |
| //test data | |
| //'This Is An Example' becomes 'tHIS iS aN eXAMPLE' | |
| //'boB rOss IS thE OrIgInAl GanGster' Becomes 'BOb RoSS is THe oRiGiNaL gANgSTER' | |
| function caseReverse(str) { |
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
| // FizzBuzz | |
| // write a function that takes in one number. | |
| // Starting at 1, console log every number up to the number passed in. | |
| // If the number being logged is divisible by 3 log 'Fizz' instead. | |
| // If the number is divisible by 5 we will log 'Buzz' instead. | |
| // If they are divisible by both 3 and 5 we will log 'FizzBuzz' | |
| function fizzBuzz(num) { | |
| for (let i = 1; i <= num; i++) { | |
| if (i % 3 === 0 && i % 5 === 0) { |
NewerOlder