Skip to content

Instantly share code, notes, and snippets.

View brainrake's full-sized avatar
λ ék .

Márton Boros brainrake

λ ék .
  • Budapest, Hungary
View GitHub Profile
@brainrake
brainrake / install-nix.sh
Last active October 14, 2017 20:28
Install Nix without sudo
#!/bin/sh
# Create the /nix directory, and change its ownership
sudo mkdir -p -m 0755 /nix
sudo chown $USER /nix
# Now install normally. It will not use sudo or ask for password.
curl https://nixos.org/nix/install | sh
# Or download, unpack, and run `./install` manually
updateNpmDeps = pkgs.writeScriptBin "update-frontend-deps" ''
#!${pkgs.stdenv.shell}
set -e
echo; echo "Pinning node dependencies from ./package.json ..."; echo
${pkgs.nix}/bin/nix-instantiate --strict --json --eval --expr '
(import <nixpkgs> {}).lib.mapAttrsToList
(name : value : { "${"\${name}"}" = value; })
(builtins.fromJSON (builtins.readFile ./package.json)).dependencies
' > node-modules.json
${pkgs.nodePackages.node2nix}/bin/node2nix \

Keybase proof

I hereby claim:

  • I am brainrape on github.
  • I am brainrape (https://keybase.io/brainrape) on keybase.
  • I have a public key ASDb9JEd0zAfwt34CvSxt69KoXMFYW3rUeiRII1kXHAK9Ao

To claim this, I am signing this object:

@brainrake
brainrake / Overloading.idr
Last active November 30, 2018 16:56
idris type-directed overloading
f : String -> String
f x = x ++ "!"
namespace maybe
f : Maybe String -> String
f (Just x) = x ++ "!"
f Nothing = "_"
test1 : String
@brainrake
brainrake / Optional.idr
Last active December 2, 2018 08:33
Optional function arguments in Idris
interface Optional a t where
optional : t -> Maybe a
Optional a (Maybe a) where
optional x = x
Optional a a where
optional x = Just x
Optional a () where
@brainrake
brainrake / deploy.hs
Last active July 15, 2020 06:39
nix-shell shebang haskell turtle nixos deploy script
#! /usr/bin/env nix-shell
#! nix-shell --pure -i runghc -p rsync openssh "haskellPackages.ghcWithPackages (pkgs: [ pkgs.turtle ])"
{-# LANGUAGE OverloadedStrings #-}
import Turtle
import Prelude hiding (FilePath)
import qualified Data.Text as T
sshOpts :: [Text]
sshOpts = ["-o", "StrictHostKeyChecking=accept-new"]
@brainrake
brainrake / array.js
Last active March 4, 2022 08:03
javascript functional array processing
// sml-list-style array functions
copy = (xs) => xs.slice(0, xs.length)
cons = (x, xs) => { ys = copy(xs); ys.unshift(x); return ys}
isEmpty = (xs) => xs.length == 0
hd = (xs) => xs[0]
tl = (xs) => { ys = copy(xs); ys.unshift(); return ys }
repeat = (n, x) => new Array(n).fill(x)
//
#version 150
uniform float time;
uniform vec2 resolution;
uniform vec2 mouse;
uniform vec3 spectrum;
uniform sampler2D texture0;
uniform sampler2D texture1;
uniform sampler2D texture2;
{ pkgs ? import <nixpkgs> {}, ... }:
let
openwrt-archer-c7-v5-factory = pkgs.fetchurl {
url = "http://downloads.openwrt.org/releases/19.07.2/targets/ath79/generic/openwrt-19.07.2-ath79-generic-tplink_archer-c7-v5-squashfs-factory.bin";
sha256 = "";
};
openwrt-archer-c7-v5-sysupgrade = pkgs.fetchurl {
url = "http://downloads.openwrt.org/releases/19.07.2/targets/ath79/generic/openwrt-19.07.2-ath79-generic-tplink_archer-c7-v5-squashfs-factory.bin";
sha256 = "";
};