Skip to content

Instantly share code, notes, and snippets.

:octocat:
#building

Leon Gaban leongaban

View GitHub Profile
View blockstack
Verifying my Blockstack ID is secured with the address 1KWPiFTX9JFUVcYS9KH1GDMi9AZNHUpgBz https://explorer.blockstack.org/address/1KWPiFTX9JFUVcYS9KH1GDMi9AZNHUpgBz
@leongaban
leongaban / nFormatter.js
Created Mar 3, 2019
Large currency / money number formatter
View nFormatter.js
// https://tinyurl.com/nFormatter
export const nFormatter = (num: number, digits: number) => {
const si = [
{ value: 1, symbol: "" },
{ value: 1E3, symbol: "k" },
{ value: 1E6, symbol: "M" },
{ value: 1E9, symbol: "G" },
{ value: 1E12, symbol: "T" },
{ value: 1E15, symbol: "P" },
{ value: 1E18, symbol: "E" }
View poolApi.test.ts
import LiquidityPoolApi from './LiquidityPool';
const endpoint = '/frontoffice/api/liquidity-pool/get-total-payout';
jest.mock(endpoint, () => ({
getUsersTotalPayout: jest.fn(() => Promise.resolve({ data: { payout: 100.21 } }))
}));
describe('LiquidityPool API: getUsersTotalPayout', () => {
it('should make a request when we get images', () => {
View poolApi.ts
import { bind } from 'decko';
import BaseApi from './Base';
import * as NS from './types';
class LiquidityPoolApi extends BaseApi {
@bind
public async getUsersTotalPayout(userId: string): Promise<number> {
const params: NS.IGetUsersTotalPayoutRequest = { userId };
@leongaban
leongaban / coverage.sh
Created Feb 27, 2018
Script to limit your tests coverage check to specific directories
View coverage.sh
#!/usr/bin/env bash
JEST=node_modules/jest/bin/jest.js
HELP_TEXT="\n\n\tPass a target with '-t' or '--target'.\n"
RED='\033[0;31m'
NC='\033[0m' # No Color
POSITIONAL=()
while [[ $# -gt 0 ]]
do
View index.js
// @flow
import type {
AbcCorePluginOptions,
AbcCurrencyInfo,
AbcCurrencyPlugin,
AbcCurrencyPluginFactory
} from 'edge-login'
import bcoin from 'bcoin'
// Coins Plugin Info
View decred.js
// @flow
import type { AbcCurrencyInfo } from 'edge-login'
export const decredInfo: AbcCurrencyInfo = {
// Basic currency information:
currencyCode: 'DCR',
currencyName: 'Decred',
pluginName: 'decred',
denominations: [{ name: 'DCR', multiplier: '100000000', symbol: 'D' }],
walletTypes: ['wallet:decred-blake256', 'wallet:decred'],
@leongaban
leongaban / currencyPlugin.js
Created Feb 23, 2018
Decred currencyPlugin
View currencyPlugin.js
// @flow
import type {
AbcCorePluginOptions,
AbcCurrencyEngine,
AbcCurrencyEngineOptions,
AbcCurrencyInfo,
AbcCurrencyPlugin,
AbcEncodeUri,
AbcIo,
AbcParsedUri,
@leongaban
leongaban / decred-edge-currency-plugin-progress.md
Last active Mar 5, 2018
Guide to setup Decred edge-currency-plugin
View decred-edge-currency-plugin-progress.md
@leongaban
leongaban / git-prune
Created Feb 6, 2018
Prune local Git branches
View git-prune
# Replace REL_BRANCH with the appropriate name
git fetch --all --prune && git branch --merged | egrep -v "(^\*|REL_BRANCH|master)" | xargs -I % sh -c 'git branch -d %1; git push origin :%1;'
You can’t perform that action at this time.