Skip to content

Instantly share code, notes, and snippets.

{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
inherit (lib) optional optionals;
erlang = pkgs.beam.interpreters.erlangR24;
elixir = pkgs.beam.packages.erlangR24.elixir_1_13;
nodejs = pkgs.nodejs-18_x;
@cleverca22
cleverca22 / Main.hs
Created July 26, 2021 18:27
New Project
{-# LANGUAGE OverloadedStrings #-}
module Escrow where
import Language.Marlowe.Extended
main :: IO ()
main = print . pretty $ contract
-- We can set explicitRefunds True to run Close refund analysis
-- but we get a shorter contract if we set it to False
@cleverca22
cleverca22 / Glut.hs
Created October 6, 2019 20:30 — forked from kindaro/Glut.hs
import System.Exit (exitWith, ExitCode(ExitSuccess))
import Graphics.UI.GLUT
main = do
(progName, _args) <- getArgsAndInitialize
initialDisplayMode $= [ SingleBuffered, RGBMode ]
initialWindowSize $= Size 500 500
_ <- createWindow progName
exitWith ExitSuccess
@cleverca22
cleverca22 / default.nix
Created August 28, 2019 10:56 — forked from idontgetoutmuch/default.nix
pkg config generation
{ stdenv, fetchurl, gfortran }:
stdenv.mkDerivation rec {
name = "blas-${version}";
version = "3.8.0";
src = fetchurl {
url = "http://www.netlib.org/blas/${name}.tgz";
sha256 = "1s24iry5197pskml4iygasw196bdhplj0jmbsb9jhabcjqj2mpsm";
};
{ pkgs ? import ./nix/nixpkgs.nix {} }:
with pkgs;
haskellPackages.extend (self: super: {
polysemy = self.callHackageDirect {
pkg = "polysemy";
ver = "1.1.0.0";
sha256 = "1krbhfs6sr9m6nxhs9ygkblwd85w234hll5g7ndzhdwy5pfbyfvm";
} {};
self: super:
let
pythonOverlay = pself: psuper:
{
sundials_3_lapack = pself.callPackage ./pkgs/sundials { };
myScikits-odes = pself.callPackage ./pkgs/scikits-odes { };
};
in {
pythonPackages = super.pythonPackages.override { overrides = pythonOverlay; };
}
# in rails project
with (import <nixpkgs> {});
let
rubyenv = bundlerEnv {
name = "cart-env";
# Setup for ruby gems using bundix generated gemset.nix
inherit ruby_2_6;
gemfile = ./Gemfile;
nix-repl> eval = import <nixpkgs/nixos> { configuration = ./snmpd.nix; }
nix-repl> eval.config.systemd.units."snmpd.service".unit
«derivation /nix/store/q8nq58244hw0v04w400kzwllxwb42zrg-unit-snmpd.service.drv»

attrset ? "key" and attrset.key or fallback have nearly equal complexity costs

if attrset ? "key" then attrset.key else fallback is slightly more expensive,

due to being 3 AST nodes (an ExprIf with an ExprOpHasAttr as the condition and then an ExprSelect to extract the "key")

attrset.key or fallback is slightly cheaper, since it is a single AST node (just ExprSelect)

start:
alias FlushSwitch d0
alias FlushRegulator d1
alias Furnace d2
alias FillSwitch d3
alias FillRegulator d4
loop:
l r0 FillSwitch Open
s FillRegulator On r0
l r0 FlushSwitch Open