Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Brekken abrkn

View GitHub Profile
@abrkn
abrkn / heroku-log-pino-pretty.sh
Created Apr 23, 2020
Print Heroku logs with pino-pretty
View heroku-log-pino-pretty.sh
heroku logs -a YOUR_APP_NAME -t | sed 's/[^{]*//' | npx pino-pretty
View db-migrate.sh
#!/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 Jul 4, 2020
Move the remaining balance of a Tezos account to the specified destination
View drainTezosAccount.ts
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 / ScreenCapture.cs
Created Jul 23, 2012
Captures the specified region of the a window to a System.Drawing.Bitmap.
View ScreenCapture.cs
using System;
using System.Drawing;
using System.Runtime.InteropServices;
public static class ScreenCapture
{
class NativeMethods
{
[DllImport("user32.dll")]
internal static extern IntPtr GetWindowDC(IntPtr hWnd);
@abrkn
abrkn / sql-tdd.markdown
Last active May 22, 2020
Migrations and testing for PostgreSQL using node.js and Travis-CI
View sql-tdd.markdown

Migrations and testing for PostgreSQL using node.js and Travis-CI

We're looking to add a column to the table user called admin (boolean) in an existing database.

Project layout

migrations
@abrkn
abrkn / demo.ts
Created May 1, 2020
Whitelist GraphQL introspection types returned by apollo-server
View demo.ts
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
View Sweep.ts
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,
View liquid-asset-proof-d5a8a7af573c0bfa59584a0553f8899dfbcde9f7d839db85d187909fb70e2876
Authorize linking the domain name sideshift.ai to the Liquid asset d5a8a7af573c0bfa59584a0553f8899dfbcde9f7d839db85d187909fb70e2876
@abrkn
abrkn / index.js
Created Oct 13, 2017
kraken-minimal-trader
View index.js
#!/usr/bin/env node
const assert = require('assert');
const { delay } = require('bluebird');
const BigNumber = require('bignumber.js');
const kraken = require('./kraken');
const {
fetchMyOpenOrders,
fetchOrderBook,
placeOrder,
You can’t perform that action at this time.