Skip to content

Instantly share code, notes, and snippets.

View ento's full-sized avatar

ento

View GitHub Profile
@ento
ento / slack-cli.nix
Created December 14, 2023 21:34
Slack CLI for the next-generation Slack apps. The binary is statically linked, so it seems to work without autopatchelf
{ lib, stdenv, fetchurl, ... }:
let
version = "2.11.0";
platform = stdenv.hostPlatform;
archive =
if platform.isLinux then
{
url = "https://downloads.slack-edge.com/slack-cli/slack_cli_${version}_linux_64-bit.tar.gz";
sha256 = "1sk6hb1m6j327fp8zlnw8bd8sni1wfwgc95wxqaxmr5gcg1fxqks";
}
let
parseLine = line:
let
parts = builtins.match "([^[:space:]=#]+)[[:space:]]*=[[:space:]]*(.*)" line;
in
if (!builtins.isNull parts) && (builtins.length parts) == 2 then
{ name = builtins.elemAt parts 0; value = builtins.elemAt parts 1; }
else
null;
in
@ento
ento / chart.md
Created November 12, 2023 20:07
幻字
flowchart TD-->-->|-1| 示
    袱 --> 人
    袱 --> 犬
    猱 --> 犬
    猱 -->-->|-1| 予
    猱 --> 木
    猱 <--> 申
 犬 --&gt; 犬神
FROM python:3.9-slim AS base
RUN apt-get update && apt-get install -y curl git
RUN curl --proto '=https' --tlsv1.2 -fsSL https://static.pantsbuild.org/setup/get-pants.sh | bash
FROM base as env_a
RUN umask 022 \
&& git clone https://github.com/pantsbuild/example-python example_repo \
&& cd example_repo \
&& git checkout 3de75f5 \
&& PATH=$HOME/bin:$PATH pants package ::
@ento
ento / Dockerfile
Last active April 30, 2023 04:19
WIP: Dockerfile that might be able to build Nix dependencies first in a separate layer. Ref: https://mitchellh.com/writing/nix-with-dockerfiles#user-content-fnref-2
FROM nixos/nix:latest AS builder
RUN nix-env --install jq
COPY . /tmp/build
WORKDIR /tmp/build
RUN drvpath=$(nix --extra-experimental-features "nix-command flakes" derivation show | jq -r 'to_entries[0] | .key') \
&& echo $drvpath is the path \
&& closure=$(nix-store --query --requisites $drvpath | grep -v -F $drvpath) \
@ento
ento / drmcheck.py
Last active May 11, 2021 05:33 — forked from aallan/drmcheck.py
Python script to check encryption status of various types of ebook formats.
#!/usr/bin/python
#
# Changelog
# 1.00 - Initial version, with code from various other scripts.
# 1.01 - Moved authorship announcement to usage section.
# Written in 2011 by Paul Durrant
#
# 1.02 - Added recognition of Apple Fairplay encryption.
# Modified in 2015 by Alasdair Allan
#
@ento
ento / aws-show-monthly-cost.js
Created June 17, 2020 01:57
Add columns for monthly cost to AWS pricing tables
function findHourlyPriceColumns(table) {
for (const row of table.querySelectorAll("thead tr")) {
const headers = Array.from(row.querySelectorAll("th"));
const columns = headers.reduce(function(acc, current, index) {
if (/hourly/i.test(current.innerText) || /price per hour/i.test(current.innerText)) {
acc.push(index)
}
return acc;
}, []);
if (columns.length > 0) return {hourlyColumns: columns, totalColumns: headers.length};
@ento
ento / NOTES.txt
Created March 21, 2020 00:04
Failed attempts at shrinking the size of sqitchPg closure in Nix
Attempt 1: Build sqitch with pp
-> built binary still failed with "Can't locate PAR.pm in @INC"
Attemp 2: Install sqitchModule with ./Build bundle
-> Configuring DBD::Pg fails:
> Configuring DBD-Pg-3.10.4 ... N/A
> ! No MYMETA file is found after configure. Your toolchain is too old?
@ento
ento / 01-various-structures.md
Last active March 14, 2020 04:52
How GitHub renders YAML front matter

string: hello mapping: more-mapping: even-more-mapping: hello empty: {} array: - one - two

  • three: 3
@ento
ento / wine_4.nix
Created February 20, 2020 16:54
Nix overlay for Wine 4
# I thought this might allow running Adobe Digital Editions 2.0.1 but it didn't work.
# Leaving a gist so that I don't need to look up the commit when I need it again.
self: super:
let
pkgsPath = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/8a83fb70d01a953ef72293e0034474a5a93ef3c0.tar.gz";
sha256 = "0f2blhwpy5vbxzrbyykn0jk0da9srgnfv4yaxi3yhmlpinlx84m9";
};
in {
wine_4 = (import pkgsPath { }).wineUnstable;