Skip to content

Instantly share code, notes, and snippets.

View leongaban's full-sized avatar

Leon Gaban leongaban

  • Austin, TX
  • 04:31 (UTC -06:00)
View GitHub Profile
Verifying my Blockstack ID is secured with the address 1KWPiFTX9JFUVcYS9KH1GDMi9AZNHUpgBz https://explorer.blockstack.org/address/1KWPiFTX9JFUVcYS9KH1GDMi9AZNHUpgBz
@leongaban
leongaban / nFormatter.js
Created March 3, 2019 16:59
Large currency / money number formatter
// 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" }
@leongaban
leongaban / poolApi.test.ts
Last active September 18, 2018 21:11
poolTest
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', () => {
@leongaban
leongaban / poolApi.ts
Created September 18, 2018 21:06
PoolAPI class
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 February 27, 2018 23:02
Script to limit your tests coverage check to specific directories
#!/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
@leongaban
leongaban / index.js
Created February 23, 2018 18:58
Edge index
// @flow
import type {
AbcCorePluginOptions,
AbcCurrencyInfo,
AbcCurrencyPlugin,
AbcCurrencyPluginFactory
} from 'edge-login'
import bcoin from 'bcoin'
// Coins Plugin Info
@leongaban
leongaban / decred.js
Created February 23, 2018 18:58
decred plugin
// @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 February 23, 2018 18:58
Decred currencyPlugin
// @flow
import type {
AbcCorePluginOptions,
AbcCurrencyEngine,
AbcCurrencyEngineOptions,
AbcCurrencyInfo,
AbcCurrencyPlugin,
AbcEncodeUri,
AbcIo,
AbcParsedUri,
@leongaban
leongaban / decred-edge-currency-plugin-progress.md
Last active March 5, 2018 23:18
Guide to setup Decred edge-currency-plugin
@leongaban
leongaban / git-prune
Created February 6, 2018 15:50
Prune local Git branches
# 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;'