Skip to content

Instantly share code, notes, and snippets.

Danylo Hlynskyi danbst

Block or report user

Report or block danbst

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View asciidoc.adoc

Hey let’s start a list:

  1. Yeah, all good.

    a bit of code.
    Oh wow, it is indented compared to markdown!

    A bit of text. Wow, it is indeted as well!



Our database has fast rate of transactions. I did think, that such rate is impossible, until I've seen it with my eyes. I've been instinctively insisting on fixing code to reduce number of transactions (sometimes successful), but never checked what are consequences for database.

One of consequences is fast rate of autovacuum VACUUM FREEZE.

VACUUM is essential for Postgresql to mark non-visible rows (those which were normal rows, but became invisible because of update or delete) as visible to PG. Note, that they become visible only to PG, previously PG didn't know they are free for use, and thus had allocated extra buffers in the end of a table for any new rows (inserts or updates). PG not knowing which rows are free for use is another problem, which causes table bloat, which deserves another post.

VACUUM FREEZE is special kind of VACUUM. From resource usage perspective, it differs from VACUUM by that it has to scan full table (normal VACUUM processes only buffers known to contain at


Switching NixOS architecture (32bit -> 64bit)

There are rumors, that you can switch from system architecture just adding 1 configuration option:

nixpkgs.system = "x86_64-linux"

and running nixos-rebuild boot && reboot.

danbst / iphone.nix
Created Sep 8, 2018
iPhone pairing for NixOS
View iphone.nix
# First add this module to your /etc/nixos/configuration.nix
# ...
# imports = [ /path/to/iphone.nix ];
# iphone.enable = true;
# iphone.user = "yourusername";
# ...
# Then rebuild system. Attach iPhone via cable, open terminal and run command `iphone`
# It will fail, but there will occure a dialog on your iPhone to "trust this computer"
# Press OK there and run `iphone` again. If it succeeds it will open a freshly mounted folder
danbst /
Last active Jun 19, 2019
[Linux] [Firefox] Open link in browser, which is in current workspace

I use separate Firefox profiles for work and personal stuff. To distinguish those I place them on different workspaces.

  • Workspace 0: firefox --no-remote -P MyJob
  • Workspace 1: firefox --no-remote -P default

I have also company Slack on Workspace 0. Which usually contains links to some work stuff.

The problem

danbst /
Last active Jun 17, 2019
Old Firefox with latest Java plugin. For the upcoming in August Java plugin deprecation in Firefox

What is this for

Firefox and Oracle deprecated Java plugin. But some online banking systems rely on that plugin very much. Soon the only solution would be to use old browser version.

Here I try to solve the yet-to-come problem using Nix.

  1. I do use an old firefox-esr from 18.03 NixOS release (52.9.0esr as of writing)
  2. However Java plugin is used from bleeding edge nixpkgs-usntable
  3. Oracle makes some complications for automated JDK fetchers, but we overcome them with some hacky curl | sh from some random script in Internet. We accept Oracle license by using Oracle JDK
  4. But thanks to Nix build environment, that curl | sh hardly can harm our system,
danbst / uuid-bloom.sql
Created Apr 27, 2019
Postgresql UUID Bloom index support (best for UUIDv4) (
View uuid-bloom.sql
create extension "uuid-ossp";
create extension bloom;
CREATE or replace FUNCTION hashuuid(u uuid) RETURNS integer AS $$
a bytea := uuid_send(u);
RETURN (get_byte(a, 3) << 24) + (get_byte(a, 2) << 16) + (get_byte(a, 1) << 8) + get_byte(a, 0);
danbst / background-script.js
Created Mar 30, 2019
Firefox extension, which tracks time spent in Facebook and tells it to you INSTANTLY.
View background-script.js
timeSpent = 0;
timeStarts = 0
browser.tabs.onActivated.addListener((activeInfo) => {
{timeSpent: timeSpent}
).then(response => {
timeStarts = (new Date).getTime();
}).catch(error => {
View submodule-with-parent-config.nix
sub = { config, lib, parentConfig, ...}: { = lib.mkOption {
type = lib.types.bool;
default =;
in { config, lib, ...}: { = lib.mkOption { type = lib.types.bool; default = true; };
danbst /
Last active Mar 5, 2019
Imperative nix-env rewrite (so it becomes declarative)
#!/usr/bin/env bash
mkdir -p $(dirname "$statefile")
touch "$statefile"
function update {
You can’t perform that action at this time.