Skip to content

Instantly share code, notes, and snippets.

@dvdbng
dvdbng / vim-heroku.sh
Last active April 22, 2024 22:42
Run vim in heroku updated 2017
mkdir ~/vim
cd ~/vim
# Staically linked vim version compiled from https://github.com/ericpruitt/static-vim
# Compiled on Jul 20 2017
curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz
export VIMRUNTIME="$HOME/vim/runtime"
export PATH="$HOME/vim:$PATH"
cd -
@dvdbng
dvdbng / gist:1762527
Created February 7, 2012 22:18
HTML DOM to Markdown in javascript
/*
You can use this to convert a DOM element or a HTML string to markdown.
Usage examples:
var markdown = toMarkdown(document.getElementById("content"));
// With jQuery you can easily convert HTML strings
var markdown = toMarkdown($("<ul><li>Hi!</li></ul>")[0]);
@dvdbng
dvdbng / zsh_to_fish.py
Created December 21, 2016 18:02
Migrate zsh history to fish
import os
import re
def zsh_to_fish(cmd):
return (cmd.replace('&&', '; and ')
.replace('||', '; or '))
def is_valid_fish(cmd):
@dvdbng
dvdbng / main.py
Created July 13, 2018 15:18
Coinbase pro DCA with limit orders
import requests
import os
import time
import base64
import hmac
import hashlib
from decimal import Decimal, getcontext
API_URL = 'https://api.pro.coinbase.com'
@dvdbng
dvdbng / copy-aws-eb-env-vars.js
Created June 16, 2021 14:41
Copy/paste all ENV variables from one AWS beanstalk env to another
// Copy/paste all ENV variables from one AWS beanstalk env to another. Use this functions in the browser console
// Copy ENV as json
copy(
JSON.stringify(
Object.fromEntries(
Array.from(
document.querySelectorAll('.env-props-table tbody tr:not(.ng-hide)')
).map(e => [
e.querySelector('[ng-model="option.optionName"]').value,
@dvdbng
dvdbng / ssh_proxy.js
Created May 12, 2020 16:58
TCP forwarding proxy over ssh
const net = require('net');
const child_process = require('child_process');
function makeProxy(port, jump, target) {
const server = net.createServer(socket => {
const subprocess = child_process.spawn(
'ssh',
[jump, '-W', target],
{ stdio: ['pipe', 'pipe', 'inherit'] }
);
@dvdbng
dvdbng / gsubrb
Created April 10, 2020 13:24
Recursive replace in directory, replacement is dynamically created by ruby code
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
require 'active_support/all'
options = {}
OptionParser.new do |opts|
opts.banner = 'Usage: gsubrb [options]'
opts.on('-r', '--replace [CODE]', String, 'Block that will be executed for each match') do |code|
@dvdbng
dvdbng / awsenv
Created April 2, 2020 17:06
Set AWS credentials from pass store
#!/bin/bash
# Usage awsenv enviromnent command...
search="$1"
shift
file=$(find "$HOME"/.password-store/AWS | grep "$search.*/AKIA.*gpg$")
if [[ x"$file" = x ]]; then
echo "Could not find a AWS key at $search" >&2
exit 1
#!/bin/bash
# Usage: ./eth-balance address
wei="$(curl -s https://api.blockcypher.com/v1/eth/main/addrs/"$1" | jq .balance)"
eth="$(echo "$wei / (10 ^ 18)" | bc -l)"
echo $eth
#!/bin/bash
# Usage: ./btc-balance address
satoshis="$(curl https://insight.bitpay.com/api/addr/"$1"/balance)"
btc="$(echo "$satoshis/100000000" | bc -l)"
echo $btc