Skip to content

Instantly share code, notes, and snippets.

View kristapsk's full-sized avatar

Kristaps Kaupe kristapsk

View GitHub Profile
@kristapsk
kristapsk / accesslog2csv.py
Last active March 22, 2023 19:24 — forked from joswr1ght/accesslog2csv.py
Convert Apache/Nginx Unified Log Format to CSV
#!/usr/bin/env python3
# accesslog2csv: Convert default, unified access log from Apache, Nginx
# servers to CSV format.
#
# Original source by Maja Kraljic, July 18, 2017
# Modified by Joshua Wright to parse all elements in the HTTP request as
# different columns, December 16, 2019
# Modified by Kristaps Kaupe to support (ignore) additional fields at the end and also added shebang at March 2023
#!/usr/bin/env bash
lockdir=/tmp/satsale.lock
if mkdir "$lockdir" 2> /dev/null ; then
trap 'rm -rf "$lockdir"' 0
trap "exit 2" 1 2 3 15
else
exit 0
fi
Utxos are grouped by address type (P2PKH, P2SH-P2WPKH, or P2WPKH).
The group with the same address type as the address being spent to is selected if it is >= twice the spend amount.
If the above condition is not met, then a group with a different address type and a total value >= twice the spend amount is selected.
If the above condition is not met, then 2 groups with total amounts >= the spend amount are chosen.
Transaction composition is arranged by “sets”.
For each set:
The utxos are processed in randomised order.
#!/usr/bin/env bash
while :; do
lightning-cli listpeers | jq -r ".peers[].id" | while read node_id; do
if [[ $((RANDOM % 2)) != 0 ]]; then
echo "Pinging $node_id"
lightning-cli ping $node_id $((RANDOM % 65530)) $((RANDOM % 65530))
fi
done
echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] sleeping..."
@kristapsk
kristapsk / odroid-hc4-raspibolt-notes.md
Last active December 2, 2021 00:58
Odroid HC4 RaspiBolt installation notes

Odroid HC4 RaspiBolt installation notes

Upgrading

Upgrading kernel will make it unbootable.

# apt update
# apt-mark hold linux-odroid-c4
linux-odroid-c4 set on hold.

Keybase proof

I hereby claim:

  • I am kristapsk on github.
  • I am kristapsk (https://keybase.io/kristapsk) on keybase.
  • I have a public key ASBHmqoD_9bKZ-aOHjBP4NPx_q1EtPBCbxvBWUmDSK-9sgo

To claim this, I am signing this object:

<?php
$algo = 'sha512';
$algo_iter = 100;
$rand = ord(openssl_random_pseudo_bytes(1));
$pass = 'password';
$salt = openssl_random_pseudo_bytes(16);
$salt_hex = bin2hex($salt);
$finished = false;
$val = hash($algo, hash($algo, $pass) . $salt);
for ($i = 0; $i <= 255; $i++) {
@kristapsk
kristapsk / hhvm-fullUrl.patch
Created November 23, 2016 16:19
HHVM fullUrl patch for ServerStats
diff --git a/hphp/runtime/server/http-request-handler.cpp b/hphp/runtime/server/http-request-handler.cpp
index 4b5c3f4..8369e8e 100644
--- a/hphp/runtime/server/http-request-handler.cpp
+++ b/hphp/runtime/server/http-request-handler.cpp
@@ -180,8 +180,7 @@ void HttpRequestHandler::handleRequest(Transport *transport) {
}
}
- ServerStats::StartRequest(transport->getCommand().c_str(),
- transport->getRemoteHost(),
diff --git a/hphp/runtime/ext/mysql/mysql_common.cpp b/hphp/runtime/ext/mysql/mysql_common.cpp
index 4ab1d17..a4947b0 100644
--- a/hphp/runtime/ext/mysql/mysql_common.cpp
+++ b/hphp/runtime/ext/mysql/mysql_common.cpp
@@ -48,7 +48,7 @@
#include "hphp/runtime/ext/std/ext_std_network.h"
#include "hphp/runtime/server/server-stats.h"
-#include "hphp/runtime/ext/async_mysql/ext_async_mysql.h"
+//#include "hphp/runtime/ext/async_mysql/ext_async_mysql.h"
@kristapsk
kristapsk / date_loop.sh
Created March 14, 2016 14:45
Bash date loop
#! /bin/bash
date_start="2015-01-01"
date_end="2015-12-31"
date_start_unixtime="`date --date="$date_start" +"%s"`"
date_end_unixtime="`date --date="$date_end" +"%s"`"
date_current=$date_start
date_current_unixtime=$date_start_unixtime