Skip to content

Instantly share code, notes, and snippets.

Andreas Brekken abrkn

View GitHub Profile
@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
@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 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,
View how-to-lightning.ts
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!;
You can’t perform that action at this time.