Skip to content

Instantly share code, notes, and snippets.


Stephen Wicklund Venryx

View GitHub Profile
Venryx / Example.kt
Last active Feb 17, 2020
Trigger SonicBomb shakes from your app
View Example.kt
// Note: I'm not updating this anymore. For the latest version, see here:
val patterns = arrayOf(
"!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
View index.html
<!DOCTYPE html>
<meta charset="utf-8"/>
<script src=""></script>
<script src="./suite.js"></script>
<h1>Open the console to view the results</h1>
Venryx / Example.tsx
Last active Sep 11, 2020
Using "useImperativeHandle" in a React functional component, with automatic TypeScript typing
View Example.tsx
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}/>
Venryx / DialogFlowExample.ts
Last active Jul 14, 2020
How to get a Google auth-token for DialogFlow, entirely from front-end JavaScript
View DialogFlowExample.ts
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}`;
const serviceAccountPrivateKey = `-----BEGIN PRIVATE KEY-----\nXXXXXX\n-----END PRIVATE KEY-----`;
export async function ConvertSpeechToText(audioData_str_opus: string): Promise<string> {
const claimSet = new ClaimSet([""], serviceAccountEmail);
Venryx / WebpackConfig.js
Created Sep 8, 2019
Example inline-plugin to replace CopyWebpackPlugin
View WebpackConfig.js
let fs = require("fs-extra");
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/...".`);
Venryx / Main.ts
Last active Jun 4, 2020
View Main.ts
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) {
Venryx / AndroidManifest.xml
Last active Aug 27, 2020
Record audio on Android in the background (even when screen is off)
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="" package="com.myapp">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
<service android:name=".ForegroundService" android:enabled="true" android:exported="true"></service>
Venryx / RomajiConverter.ts
Last active Jun 4, 2019
Hiragana/Katakana to Romaji Converter (Typescript/Javascript)
View RomajiConverter.ts
// Raw chart text obtained by simple copy-paste from:
const rawChartText = `
a i u e o
ka ki ku ke ko きゃ キャ kya きゅ キュ kyu きょ キョ kyo
sa shi su se so しゃ シャ sha しゅ シュ shu しょ ショ sho
ta chi tsu te to ちゃ チャ cha ちゅ チュ chu ちょ チョ cho
na ni nu ne no にゃ ニャ nya にゅ ニュ nyu にょ ニョ nyo
ha hi fu he ho ひゃ ヒャ hya ひゅ ヒュ hyu ひょ ヒョ hyo
ma mi mu me mo みゃ ミャ mya みゅ ミュ myu みょ ミョ myo
ya yu yo
View index.html
<!DOCTYPE html>
<meta charset="utf-8"/>
<title>Join vs Template - Venryx</title>
<script src=""></script>
<script src="./suite.js"></script>
<h1>Open the console to view the results</h1>
Venryx / index.html
Created Dec 6, 2018
Electron Fiddle Gist
View index.html
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Hello World!</title>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
You can’t perform that action at this time.