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
declare global { | |
interface String { | |
/** | |
* Reformats a multi-line string to represent the actual intended "block" of text. | |
* @param desiredIndent How much to indent each line. (after removal of the first-line indent-length from each of them) | |
*/ | |
AsMultiline(desiredIndent: number): string; | |
} | |
} | |
String.prototype.AsMultiline = function(this: string, desiredIndent: number = null) { |
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
[...] | |
let fs = require("fs-extra"); | |
webpackConfig.plugins.push({ | |
apply(compiler) { | |
console.log(`Valid hook names: ${Object.keys(compiler.hooks)}`); | |
//compiler.hooks.beforeRun.tap("CopyPlugin_Custom", params=>{ | |
compiler.hooks.shouldEmit.tap("CopyPlugin_Custom", params=>{ | |
console.log(`Copying some difficult files (eg. *.wasm) from "node_modules/..." to "Resources/FromNodeModules/...".`); |
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 {GetAccessToken, ClaimSet} from "./GoogleAuth"; | |
const projectID = "XXXXXX"; | |
// session-id can apparently be set to an arbitrary value, eg. "abcd1234-abcd-abcd-abcd-abcd12345678". | |
const sessionID = "XXXXXX"; | |
const serviceAccountEmail = `XXXXXX@${projectID}.iam.gserviceaccount.com`; | |
const serviceAccountPrivateKey = `-----BEGIN PRIVATE KEY-----\nXXXXXX\n-----END PRIVATE KEY-----`; | |
export async function ConvertSpeechToText(audioData_str_opus: string): Promise<string> { | |
const claimSet = new ClaimSet(["https://www.googleapis.com/auth/cloud-platform"], serviceAccountEmail); |
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 {forwardRef, useImperativeHandle, ForwardRefExoticComponent, RefAttributes, Ref} from "react"; | |
export type Handle<T> = T extends ForwardRefExoticComponent<RefAttributes<infer T2>> ? T2 : never; | |
export const Parent = (props: {})=> { | |
let childHandle: Handle<typeof Child>; | |
return ( | |
<div onClick={()=>childHandle.SayHi()}> | |
<Child name="Bob" ref={c=>childHandle = c}/> | |
</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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Test1</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
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
// Note: I'm not updating this anymore. For the latest version, see here: https://stackoverflow.com/a/60271550/2441655 | |
val patterns = arrayOf( | |
"!WLALALALALALALALA;", // default | |
"!WTRG0TRG0TRG0TRG;", // pulse | |
"!WPJ0FPV7S1J600;" // sos | |
// you can add your own patterns by mixing and matching the vibration components | |
); | |
// strength is between 0 and 100; pattern follows the format seen above |
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 {Characteristic, Peripheral, Service} from "@abandonware/noble"; | |
export class ControllerData { | |
accel: number[]; | |
gyro: number[]; | |
magX: number; | |
magY: number; | |
magZ: number; |
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 videoPlayer = netflix | |
.appContext | |
.state | |
.playerApp | |
.getAPI() | |
.videoPlayer; | |
// Getting player id | |
const videoPlayer = videoPlayer | |
.getAllPlayerSessionIds()[0] |
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
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP | |
def ToLPath(path): | |
return path.replace("\\", "/").replace("C:/", "/mnt/c/") | |
def ToWPath(path): | |
return path.replace("/", "\\").replace("\\mnt\\c\\", "C:\\") | |
def ListDir(path, recursive = False): | |
result = [] | |
for file in listdir(ToWPath(path), recursive): |
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
use std::{sync::{Mutex, Arc}, ops::{Deref, DerefMut}}; | |
use tokio::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard}; | |
/// Wrapper around RwLock, which: | |
/// 1) Requires that anyone who takes a lock-guard must supply their "name". | |
/// 2) Provides a way for anyone to get a list of "current lock-guard holders". (without having to take a lock-guard themselves) | |
pub struct RwLock_Tracked<T> { | |
l: RwLock<T>, | |
live_guards: Arc<Mutex<Vec<String>>>, | |
} |