Skip to content

Instantly share code, notes, and snippets.

@Venryx
Venryx / ForOfLoop_ES6ToES5_SimpleConversion.md
Last active September 14, 2016 18:10
Small webpack config change to have the ES6 for-of loop converted to an ES5 for loop

The following is a small webpack config change to have the ES6:
for (let item of collection)
Converted to the ES5:
for (let i = 0, item; i < collection.length | (item = collection[i]); i++)

Instructions

  1. Run npm install --save string-replace-webpack-plugin

  2. Add the following to your webpack.config.js file: (below the babel-loader, so that ours runs before it (yes, last runs first))

@Venryx
Venryx / ReasonScore.ts
Created March 27, 2018 11:46
Reason Score - First Attempt
import { MapNodeL3 } from "Store/firebase/nodes/@MapNode";
import { GetNodeChildrenL2, GetNodeChildrenL3 } from "Store/firebase/nodes";
import {MapNodeL2, Polarity} from "../nodes/@MapNode";
import {IsSpecialEmptyArray, emptyArray_forLoading} from "../../../Frame/Store/ReducerUtils";
import {GetFinalPolarity} from "../nodes/$node";
import {MapNodeType} from "../nodes/@MapNodeType";
export function ReasonScore_CalculateTruthScore(node: MapNodeL3) {
Assert(node.type == MapNodeType.Claim, "RS truth-score can only be calculated for a claim.");
@Venryx
Venryx / ReasonScore.ts
Last active March 27, 2018 13:26
ReasonScore - Draft 2
import { MapNodeL3 } from "Store/firebase/nodes/@MapNode";
import { GetNodeChildrenL2, GetNodeChildrenL3 } from "Store/firebase/nodes";
import {MapNodeL2, Polarity} from "../nodes/@MapNode";
import {IsSpecialEmptyArray, emptyArray_forLoading} from "../../../Frame/Store/ReducerUtils";
import {GetFinalPolarity} from "../nodes/$node";
import {MapNodeType} from "../nodes/@MapNodeType";
export function RS_CalculateTruthScore(node: MapNodeL3) {
Assert(node.type == MapNodeType.Claim, "RS truth-score can only be calculated for a claim.");
@Venryx
Venryx / ReasonScore.ts
Created March 27, 2018 14:38
ReasonScore - Draft 3
import { MapNodeL3 } from "Store/firebase/nodes/@MapNode";
import { GetNodeChildrenL2, GetNodeChildrenL3 } from "Store/firebase/nodes";
import {MapNodeL2, Polarity} from "../nodes/@MapNode";
import {IsSpecialEmptyArray, emptyArray_forLoading} from "../../../Frame/Store/ReducerUtils";
import {GetFinalPolarity} from "../nodes/$node";
import {MapNodeType} from "../nodes/@MapNodeType";
export function RS_CalculateTruthScore(node: MapNodeL3) {
Assert(node.type == MapNodeType.Claim, "RS truth-score can only be calculated for a claim.");
@Venryx
Venryx / ReasonScore.ts
Created March 27, 2018 17:05
ReasonScore - Draft 4
import { MapNodeL3 } from "Store/firebase/nodes/@MapNode";
import { GetNodeChildrenL2, GetNodeChildrenL3 } from "Store/firebase/nodes";
import {MapNodeL2, Polarity, LayerPlusAnchorParentSet} from "../nodes/@MapNode";
import {IsSpecialEmptyArray, emptyArray_forLoading} from "../../../Frame/Store/ReducerUtils";
import {GetFinalPolarity} from "../nodes/$node";
import {MapNodeType} from "../nodes/@MapNodeType";
import { Lerp } from "js-vextensions";
import { ArgumentType } from "Store/firebase/nodes/@MapNodeRevision";
export function RS_CalculateTruthScore(node: MapNodeL3) {
@Venryx
Venryx / index.html
Created December 6, 2018 15:20
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<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>,
@Venryx
Venryx / index.html
Created December 6, 2018 15:20
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<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>,
@Venryx
Venryx / index.html
Created April 4, 2019 23:47 — forked from JobLeonard/index.html
Join vs Template - Venryx (http://jsbench.github.io/#a8a564f66be7840376640c3060846208) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Join vs Template - Venryx</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>
<!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>
@Venryx
Venryx / Example.kt
Last active February 17, 2020 23:07
Trigger SonicBomb shakes from your app
// 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