Skip to content

Instantly share code, notes, and snippets.

View abrkn's full-sized avatar

Andreas Brekken abrkn

View GitHub Profile
#!/usr/bin/env bash
#
# Run database migrations with the power of bash
#
set -eu -o pipefail
cd "$(dirname "$0")/.."
if [ "$#" -lt 2 ]; then
1>&2 echo "Usage: $0 postgres://url/db <migration dir>"
exit 1
@abrkn
abrkn / drainTezosAccount.ts
Created July 4, 2020 11:24
Move the remaining balance of a Tezos account to the specified destination
import * as Conseil from 'conseiljs';
import { SoftSigner } from 'conseiljs-softsigner';
import { ns } from '@sideshift/shared';
import {
initializeConseil,
TezosRpcClient,
getTezosKeyStoreFromSecret,
createLogger,
} from '@sideshift/shared-node';
@abrkn
abrkn / demo.ts
Created May 1, 2020 13:07
Whitelist GraphQL introspection types returned by apollo-server
import { middleware as whitelistMiddleware } from './utils/introspecton-whitelist';
import { whitelist as introspectionWhitelist } from './utils/introspecton-whitelist/whitelist';
// Your express app
// Whitelist GraphQL introspection responses
app.use(whitelistMiddleware(introspectionWhitelist));
// Apollo middleware must be below whitelisting middleware
@abrkn
abrkn / heroku-log-pino-pretty.sh
Created April 23, 2020 05:35
Print Heroku logs with pino-pretty
heroku logs -a YOUR_APP_NAME -t | sed 's/[^{]*//' | npx pino-pretty
import pMap from 'p-map';
import pRetry from 'p-retry';
import { safePromise } from 'safep';
import { chain, values, chunk, flatten } from 'lodash';
import { fromEnv as configFromEnv, SlpDepositConfig } from './config';
import { slpTokens } from '../shared/slp-tokens';
import { runWorkerUntilShutdown } from '../shared/utils-node';
import { getBitcoinRpc } from '../shared/rpcs';
import {
toBchAddress,
Authorize linking the domain name sideshift.ai to the Liquid asset d5a8a7af573c0bfa59584a0553f8899dfbcde9f7d839db85d187909fb70e2876

SideShift AI

hmm

import { fromEnv as configFromEnv } from './config';
import { getRpc } from '../shared/rpcs';
import { n, runWorkerUntilShutdown } from '../shared/utils';
import { createDeposit, getConnection, Deposit, Quote } from '../shared/orm';
import { safePromise } from 'safep';
import { AxiosError } from 'axios';
const config = configFromEnv();
const depositMethod = config.depositMethod!;
const { node, asset } = depositMethod!;
@abrkn
abrkn / shifty-output.log
Last active January 31, 2019 05:43
Example Shifty output log
Jan 31 11:41:14am info app worker.1 assert(amount)
Jan 31 11:41:14am info app worker.1 at fetchDepositAddress (/app/src/web/backend/utils/address.js:146:5)
Jan 31 11:41:14am info app worker.1 at shift (/app/src/worker-shifty/start.js:72:32)
Jan 31 11:41:14am info app worker.1 at process._tickCallback (internal/process/next_tick.js:68:7)
Time gap of 5 minutes • Thursday, January 31st at 11:46 am
Jan 31 11:46:19am info app worker.1 19 deposit methods can send $5
Jan 31 11:46:19am info app worker.1 16 deposit methods are possible to send automatically
Jan 31 11:46:19am info app worker.1 Picked the deposit method ltc (asset LTC) by random
Jan 31 11:46:19am info app worker.1 Picked the settle method bch (asset BCH) by random
Jan 31 11:46:19am info app worker.1 Creating quote...
@abrkn
abrkn / shifty.js
Created January 31, 2019 05:07
Shifty, the automated ShapeShift AI testing robot
const { delayUnlessShutdown } = require('shutin');
const { depositMethods, settleMethods } = require('../shared/facts');
const { n } = require('../shared/utils');
const { fetchRate, convert } = require('../shared/rates');
const { sample, values, chain, keys } = require('lodash');
const { fetchInventorySnapshot } = require('../shared/db');
const pReduce = require('p-reduce');
const { fetchDepositAddress } = require('../web/backend/utils/address');
const payWith = require('../shared/pay');
const { safePromise } = require('safep');