Skip to content

Instantly share code, notes, and snippets.

View offlinehacker's full-sized avatar
🤓
deploying awesomeness

Jaka Hudoklin offlinehacker

🤓
deploying awesomeness
View GitHub Profile
@offlinehacker
offlinehacker / distributed-master.nix
Last active January 10, 2020 21:14
Distributed nix builds
{ config, pkgs, ... }: {
services.nfs.server.enable = true;
services.nfs.server.exports = ''
/exports/nix 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,hide,fsid=0)
/exports/nix/store 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,fsid=1)
'';
services.nfs.server.createMountPoints = true;
programs.ssh.extraConfig = ''
Port 64123
@offlinehacker
offlinehacker / gist:33e8b545d2812cf06932
Last active August 29, 2015 14:04
Test implementation for new nix wheels
import json
import sys
from pip.index import PackageFinder
from pip.req import parse_requirements
def generate_dependencies(requirements_txt):
results = {}
path=$(nix-collect-garbage -d 2>&1 | grep error: | awk -F"\`" '{print $2}' | awk -F"\'" '{print $1}')
echo $path
until [ $path = */nix/store* ]; do
sqlite3 /nix/var/nix/db/db.sqlite "DELETE FROM ValidPaths WHERE path='$path'"
nix-store --delete $path
path=$(nix-collect-garbage -d 2>&1 | grep error: | awk -F"\`" '{print $2}' | awk -F"\'" '{print $1}')
echo $path
done
@offlinehacker
offlinehacker / mysh.c
Last active August 29, 2015 14:02
My shell
/* Compile with: g++ -Wall –Werror -o shell shell.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>
#include <dirent.h>
{
"*": {
"setuptools": {"append_deps": ["pytest[test]"]},
"sqlalchemy": {"append_deps": ["pysqlite[test]"], "spec": "sqlalchemy==0.8.5"},
"sqlalchemy-imageattach": {
"src": "https://github.com/crosspop/sqlalchemy-imageattach/archive/{{spec.pinned}}.tar.gz#egg=sqlalchemy-imageattach-{{spec.pinned}}",
"append_deps": ["pysqlite[test]"]
},
"alembic": {"append_deps": ["pysqlite[test]"]}
}
VERSION=1.6.1
ARCH=`uname -m`
ARCH_SYS=`uname -s | tr "[A-Z]" "[a-z]"`
if [[ "$ARCH" = "i386" ]]
then
ARCH = "i686"
fi
WORK_DIR=`pwd`
/* This file defines the builds that constitute the Nixpkgs.
Everything defined here ends up in the Nixpkgs channel. Individual
jobs can be tested by running:
$ nix-build pkgs/top-level/release.nix -A <jobname>.<system>
e.g.
$ nix-build pkgs/top-level/release.nix -A coreutils.x86_64-linux
*/
class overridable_property(property):
"""
Property where you can override return value by setting _name
>>> class test(object):
... @overridable_property
... def test(self):
... return "abcd"
...
>>> a = test()
@offlinehacker
offlinehacker / divide.py
Last active March 19, 2022 19:04
Devides list in all posible sublists, without repetitions
from itertools import combinations
def divide(l, p={}):
for v in (j for i in xrange(1, len(l) + 1) for j in combinations(l, i)):
r = tuple(set(l) - set(v))
for s in devide(r):
t = (v,) + (s if s else tuple())
if frozenset(t) in p: continue
else: yield t; p[frozenset(t)] = True
@offlinehacker
offlinehacker / mergewithbase.py
Last active January 8, 2022 18:21
Merges result of function or attribute from child class with result of function or attribute from the base class.
class merge_with_base(object):
"""
Merges result of function or attribute from child class with result of
function or attribute from the base class.
:param type: Use this base class instead of first base class found and
not with mixins
.. note::