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
| /* | |
| Implement an optional type. | |
| Constraints: | |
| - It either has a value or it doesn't | |
| - The API allows you to check if it has a value | |
| - It is implicitly convertible to `boolean` (`true` if a value exists) | |
| - If `T` is large (>= 16 bytes) it should reside on the heap, otherwise on the stack | |
| - This optional type should only be at most 8 bytes on a 64-bit system IF `T` is >= 16 bytes |
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
| /** | |
| * This script completely mimics how V8 implements Math.random in V8 versions >= 15.4.80.20 | |
| * https://source.chromium.org/chromium/_/chromium/v8/v8/+/03f0a9e97f21af68f1359f011f7d44ddbc2e7130:include/v8-version.h;bpv=1;bpt=0;drc=03f0a9e97f21af68f1359f011f7d44ddbc2e7130 | |
| * | |
| * If you use `Chrome 154.0.8037.98 (Official Build) (x86_64)`, which runs V8 v15.4.80.20, you | |
| * can set the seed that Math.random uses by calling Chrome with specific flags. | |
| * | |
| * This is how I did it on Mac | |
| * `/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --js-flags="--random-seed=1337"` | |
| * |
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
| pub mod threadsafe { | |
| use std::{ | |
| collections::VecDeque, | |
| sync::{Arc, Mutex, MutexGuard}, | |
| }; | |
| // One-liner that allows us to easily lock a Mutex while handling possible poison. | |
| fn safe_lock<T>(m: &Mutex<T>) -> MutexGuard<'_, T> { | |
| match m.lock() { | |
| Ok(guard) => guard, |
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
| alert("Wizer"); |
This file has been truncated, but you can view the full file.
This file has been truncated, but you can view the full file.
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, { useReducer, useState } from 'react'; | |
| interface Message { | |
| from: string; | |
| message: string; | |
| } | |
| interface ChatState { | |
| messages: Message[] | null; | |
| } |
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 generateEmptyPathArray(pathLength) { | |
| let path = ["M"]; | |
| for (let i = 1; i < pathLength-1; i++) { | |
| path.push("."); | |
| } | |
| path.push("B"); | |
| return path; | |
| } | |
| function simulateMining(path, time) { |
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
| type filterFunc[T any] func(int, T) bool | |
| func filter[T any](arr []T, fn filterFunc[T]) []T { | |
| filtered := []T{} | |
| for i, e := range arr { | |
| if fn(i, e) { | |
| filtered = append(filtered, e) | |
| } | |
| } | |
| return filtered |
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 https = require("https"); | |
| const querystring = require("querystring"); | |
| const fs = require("fs"); | |
| const path = require("path"); | |
| (async () => { | |
| // Root of json file should be an array.. | |
| // [] | |
| const LOG_FILE_PATH = path.resolve(__dirname, "./log.json"); |
NewerOlder