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
@danbst
danbst / home-etc.nix
Created Dec 27, 2019
Manage your /etc from home-manager (install home-manager as root)
View home-etc.nix
{ config, pkgs, lib, ... }: {
imports = [
(import <nixpkgs/nixos/modules/system/etc/etc.nix>)
];
options.system.build.etc = lib.mkOption { type = lib.types.package; };
options.system.activationScripts.etc =
lib.mkOption { type = lib.types.unspecified; };
config = {
View nix-remote-build.md

Okay, I've got a need to build Firefox from source, and I'd like to do that on a remote machine, and then copy build result back to my laptop. With Nix, using bastion host. I'll note details of my successful adventure.

Setup & Sources of knowledge

Here's the list of resources I've used actively:

Here's my setup:

@danbst
danbst / README.adoc
Created Sep 5, 2019
Pure Nix Minecraft launcher. For every MC version!
View README.adoc

Pure Nix Minecraft launchers

  1. Download .nix file

  2. Run:

    $ nix run -f all-minecrafts.nix versions.v1_8_9.client -c minecraft
  3. Enjoy (…​power of fixed-output derivations)!

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!

@danbst
danbst / README.md
Last active Jun 19, 2019
[Linux] [Firefox] Open link in browser, which is in current workspace
View README.md

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
danbst / uuid-bloom.sql
Created Apr 27, 2019
Postgresql UUID Bloom index support (best for UUIDv4) (https://www.postgresql.org/docs/current/bloom.html)
View uuid-bloom.sql
create extension "uuid-ossp";
-- https://www.postgresql.org/docs/current/bloom.html
create extension bloom;
CREATE or replace FUNCTION hashuuid(u uuid) RETURNS integer AS $$
DECLARE
a bytea := uuid_send(u);
BEGIN
RETURN (get_byte(a, 3) << 24) + (get_byte(a, 2) << 16) + (get_byte(a, 1) << 8) + get_byte(a, 0);
END;
@danbst
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) => {
browser.tabs.sendMessage(
activeInfo.tabId,
{timeSpent: timeSpent}
).then(response => {
timeStarts = (new Date).getTime();
}).catch(error => {
View submodule-with-parent-config.nix
let
sub = { config, lib, parentConfig, ...}: {
options.foo = lib.mkOption {
type = lib.types.bool;
default = parentConfig.bar;
};
};
in { config, lib, ...}: {
options.bar = lib.mkOption { type = lib.types.bool; default = true; };
@danbst
danbst / all-packages.nix
Created Jan 19, 2019
Overlays in nixpkgs!
View all-packages.nix
...
inherit (import ../servers/sql/postgresql-default.nix pkgs super)
postgresql
postgresqlPackages
postgresql_9_4
postgresql_9_5
postgresql_9_6
postgresql_10
postgresql_11
@danbst
danbst / idea.md
Last active Jan 17, 2019
Nixos need a replacement for nixos-rebuild!
View idea.md

nixos executable

Basic features:

  • installable as package, even on non-nixos
  • is named nixos
  • is written in C++ and binds to Nix C++ library (or maybe Haskell? Nodejs? What you think?)
  • autocomplete, ncurses, Nix 2.0
  • commit to Git by default on each rebuild

Subcommands

You can’t perform that action at this time.