Skip to content

Instantly share code, notes, and snippets.

@rjchow
rjchow / test.json
Last active February 3, 2023 10:40
test
{
"foo": "bar",
"version": 3
}
@rjchow
rjchow / make.js
Created September 23, 2022 09:54
snippet to output partial ts interface given openapi array of params
function make (openapiArray) {
let stringOutput = ""
stringOutput += "interface { \n"
for (const a of openapiArray) {
stringOutput += `/** ${a.description} */\n`
stringOutput += `${a.name}${a.required ? "" : "?"}: `
if (a.schema && a.schema.enum) {
stringOutput += a.schema.enum.map(e => `'${e}'`).join(" | ")
}
stringOutput += '\n';
FILE: plugins/woocommerce/src/Internal/Admin/Loader.php
-----------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------
308 | ERROR | [x] Short array syntax is not allowed
| | (Generic.Arrays.DisallowShortArraySyntax.Found)
344 | ERROR | [x] Short array syntax is not allowed
| | (Generic.Arrays.DisallowShortArraySyntax.Found)
389 | ERROR | [x] Short array syntax is not allowed
| | (Generic.Arrays.DisallowShortArraySyntax.Found)
FILE: plugins/woocommerce/src/Admin/Features/PaymentGatewaySuggestions/DefaultPaymentGateways.php
-----------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------
235 | ERROR | [x] Short array syntax is not allowed
| | (Generic.Arrays.DisallowShortArraySyntax.Found)
238 | ERROR | [x] Short array syntax is not allowed
| | (Generic.Arrays.DisallowShortArraySyntax.Found)
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
@rjchow
rjchow / .dual-function-keys.yaml
Created July 12, 2021 13:39
Capslock to Escape+Ctrl Remap
# ~/.dual-function-keys.yaml
TIMING:
TAP_MILLISEC: 200
DOUBLE_TAP_MILLISEC: 150
MAPPINGS:
- KEY: KEY_CAPSLOCK
TAP: KEY_ESC
HOLD: KEY_LEFTCTRL
- KEY: KEY_ESC
@rjchow
rjchow / credentica-1.1.3.md
Created March 31, 2021 15:29
Prescient write up on centralised databases and data privacy

Excerpt from http://www.credentica.com/mit/Chapter1.pdf

It is ironic that digital certificates today are considered by many to be a secure way to provide access to personal data stored in central databases. The practice of looking up data in real time in a central database goes against the philosophy behind digital certificates, which is to allow offline verification of digital signatures. In many PKIs it is a waste of efficiency to use digital certificates in combination with central database lookup; one might as well do away with digital certificates altogether and simply check the validity of public keys in a central database. Indeed, Wheeler and Wheeler and the Accredited Standards Committee X9 for this reason propose a return to the online key repository model of Diffie and Hellman. (This model cannot protect the privacy of certificate holders, though, as we will see later on.) The central database paradigm is even less desirable from the perspective of individuals:

  • Individuals can be discriminated a
@rjchow
rjchow / readme.md
Last active March 29, 2021 08:45
how 2 ethereum developer?
@rjchow
rjchow / example-did-sign-kms.js
Created March 3, 2021 06:38
aws kms did sign example
require("dotenv").config()
const { wrapDocument, signDocument, SUPPORTED_SIGNING_ALGORITHM } = require("@govtechsg/open-attestation")
const { AwsKmsSigner } = require("ethers-aws-kms-signer");
const signer = new AwsKmsSigner({
accessKeyId: process.env.KMS_ACCESS_KEY_ID,
secretAccessKey: process.env.KMS_SECRET_ACCESS_KEY,
@rjchow
rjchow / infura-transaction-service.txt
Last active February 7, 2021 02:29
ETHDenver2021 Talks
infura transaction service
https://www.youtube.com/watch?v=BmghRUEJtJ4
fee market to entice miners
stuck transactions -> when there are too many transactions, even with high fees
problems
#1 transactions get dropped by network
nonce gap (nonce must strictly increment by 1) -> dropped transaction blocks all transactions that depend on it
@rjchow
rjchow / index.js
Created January 27, 2021 08:32
Simple Quorum Proxy
const express = require('express');
const morgan = require("morgan");
import fetch from 'node-fetch';
import { json } from 'body-parser';
require('dotenv').config()
const app = express();
// Configuration