Skip to content

Instantly share code, notes, and snippets.

@glittershark
glittershark / orjson.nix
Created March 28, 2020 18:46
Horrible, hacky packaging of orjson with Nix
{ fetchFromGitHub
, python
, maturin
, arrow
, dataclasses
, numpy
, pendulum
, psutil
, pytest
, pytz
@sebastien
sebastien / nix-fishgen.py
Last active May 31, 2021 02:52
Python script that converts Nix's profile bash script to Fish
#!/usr/bin/env python3
# Updated: 2018-10-17
import re, sys, os
"""
Converts the Nix profile SH script to a Fish-compatible profile using a
simple line-by-line replace algorithm.
"""
@globin
globin / configuration.nix
Last active March 1, 2024 00:46
prometheus on nixos
{ pkgs, lib, config, ... }:
{
networking = {
firewall.allowedTCPPorts = [
3000 # grafana
9090 # prometheus
9093 # alertmanager
];
useDHCP = true;
};
@nvictus
nvictus / loadnpy.js
Last active November 4, 2023 18:47
NumPy binary file parser for javascript
// Client-side parser for .npy files
// See the specification: http://docs.scipy.org/doc/numpy-dev/neps/npy-format.html
var NumpyLoader = (function () {
function asciiDecode(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
}
function readUint16LE(buffer) {
var view = new DataView(buffer);
var val = view.getUint8(0);
@bryder
bryder / py.test_tmpdir_usage
Last active April 27, 2021 13:23
How to use py.test tmpdir
# https://pytest.org/latest/tmpdir.html
# http://py.readthedocs.org/en/latest/path.html
# Using in conftest.py
@pytest.fixture(autouse=True)
def a_tmp_filename(tmpdir):
p = tmpdir.join("filename")
p.write("some stuff\n")
return str(p) # str(p) returns the full pathname you can use with normal modules