Skip to content

Instantly share code, notes, and snippets.

View adisbladis's full-sized avatar
:shipit:
^ This guy

adisbladis

:shipit:
^ This guy
View GitHub Profile
@adisbladis
adisbladis / nix-path.py
Created April 10, 2019 19:52
Add derivations to PATH at runtime from python
#!/usr/bin/env python
#
# Add binaries to PATH at runtime
import subprocess
import nix
import os
def realise_path(store_path: str):
@adisbladis
adisbladis / shell.nix
Created October 28, 2018 21:52
Dirty nixpkgs python
with import <nixpkgs> {};
mkShell {
buildInputs = [
(python3.withPackages(ps: [
ps.nixpkgs
]))
];
}
with import <nixpkgs> { };
let
cutPoints = builtins.map (drv: drv.outPath) [
nodejs
python2
python3
coreutils
openssl.out
glibc
@adisbladis
adisbladis / default.nix
Created September 22, 2018 15:50
An example of how to set up a custom emacs with packages from nixpkgs
with import <nixpkgs> {};
let
# An example of how to get xwidgets rather than gtk
# overridenEmacs = emacs26.override { withXwidgets = true; };
overridenEmacs = emacs26;
emacsPkgs = pkgs.emacsPackagesNgGen overridenEmacs;
emacsWithPackages = emacsPkgs.emacsWithPackages;
in emacsWithPackages(epkgs: with epkgs; [
@adisbladis
adisbladis / .direnvrc
Created June 6, 2018 09:44
direnvrc nix cache
use_nix() {
local shell_file=$(test -f shell.nix && echo shell.nix || echo default.nix)
local cache_key=$(nix-instantiate "$shell_file" 2> /dev/null | shasum -a 1 | cut -d ' ' -f 1)
# Use ram as virtualenv storage
local tmpdir
case $(uname -s) in
Linux*) tmpdir=$XDG_RUNTIME_DIR;;
Darwin*) tmpdir_SDK=$TMPDIR;;
*) tmpdir=/tmp
@adisbladis
adisbladis / .envrc
Created June 18, 2018 08:14
Minimal example nix project with direnv
use nix
@adisbladis
adisbladis / shell.nix
Created June 12, 2018 08:44
Build android applications from nix-shell without FHS env
with (import <nixpkgs> {});
let
# Extract license from a Linux box
# It's in ~/Android/Sdk/licenses/android-sdk-license
sdkLicense = "d56f5187479451eabf01fb78af6dfcb131a6481e";
in pkgs.mkShell {
buildInputs = with pkgs; [
@adisbladis
adisbladis / para.py
Created June 8, 2018 02:29
Paramiko example with proper stderr/stdout behaviour
import contextlib
import functools
import paramiko
import select
import sys
import os
if __name__ == '__main__':
@adisbladis
adisbladis / findprocs.js
Created April 30, 2018 09:56
Finding child processes recursive in nodejs without external dependencies
#!/usr/bin/env node
const ChildProcess = require('child_process')
function findChildren(pid) {
const pgrep = ChildProcess.spawnSync('pgrep', ['-P', pid])
// Probably segfault..
// Happens on linux at least when there is no child
if(pgrep.status === null) {
In this moment of year NixPkgs already close to half of the umber of commits from previous year.
commits=12747/26374=0.483
velocity_last_year=26374/365=72.258 commits/day
velocity_this_time=12747/109=116.945 commits/day
velocity_times=velocity_this_year/velocity_last_year=1.618 times
accel=(velocity_this_time-velocity_last_year)/current_day=0.410 commits/day^2
velocity_end_of_year_extrapolated=velocity_last_year+365*accel=221.899 commits/day