View polkadot-extension-backup.ts
This file contains 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 { fromHex, utf16StrToUtf8Bytes } from "@unstoppablejs/utils"; | |
import { jsonEncrypt } from "@polkadot/util-crypto"; | |
import { createPair, Keyring } from "@polkadot/keyring"; | |
const keyToBytes = (input: string | Uint8Array): Uint8Array => | |
typeof input === "string" ? fromHex(input) : input; | |
export function createBackUpFileContent( | |
addresses: Array<{ | |
name: string; |
View .eslintrc.js
This file contains 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
'use strict'; | |
module.exports = { | |
root: true, | |
env: { | |
browser: false, | |
commonjs: false, | |
es6: true, | |
node: true, |
View adventOfCode-2015-day7.js
This file contains 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 {map, pipe} = require('ramda'); | |
const operations = { | |
NOT: a => ~a, | |
COPY: a => a, | |
AND: (a, b) => a & b, | |
OR: (a, b) => a | b, | |
LSHIFT: (a, b) => a << b, | |
RSHIFT: (a, b) => a >> b, | |
}; |
View SagasGlobalErrorHandling.js
This file contains 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
// I usually use the request-sequence pattern | |
// (https://gist.github.com/josepot/cf63578fa81c7dba89ba156e71274537) | |
// And since 99% of the times that a saga errors it's because something | |
// went wrong with a request. That's not the only case when a saga can crash. | |
// The problem is that if there is an unhandled exception is a saga, that | |
// exception gets propagated all the way up to the rootSaga and the root | |
// saga will cancell all watchers... Which can be pretty annoying. | |
// This is one way to avoid such thing from happening: | |
// This is just a silly example on how to deal with a general exception. |
View SagasRequestSequencePattern.js
This file contains 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
// Request sequence pattern | |
// One of the reasons why I love Redux-Saga is because it allows me | |
// to handle all the common requests in a consistent manner, | |
// which reduces the amount of boilerplate and helps me keep things | |
// DRYer. I usually use a variation of the following utility Saga | |
// whenever I have to make a normal/promise request: | |
import { | |
call, |