Skip to content

Instantly share code, notes, and snippets.

View heri16's full-sized avatar

Heri Sim heri16

View GitHub Profile
@ynaoto
ynaoto / gist:5228280
Last active June 21, 2017 07:23
Install 'mosh' to CentOS 6
rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install mosh –enablerepo=epel
@revskill10
revskill10 / accounting.sql
Last active April 15, 2022 02:31 — forked from 001101/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL,
parent_id INTEGER REFERENCES section,
parent_path LTREE
);
CREATE INDEX account_parent_path_idx ON accounts USING GIST (parent_path);
CREATE INDEX account_parent_id_idx ON accounts (parent_id);
@anselmobattisti
anselmobattisti / gstreamer_webcam_to_udp
Created September 7, 2019 16:02
Capture webcam video and stream it using gstreamer
Capture and send video
gst-launch-1.0 v4l2src device=/dev/video0 \
! decodebin \
! x264enc \
! rtph264pay \
! udpsink port=5000
Show the video
gst-launch-1.0 \
@kassane
kassane / client.cpp
Last active February 26, 2023 06:53
Draft C++ wrapper to TigerBeetle database
#include "tb_client.hpp"
int main() {
tb::Client client("localhost", 8080);
tb::Account account({0, 0, {0}, 1, 1, TB_ACCOUNT_LINKED, 0, 0, 0, 0, 0});
tb::create_account_result result = client.create_account(account);
if (result != TB_CREATE_ACCOUNT_OK) {
// Handle error
}
@anacrolix
anacrolix / striter.py
Created September 26, 2012 14:35
A Python IO class wrapping an iterable of strings.
import io
class StringIteratorIO(io.TextIOBase):
def __init__(self, iter):
self._iter = iter
self._left = ''
def readable(self):
return True
@EkremGungormez
EkremGungormez / gist:2724210
Created May 18, 2012 09:17
abap inner join example
TABLES: MKPF,
MSEG.
DATA: BEGIN OF gs_ara,
mblnr type mkpf-mblnr,
mjahr TYPE mkpf-mjahr,
budat TYPE mkpf-budat,
tcode2 TYPE mkpf-tcode2,
usnam TYPE mkpf-usnam,
cpudt TYPE mkpf-cpudt,

Non-custodial lightning escrow for HodlHodl

phase 1: bitcoin funding

  1. seller generates secret A
  2. seller asks hodlhodl to generate a hold invoice with payment hash = hash(A), notice that hodlhodl doesn’t have the preimage A
  3. seller sends a lightning payment to settle the invoice
  4. once hodlhodl receives the payment, it remains on hold since it doesn’t have the preimage A to settle it
  5. hodlhodl lets the seller know it received the payment, so that it can proceed

phase 2: fiat payment

@idavis
idavis / Use-Impersonation.ps1
Created March 5, 2011 18:52
Impersonate a user and execute a script block as that user
param( [ScriptBlock] $scriptBlock )
<#
.SYNOPSIS
Impersonates a user and executes a script block as that user. This is an interactive script
and a window will open in order to securely capture credentials.
.EXAMPLE
Use-Impersonation.ps1 {Get-ChildItem 'C:\' | Foreach { Write-Host $_.Name }}
This writes the contents of 'C:\' impersonating the user that is entered.
#>
@t-bast
t-bast / phoenix-splicing.md
Created May 12, 2021 17:21
Phoenix in a splicing future (a.k.a death to all swaps)

Phoenix in a splicing future (a.k.a death to all swaps)

Phoenix implements trusted swaps for users' convenience (to allow easy onboarding and offboarding). But it's not a satisfying solution for the following reasons:

  • It uses two on-chain transactions for swap-in where one should be sufficient (one transaction from the user to Acinq followed by a channel open)
  • Swap-out feerates are unpredictable (because we may fund the swap-out with unconfirmed previous outputs) which is frustrating for users
  • It forces Acinq to use its own utxos, which doesn't scale well and is an operational burden
  • If Acinq doesn't have any utxos available and the mempool is completely full, swaps are stuck which is also frustrating for users