Skip to content

Instantly share code, notes, and snippets.

@ekzhang
ekzhang / Buildcarte.ipynb
Last active July 11, 2024 01:58
Build Systems à la Carte — Python edition
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@steinuil
steinuil / Nuget2Nix.fsx
Last active May 23, 2023 21:39
Code for the .NET packaging post
open System
open System.IO
open System.Net
open System.Text.Json
open System.Collections.Generic
open System.Security.Cryptography
/// Taken from hash.cc in the nix codebase
/// https://github.com/NixOS/nix/blob/a7540294cfae82c098e8691cd5212a9184add574/src/libutil/hash.cc
module Base32 =
@adisbladis
adisbladis / podman-shell.nix
Last active August 22, 2024 00:43
Use podman within a nix-shell
{ pkgs ? import <nixpkgs> {} }:
let
# To use this shell.nix on NixOS your user needs to be configured as such:
# users.extraUsers.adisbladis = {
# subUidRanges = [{ startUid = 100000; count = 65536; }];
# subGidRanges = [{ startGid = 100000; count = 65536; }];
# };
@misuzu
misuzu / oracle-cloud-nixos-install.md
Last active November 9, 2024 22:22
Install NixOS on Oracle Cloud over Ubuntu 18.04

Install NixOS on Oracle Cloud over Ubuntu 18.04 (make sure to use Ubuntu 18.04 or this may not work)

# install useful tools
sudo apt-get update
sudo apt-get install --no-install-recommends -y nano mc git

# prepare /boot
sudo umount /boot/efi
sudo mv /boot /boot.bak
# Usage: $ nix eval "(builtins.attrNames (import (builtins.fetchurl "https://matthewbauer.us/generate-versions.nix") {}).emacs)"
# $ nix run "(import (builtins.fetchurl "https://matthewbauer.us/generate-versions.nix") {}).emacs.\"24.3\"" -u LANG -c emacs
{ channels ? [ "19.03" "18.09" "18.03" "17.09" "17.03"
"16.09" "16.03" "15.09" "14.12" "14.04" "13.10" ]
, attrs ? builtins.attrNames (import <nixpkgs> {})
, system ? builtins.currentSystem
, args ? { inherit system; }
}: let
getSet = channel: (import (builtins.fetchTarball "channel:nixos-${channel}") args).pkgs;
@palladin
palladin / boolExpr.cs
Created May 15, 2019 15:56
BoolExpr eval
public interface IBoolExpr { }
public class And : IBoolExpr
{
public IBoolExpr Left { get; set; }
public IBoolExpr Right { get; set; }
public void Deconstruct(out IBoolExpr left, out IBoolExpr right)
{
left = Left;
right = Right;
}
@jb55
jb55 / default.nix
Last active July 30, 2023 21:45
deploy dotnet core apps on nixos
{ stdenv, lib, bash, callPackage, writeText, makeWrapper, writeScript, dotnet-sdk,
patchelf, libunwind, coreclr, libuuid, curl, zlib, icu }:
let
config = "Staging";
project = "RazorCx.Api";
target = "linux-x64";
rpath = stdenv.lib.makeLibraryPath [ libunwind coreclr libuuid stdenv.cc.cc curl zlib icu ];
@crazycodr
crazycodr / sync-out.sh
Created January 18, 2018 03:51
EFS docker image cache
#!/bin/bash
set -euo pipefail
docker_image_manifest_directory="$(mktemp -d "docker-image-manifest.XXXX")"
docker inspect $(docker images -q) \
| jq '[.[] | { id: .Id, tags: .RepoTags[] | split(":") } | { id: .id, repository: .tags[0], version: .tags[1] } ] | unique' \
> "${docker_image_manifest_directory}/image.manifest"
@juanca
juanca / github_load_all_diffs.js
Created March 2, 2017 18:42
Github PR bookmarklet: Load all file diffs
javascript:
document.querySelectorAll('.load-diff-button').forEach(node => node.click())
@jto
jto / _Fun.scala
Last active November 22, 2016 15:34
final class Compose1[T1, R] private (val fs: Vector[(Any => Any, Int)]) extends (T1 => R) {
val MAX_DEPTH = 1000
private def append(gs: Vector[(Any => Any, Int)], fd: (Any => Any, Int)) = {
val (fl, dl) = gs.last
val (f, d) = fd
if(d + dl > MAX_DEPTH) {
fd +: gs
} else {