Skip to content

Instantly share code, notes, and snippets.

View danbst's full-sized avatar

Danylo Hlynskyi danbst

  • Ivano-Frankivsk, Ukraine
View GitHub Profile
@danbst
danbst / swap.js
Created November 5, 2020 14:10
draw swap/rotation animation using p5.js
var figures = [];
var size = 50;
var margin = 1.5;
var postprocessed = false;
var centerX = 0;
let names = ["a", "b", "c", "d", "e", "f"];
function addFigure(col) {
figures.push([figures.length * size * margin, 0, col]);
}
@danbst
danbst / fire.py
Last active November 11, 2021 22:15
FIRE retro x80 Python numpy FTW
import pygame
import random
import colorsys
import numpy as np
from pygame import surfarray
def color_HSL(h, s, l):
color = colorsys.hls_to_rgb(h/255, l/255, s/255)
return tuple( int(x*255) for x in color )
@danbst
danbst / README.md
Created May 24, 2020 11:14
monkey ZNO simulation

Results:

Cumulative distribution method (2019, by Taras Pavlov): 0.08891278153876137                                                                                                                                          
Simulation method (2019): 0.09003                                                                                                                                                                                    
Total simulation method (2019): 0.09858                                                                                                                                                                              
Total simulation method (2020): 0.04539                                                                                                                                                                              
# all users, key is chat.id
user_settings = {}
# user chat settings
class UserChat:
timers = {} # all timers. Key is timer ID, defined arbitrary
state = None
id = None # chat.id
def tick(self, current_time):
@danbst
danbst / gen.py
Created March 20, 2020 16:40
str gen
def generate_users_str(db, config, with_orders=False, with_ids=False):
all_s = []
total_orders = 0
if with_orders:
for user in db:
id_prefix = f"{user['telegram_id']} - " if with_ids else ""
is_ordered = user.get('order_food', config['DEFAULT_ORDER'])
if is_ordered:
total_orders += 1
@danbst
danbst / home-etc.nix
Created December 27, 2019 15:17
Manage your /etc from home-manager (install home-manager as root)
{ 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 = {

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 September 5, 2019 20:14
Pure Nix Minecraft launcher. For every MC version!

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)!

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 October 22, 2023 12:06
[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