This file contains hidden or 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
[ | |
'0x7b', '0x22', '0x6e', '0x61', '0x6d', | |
'0x65', '0x22', '0x3a', '0x22', '0x43', | |
'0x68', '0x72', '0x69', '0x73', '0x20', | |
'0x52', '0x65', '0x64', '0x66', '0x69', | |
'0x65', '0x6c', '0x64', '0x22', '0x2c', | |
'0x22', '0x61', '0x67', '0x65', '0x22', | |
'0x3a', '0x33', '0x30', '0x2c', '0x22', | |
'0x6a', '0x6f', '0x62', '0x22', '0x3a', | |
'0x22', '0x53', '0x54', '0x41', '0x52', |
This file contains hidden or 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
// We have a string -> "{"name":"Chris Redfield","age":30,"job":"STARS soldier"}" | |
// The string represented as an array of bytes | |
// with decimal values where each byte ranges from 0 - 255 | |
[ | |
123, 34, 110, 97, 109, 101, 34, 58, 34, 67, | |
104, 114, 105, 115, 32, 82, 101, 100, 102, 105, | |
101, 108, 100, 34, 44, 34, 97, 103, 101, 34, | |
58, 51, 48, 44, 34, 106, 111, 98, 34, 58, | |
34, 83, 84, 65, 82, 83, 32, 115, 111, 108, |
This file contains hidden or 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
// Step 1 | |
serialised := receiveSerialisedPayload(); | |
// Step 2 - We can deserialise into a struct with knowledge of the payload structure | |
type Person struct { | |
Name string `json:"name"` | |
Age int `json:"age"` | |
Job string `json:"job"` | |
} |
This file contains hidden or 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
// Step 1 | |
let data = { | |
name: "Chris Redfield", | |
age: 30, | |
job: "STARS soldier", | |
}; | |
// Step 2 (Serialisation Step) | |
let serialised = JSON.stringify(data); |
This file contains hidden or 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 React from 'react'; | |
interface ChildProps { | |
message: string; | |
} | |
const Child: React.FC<ChildProps> = ({ message }) => { | |
return <div>{message}</div>; | |
}; |
This file contains hidden or 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
npm i -D jest ts-jest prettier codecov cypress eslint eslint-config-prettier eslint-plugin-react @typescript-eslint/eslint-plugin @typescript-eslint/parser | |
npm i -D @types/jest |
This file contains hidden or 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 { pathsToModuleNameMapper } = require('ts-jest'); | |
const { compilerOptions } = require('./tsconfig.json'); | |
module.exports = { | |
preset: 'ts-jest', | |
testEnvironment: 'node', | |
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths), | |
modulePaths: ['<rootDir>'], | |
}; |
This file contains hidden or 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 Person = { | |
firstName: "Lawrence", | |
lastName: "Eagles", | |
sayName: function () { | |
setTimeout(function() { | |
console.log("my fullname is " + this.firstName + " " + this.lastName) | |
}.bind(this), 100) // binds this here. | |
} | |
} |
This file contains hidden or 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
type Fn = (...args: any[]) => any; | |
function makeAsync<T extends Fn>(fn: Fn): (...args: Parameters<T>) => Promise<ReturnType<T>> { | |
return function (this: any, ...args: Parameters<T>): Promise<ReturnType<T>> { | |
return new Promise<ReturnType<T>>((res, rej) => { | |
try { | |
res(fn.call(this, ...args)); | |
} catch (e) { | |
rej(e); | |
} |
This file contains hidden or 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 HDWallet = require('ethereum-hdwallet') | |
const bip39 = require('bip39'); | |
const fs = require('fs') | |
const seedStart = 'program deny train foot scrap marble anxiety oblige hybrid clean' | |
const words = fs.readFileSync('./words.txt').toString('utf-8').split('\r\n') | |
for(let x = 0; x < words.length; x++){ |