This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gleam/iterator | |
import gleam/string | |
import gleam/io | |
pub fn main() { | |
iterator.unfold(["1,2,3,4,5,6,6,7"], fn(acc) { | |
case acc { | |
[] -> iterator.Done | |
[e] | [e, ..] -> | |
case binary_split(e, <<",":utf8>>) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gleam/dynamic | |
import gleam/int | |
import gleam/list | |
import gleam/string | |
import gleam/bit_array | |
import gleam/io | |
pub fn main() { | |
let assert Ok(s) = fmt("formatted: %d %b", #(123, <<123>>)) | |
io.println(s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
inputs, | |
lib, | |
... | |
}: { | |
perSystem = { | |
pkgs, | |
inputs', | |
... | |
}: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{lib, ...}: { | |
toBase64 = text: let | |
inherit (lib) sublist mod stringToCharacters concatMapStrings; | |
inherit (lib.strings) charToInt; | |
inherit (builtins) substring foldl' genList elemAt length concatStringsSep stringLength; | |
lookup = stringToCharacters "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
sliceN = size: list: n: sublist (n * size) size list; | |
pows = [(64 * 64 * 64) (64 * 64) 64 1]; | |
intSextets = i: map (j: mod (i / j) 64) pows; | |
compose = f: g: x: f (g x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "string_scanner" | |
# A partial parser of the netrc format | |
# No support for default, account, or macdef) | |
class Netrc | |
def self.parse | |
file = File.read(File.expand_path("~/.netrc", home: true)) | |
s = StringScanner.new(file) | |
machines = {} of String => Hash(String, String) | |
machine = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec" | |
require "json" | |
require "uri" | |
require "option_parser" | |
module Test | |
annotation Flag | |
end | |
module Configuration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import ./nix { } }: | |
let | |
inherit (builtins) fromJSON readFile toFile elemAt split mapAttrs; | |
inherit (pkgs) | |
crystal runCommand stdenv lib coreutils inclusive pkgconfig openssl; | |
inherit (pkgs.lib) makeBinPath; | |
shardLock2JSON = shardLockFile: | |
runCommand "yaml2json" { buildInputs = [ crystal ]; } '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ lib, crystal, nix-prefetch-git, makeStaticLibraries, stdenv, glibc, pcre | |
, libyaml, boehmgc, libevent }: | |
let | |
staticStdenv = makeStaticLibraries stdenv; | |
staticGlibc = glibc.static; | |
staticPcre = pcre.override { stdenv = staticStdenv; }; | |
staticLibyaml = libyaml.override { stdenv = staticStdenv; }; | |
staticBoehmgc = | |
boehmgc.override { stdenv = staticStdenv // { isLinux = false; }; }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nix-shell | |
#!nix-shell -p jq -i bash | |
# Usage: | |
# | |
# nix-install vim | |
set -e | |
registry=~/.config/nix/my_packages.json | |
profile=~/.config/nix/my_profile.nix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
record Bytea, bytes : Bytes | |
struct Bytea | |
def self.adapter | |
Lucky | |
end | |
def blank? | |
@bytes.size == 0 | |
end |
NewerOlder