Skip to content

Instantly share code, notes, and snippets.


Josep M Sobrepere josepot

View GitHub Profile
josepot / polkadot-extension-backup.ts
Last active November 20, 2021 06:49
create polkadot-js extension backup file
View polkadot-extension-backup.ts
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;
josepot / .eslintrc.js
Last active June 1, 2020 19:26
View .eslintrc.js
'use strict';
module.exports = {
root: true,
env: {
browser: false,
commonjs: false,
es6: true,
node: true,
View adventOfCode-2015-day7.js
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,
josepot / SagasGlobalErrorHandling.js
Created December 3, 2016 18:26
Sagas: Global Error Handling
View SagasGlobalErrorHandling.js
// I usually use the request-sequence pattern
// (
// 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.
josepot / SagasRequestSequencePattern.js
Last active December 4, 2016 16:51
Sagas: Request Sequence pattern
View SagasRequestSequencePattern.js
// 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 {