Skip to content

Instantly share code, notes, and snippets.

View arvenil's full-sized avatar
💻
Looking for project

Kamil Dziedzic arvenil

💻
Looking for project
View GitHub Profile
@arvenil
arvenil / port.go
Created September 3, 2021 12:23
port.go
View port.go
// Package port allows to obtain a free port that is ready to use.
package port
import (
"net"
"emperror.dev/errors"
)
// New returns a free open port that is ready to use.
@arvenil
arvenil / skip-locked-with-partitions.md
Last active August 15, 2023 14:14
SKIP LOCKED with partitioned table
View skip-locked-with-partitions.md

Create data table and partition it by state

CREATE TABLE data (
   id bigserial not null,
   state smallint not null DEFAULT 1,
   updated_at timestamp without time zone default now()
) partition by list(state);
create table data_pending partition of data for values in (1);
create table data_processing partition of data for values in (2);
View keybase.md

Keybase proof

I hereby claim:

  • I am arvenil on github.
  • I am arvenil (https://keybase.io/arvenil) on keybase.
  • I have a public key whose fingerprint is 6219 08B1 B833 37F3 C040 BB32 9B2A 8BE3 2C07 EA6C

To claim this, I am signing this object:

@arvenil
arvenil / BlockPropagation.md
Created December 21, 2016 18:03 — forked from gavinandresen/BlockPropagation.md
O(1) block propagation
View BlockPropagation.md

O(1) Block Propagation

The problem

Bitcoin miners want their newly-found blocks to propagate across the network as quickly as possible, because every millisecond of delay increases the chances that another block, found at about the same time, wins the "block race."

@arvenil
arvenil / michal_gorski.sh
Created September 3, 2014 16:10
Recommendation: Michał Górski
View michal_gorski.sh
$ /usr/bin/michal_gorski.sh --help
"Michał Górski is an ambitious developer who isn't scared by any work.
Just provide him with some challenges and watch how magic happens.
You will be impressed how quick, creative and thoughtful this person is."
Usage:
--do-awesome=<work_to_be_done> Do work and provide awesome results
--do-crap=<work_to_be_done> Do work and provide crappy results
--help Read about the only developer you need
@arvenil
arvenil / vercmps.sh
Last active August 29, 2015 14:04 — forked from livibetter/vercmp.sh
Fix for "08: value too great for base", works for versions with numbers only (no letters, no rc suffixes)
View vercmps.sh
#!/bin/bash
# Copyright (c) 2012 Yu-Jie Lin
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
View gist:a1d273f5287ce8e1f4df
<?php
// Let's create /tmp/ninja-lock1.txt ...
$fp0 = fopen('/tmp/ninja-lock1.txt', 'c');
// ... and close it imiedietly
fclose($fp0);
// File handler $fp0 was closed so flock()
// is unable to use it to gain lock.
// It will fail with wouldblock set to 0
// as it doesn't make sense to wait on unusable file handle.