Skip to content

Instantly share code, notes, and snippets.

@rjchow
rjchow / readme.md
Last active August 19, 2020 13:29
Using matplotlib on WSL2 + remote X11 server

Install x410 or vcxsrv

Add to ~/.zshrc

export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0

Set Public Access to true in x410 settings

Setup Windows Firewall rule to allow tcp 6000 from WSL2 subnet to x410.exe

@rjchow
rjchow / example.md
Last active July 1, 2020 07:34
Using curl with oa-functions https endpoint

curl and jq can be used in conjunction to send an OpenAttestation file to the API endpoint for verification

For example to send a file named ropsten.opencerts :

curl -X POST -d "$(cat ropsten.opencerts | jq '{ "document": . }')" https://api-ropsten.opencerts.io/verify

To get a pretty-printed JSON response, pipe it back into jq :

@rjchow
rjchow / gist:ed26432151edbb8a3c1a93d69deac225
Last active June 22, 2020 02:49
Using AssumeRole/MFA with Serverless instead of unsecured Access Keys lying around on ~/.aws/credentials

Set up MFA profile1, for e.g named as "cli-admin"

> export AWS_SDK_LOAD_CONFIG="true"
> serverless deploy --aws-profile cli-admin

... sls text will scroll by, and you will see Enter MFA code for arn:aws:iam::-:mfa/cli-admin: Serverless: Bundling with Webpack... IT WONT WAIT FOR YOU TO ENTER YOUR MFA! There's a stupid bug2

const ethers = require("ethers");
console.time("Wallet Creation");
const w = ethers.Wallet.createRandom();
console.timeEnd("Wallet Creation");
async function encryptAndDecryptWithScryptParams(N, r, p) {
console.time(`Encrypt/Decrypt with scrypt params N:${N} r:${r} p:${p} `);
const g = await w.encrypt("password", { scrypt: { N, r, p } });
export class TitleEscrow extends ethers.Contract {
constructor(addressOrName: string, providerOrSigner: ethers.Signer | ethers.providers.Provider) {
super(addressOrName, new.target.ABI(), providerOrSigner)
}
connect(providerOrSigner: ethers.Signer | ethers.providers.Provider): TitleEscrow {
return new (<{ new(...args: any[]): TitleEscrow }>(this.constructor))(this.address, providerOrSigner)
}
// http://stackoverflow.com/questions/39806802/lifecycle-event-state-and-prevstate-in-react-js/
console.clear();
class Counter extends React.Component {
// state = { value: 0 };
// the state above is just a property of
// the Counter class, this is not however
0x625b507726de9342B0dC0103c31C21Cb696A7010
2019-04-24T07:55:18+0000
0x625b507726de9342B0dC0103c31C21Cb696A7010
2019-04-24T07:55:18+0000

SSEC-EQA

qualificationLevel: [ {
  frameworkName: "sg/ssec-eqa/2015"
  frameworkVersion: "2015"
  levelCode: 51
  levelDescription: "Polytechnic Diploma"
  qualificationName: "Diploma in Biomedical Science"
  qualificationDescription: "Learn to integrate and apply biological and chemical sciences knowledge to solve problems that our world faces, including infectious diseases, cancer, neurodegenerative diseases and an increasing demand for better nutrition and safer foods. Our Diploma in Biomedical Science (BMS) combines knowledge from bioinformatics, chemistry, molecular biology, immunology, microbiology, and proteomics to offer innovative solutions to these challenges."