Skip to content

Instantly share code, notes, and snippets.

View rehno-lindeque's full-sized avatar

Rehno Lindeque rehno-lindeque

View GitHub Profile
@davidbau
davidbau / runningstats.py
Last active June 10, 2024 21:43
Running stats objects for pytorch: mean, variance, covariance, second-moment, quantiles, topk, and combinations.
'''
To use a runningstats object,
1. Create the the desired stat object, e.g., `m = Mean()`
2. Feed it batches via the add method, e.g., `m.add(batch)`
3. Repeat step 2 any number of times.
4. Read out the statistic of interest, e.g., `m.mean()`
Built-in runningstats objects include:
@edolstra
edolstra / nix-lang.md
Last active July 16, 2024 02:12
Nix language changes

This document contains some ideas for additions to the Nix language.

Motivation

The Nix package manager, Nixpkgs and NixOS currently have several problems:

  • Poor discoverability of package options. Package functions have function arguments like enableFoo, but there is no way for the Nix UI to discover them, let alone to provide programmatic ways to
@kspeakman
kspeakman / FileUtils.elm
Last active November 14, 2017 21:13
Elm file uploads as simple as I could make them
module FileUtils exposing (..)
import Native.FileUtils
import Html exposing (..)
import Html.Events exposing (..)
import Http exposing (Body)
import Json.Decode as Json
type alias File =
@jatcwang
jatcwang / gist:ae3b7019f219b8cdc6798329108c9aee
Created February 2, 2017 23:44
List of all setxkbmap configuration options (including models/layout/etc)
! model
pc101 Generic 101-key PC
pc102 Generic 102-key (Intl) PC
pc104 Generic 104-key PC
pc105 Generic 105-key (Intl) PC
dell101 Dell 101-key PC
latitude Dell Latitude series laptop
dellm65 Dell Precision M65
everex Everex STEPnote
flexpro Keytronic FlexPro
@roadrunner2
roadrunner2 / 0 Linux-On-MBP-Late-2016.md
Last active July 12, 2024 19:23
Linux on MacBook Pro Late 2016 and Mid 2017 (with Touchbar)

Introduction

This is about documenting getting Linux running on the late 2016 and mid 2017 MPB's; the focus is mostly on the MacBookPro13,3 and MacBookPro14,3 (15inch models), but I try to make it relevant and provide information for MacBookPro13,1, MacBookPro13,2, MacBookPro14,1, and MacBookPro14,2 (13inch models) too. I'm currently using Fedora 27, but most the things should be valid for other recent distros even if the details differ. The kernel version is 4.14.x (after latest update).

The state of linux on the MBP (with particular focus on MacBookPro13,2) is also being tracked on https://github.com/Dunedan/mbp-2016-linux . And for Ubuntu users there are a couple tutorials (here and here) focused on that distro and the MacBook.

Note: For those who have followed these instructions ealier, and in particular for those who have had problems with the custom DSDT, modifying the DSDT is not necessary anymore - se

@3noch
3noch / Distributed Builds.md
Last active January 4, 2024 14:34
How to set up distributed builds with nix

Reference: https://github.com/LnL7/nix-docker

# If on Darwin, I recommend keeping nix stuff contained
mkdir -p /nix/etc/nix
ln -s /nix/etc/nix /etc/nix  # sysconfdir; can be overridden with $NIX_CONF_DIR

cd /nix/etc/nix/
openssl genrsa -out signing-key.sec 2048
openssl rsa -in signing-key.sec -pubout > signing-key.pub
rec {
myNixpkgsFunc = import ./nixpkgs;
myNixpkgs = myNixpkgsFunc {};
baseNixpkgsFunc = import ((import <nixpkgs> { }).fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "d4eac0278ca188aa236b6a7f0fbb15f8ee4273d0";
sha256 = "0mpx6bjvix7dfmgn6a2chmmicamz9v941fki0lgzfk2gw90fqg6w";
});
/**
* Author: Nick Johnson <arachnid at notdot.net>
*
* WARNING: This contract is new and thus-far only lightly tested. I'm fairly
* confident it operates as described, but you may want to assure yourself of
* its correctness - or wait for others to do so for you - before you trust your
* ether to it. No guarantees, express or implied, are provided - use at your
* own risk.
*
* @dev Ether vault contract. Stores ether with a 'time lock' on withdrawals,
{ lib, config, pkgs, ... }:
let
WANMASTER = "enp4s2f0";
WAN = "wan";
LAN = "enp4s2f1";
in
{
networking = {
defaultMailServer.directDelivery = true;
@bobvanderlinden
bobvanderlinden / builder.sh
Created June 3, 2016 18:12
Nix and npm-shrinkwrap
source $stdenv/setup
# Place npm-shrinkwrap.json alongside package.json
ln -s $NPM_SHRINKWRAP ./npm-shrinkwrap.json
# Create fake package.json. This is not used by npm when npm-shrinkwrap.json is available, but npm does parse this as json
echo "{}" > package.json
# Create fake HOME directory for npm
export HOME=$PWD/home