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 / bash-curl-pup-jq-notifysend-nix.md
Created Jul 19, 2018
Bash. Curl. Pup. Jq. Notify-send. Nix
View bash-curl-pup-jq-notifysend-nix.md

Цей список складений з технологій (утиліт Linux), які я використаю для однієї життєвої ситуації - пошуку аренди квартири по риночній ціні.

Знайомим з поняттям "скрейпінг" мабуть уже зрозуміло, про що буде пост. Тим не менше, запрошую під кат.

Постановка задачі

OLX є, здається, найактивнішою площадкою для пошуку аренди квартири у Києві. Але просто зайти на OLX, задати фільтри (район, кількість кімнат) недостатньо. Справа в тім, що є 3 типи аренд:

  • аренди від ріелторів - ціни на ці квартири майже завжди завищені, тому-що від ціни квартири залежить дохід ріелтора. Через завищену вартість (неринкову) афіші висять відносно довго
  • аренди від хазяїв - ціни на квартири нижчі, щоб швидше знаходити арендаторів
@danbst
danbst / default.nix
Created Jul 13, 2018
Proof-of-Concept running PostgreSQL tests inside Nix package build
View default.nix
with import <nixpkgs> { };
runCommand "some-test" {
buildInputs = [ postgresql ];
preCheck = ''
set -e
export PGDATA=$TMP/db
export PGHOST=$TMP/socketdir
mkdir $PGDATA $PGHOST
pg_ctl initdb
echo "unix_socket_directories = '$PGHOST'" >> $PGDATA/postgresql.conf
View nixos-infect.sh
#! /usr/bin/env bash
# More info at: https://github.com/elitak/nixos-infect
set -o pipefail
set -e
makeConf() {
# Skip everything if main config already present
[[ -e /etc/nixos/configuration.nix ]] && return 0
# NB <<"EOF" quotes / $ ` in heredocs, <<EOF does not
@danbst
danbst / README.md
Last active Jun 17, 2019
Old Firefox with latest Java plugin. For the upcoming in August Java plugin deprecation in Firefox
View README.md

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,
View prefetch-github.sh
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p gitMinimal nix-prefetch-git jq
set -e
project="$1"
branch="${2:-master}"
owner=$(echo "$project" | cut -d/ -f1)
repo=$(echo "$project" | cut -d/ -f2)
rev=$(git ls-remote "git://github.com/$project.git" "$branch" | head -n1 | awk '{print $1}')
rev=${rev:-$2}
@danbst
danbst / default.nix
Created Mar 27, 2018
Nix + Python + nanomsg
View default.nix
####################################################################################
# Nix shell for nix-powered environments
# This is like `virtualenv`, but with fine-defined system dependencies
####################################################################################
rec {
nanomsg-py = pythonPackages.buildPythonPackage {
name = "nanomsg-1.0";
src = pkgs.fetchurl { url = "https://pypi.python.org/packages/0b/b1/3037e0e380d5fab2824e69a59bd374da402c0cef264ccb3fe5d71c230c4b/nanomsg-1.0.tar.gz"; sha256 = "843be41258219d9d319cf434a68cac7669834ab9c993ea4bab5b3d87f62a7a13"; };
doCheck = false;
buildInputs = [ pkgs.nanomsg ];
@danbst
danbst / README.md
Last active Dec 5, 2018
nixq - jq but with Nix syntax
View README.md

nixq - jq but with Nix syntax

Familliar syntax and all of <nixpkgs/lib> and builtins in your hands.

Now going through jq tutorial:

Identity filter

$ # jq
@danbst
danbst / nixeval.md
Last active Nov 8, 2017
Is there simpler way to extract string from Nix string?
View nixeval.md
function nixeval { eval echo -en "$(nix-instantiate --eval --strict "$@" | sed 's/${/\\${/g')"; }

Evaluate Nix expression and remove quotes from resulting expresssion:

$ nixeval -E 'builtins.toJSON __nixPath' | jq
[             
  {
@danbst
danbst / 0_reuse_code.js
Created Aug 2, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View switch-NixOS-32bit-to-64bit.md

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.

You can’t perform that action at this time.