Skip to content

Instantly share code, notes, and snippets.

View gtklocker's full-sized avatar

Kostis Karantias gtklocker

View GitHub Profile
#!/usr/bin/env python3
import subprocess
if __name__ == "__main__":
current_branch = subprocess.check_output(["git", "branch", "--show-current"]).rstrip()
if not current_branch:
raise Exception("need to be checked out to a named git branch")
merged_branches_with_upstream = subprocess.check_output(
["git", "branch", "--format", "%(refname:short) %(upstream:short)", "--merged"]
@gtklocker
gtklocker / .vimrc
Created December 2, 2020 19:23
Emergency .vimrc
set ignorecase smartcase
set autoindent smartindent
set gdefault hlsearch incsearch showmatch
set expandtab softtabstop=4 shiftwidth=4
syntax on
set laststatus=2
set ruler
set nobackup noswapfile noundofile
set cursorline
@gtklocker
gtklocker / brew-zap
Created May 9, 2020 21:18
Recursively remove homebrew packages
#!/bin/zsh
set -euo pipefail
local preall=$(brew list -1)
local predeps=$(brew deps --installed)
local preleaves=$(brew leaves)
recur() {
local pkg=$1
@gtklocker
gtklocker / notes-on-truffle-testing.md
Created January 10, 2019 20:01
Notes on Truffle testing
  • Error: VM Exception while processing transaction: revert -> make sure you've set uint public initialBalance = 10 ether;
@gtklocker
gtklocker / Makefile
Created December 10, 2018 10:41
Sane Makefile for LaTeX targets
.PHONY: all clean
all: $(patsubst %.tex, %.pdf, $(wildcard *.tex))
%.pdf: %.tex
latexrun $<
%.tex: preamble.sty
clean:
rm -rf *.log *.aux *.out *.pdf *.bbl *.blg
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.38308101892471313</real>
@gtklocker
gtklocker / bcash-tx-watcher.js
Created September 21, 2018 20:41
Watch for a Bitcoin Cash transaction (new or historical) using bcash
'use strict';
const bcash = require('bcash').set('testnet');
const Logger = require('blgr');
//const logger = new Logger({ level: 'info' });
// SPV chains only store the chain headers.
const chain = new bcash.Chain({
memory: false,
@gtklocker
gtklocker / steps-to-weird-behavior-on-bcoin.md
Created July 30, 2018 11:09
Steps to get a tx to show as both confirmed and unconfirmed on bcoin

steps:

  • npm install (-g) bclient which provides bwallet-cli
  • make sure your ~/.bcoin/wallet.conf contains network: testnet
  • run an spv node on btc testnet (bcoin --network testnet --spv, or you could spawn one programmatically)
  • wait until it’s fully synced
  • get the receive address of the “default” account (bwallet-cli account get default)
  • send some btc testnet from a faucet to that address
  • bwallet-cli balance should immediately show some unconfirmed amount
  • wait until the tx gets 1 conf, now the amount that was previously unconfirmed should show both as confirmed and unconfirmed
@gtklocker
gtklocker / gist:e34924546438fbea1e678df0b9ea277b
Created April 20, 2018 15:10
git ignore vim files everywhere
wget https://github.com/github/gitignore/raw/master/Global/Vim.gitignore -O ~/.gitignore.global && git config --global core.excludesfile ~/.gitignore.global
@gtklocker
gtklocker / delos-scraper.pl
Last active January 12, 2018 20:38
delos.uoi.gr scraper
#!/usr/bin/perl
# Last tested: 2017-01-22
use strict;
use warnings;
my $lesson_id = $ARGV[0];
for (my $page_id = 1; ; ++$page_id) {
my $url = "http://delos.uoi.gr/opendelos/search?crs=$lesson_id&sa=$page_id";
my $page = qx{curl --silent "$url"};