Skip to content

Instantly share code, notes, and snippets.

@mbrock
mbrock / swash.js
Created October 26, 2023 11:03
swa.sh
// swa.sh - a tool, for naught
// Copyright (C) 2023 Mikael Brockman
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@mbrock
mbrock / roam-telegram.js
Last active September 21, 2021 18:21
Roam Telegram integration PoC
// I made this in like one hour while baby was napping.
// It's a proof of concept, but I hope to improve it soon.
// In particular, I really want to grab photos from Telegram.
//
// Make a page in your Roam called [[Telegram Bot]].
//
// Put two nodes in there:
//
// API Key:: <key you get from Telegram's bot system>
// Last Update ID::
{-# Language DataKinds #-}
{-# Language FlexibleContexts #-}
{-# Language FlexibleInstances #-}
{-# Language KindSignatures #-}
{-# Language ScopedTypeVariables #-}
{-# Language TypeApplications #-}
{-# Language ViewPatterns #-}
module Tax where
FROM ubuntu
RUN apt update && apt install -y sudo && \
mkdir -p /home/user && groupadd -r user && \
useradd -r -g user -d /home/user -s /sbin/nologin -c "User" user && \
echo "user ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \
chmod 0440 /etc/sudoers.d/user
ENV HOME=/home/user
RUN chown user:user /home/user
RUN apt install -y curl bzip2
USER user
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash
true
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix-prefetch-scripts curl jshon jq
set -e
json="{}"
add() { json=$(jshon "$@" <<<"$json"); }
rm -rf overlay/upstream
mkdir -p overlay/upstream
GET() {

Keybase proof

I hereby claim:

  • I am mbrock on github.
  • I am mbrock (https://keybase.io/mbrock) on keybase.
  • I have a public key ASBYWz5glW-ksfNNPzhmsTlZVH-rpyk6rKyLHC1WghPddAo

To claim this, I am signing this object:

# Put this expression right in your systemPackages
(pkgs.writeScriptBin "foo" ''
#! ${stdenv.shell}
echo foo
'')
@mbrock
mbrock / docker-services.nix
Created July 28, 2017 09:09
Nix service thing for Docker
{ config, pkgs, ... }:
let dockerService = {
name,
vhosts ? [],
public ? (if builtins.length vhosts > 0 then true else false),
image,
user ? "docker",
cmd ? "",
volumes ? [],
#!/bin/sh
# use: ipfspic <picture-to-upload>
url=https://ipfs.pics/upload.php
http --headers -f POST $url img@"$1" |
grep Location |
sed 's/^Location: //' |
sed 's#pics/#pics/ipfs/#' |
sed 's/#new//'