Skip to content

Instantly share code, notes, and snippets.

@jcaesar
jcaesar / .gitignore
Last active March 2, 2022 09:59
Repro
/target
#!/usr/bin/env bash
set -euo pipefail
df='
FROM docker.io/library/debian:bullseye
RUN dpkg --add-architecture armhf && \
apt-get update && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get install -yq \
@jcaesar
jcaesar / remind-khal-notify-send
Created March 24, 2021 01:33
Invoke notify-send based on khal, with a 15 and 3 minute wakeup margin - should play nice with all kinds of UTF-8 and special characters (Curse you, colleagues who put paths to windows shares into appointments. \\foo\)
#!/usr/bin/env bash
set -euo pipefail
trap 'echo "ERROR: $BASH_SOURCE:$LINENO $BASH_COMMAND" >&2' ERR
for prg in notify-send khal; do
if ! which $prg &>/dev/null; then
echo $prg not found
exit -1
fi
@jcaesar
jcaesar / dnsupdate.sh
Created February 23, 2021 06:52
dumb dyndns
#!/usr/bin/env bash
# Script to update DNS zones on a remote server
# Copyright © 2005-2007 - Julien Valroff <[email protected]>
# Parts of the script Copyright © 2001-2002 - Dag Wieers <[email protected]>
set -e -u
set -o pipefail
trap 'echo "ERROR: $BASH_SOURCE:$LINENO $BASH_COMMAND" >&2' ERR
RECORD="$1"
#include <cstdio>
#include <cstdlib>
#include <execinfo.h>
#include <iostream>
#include <stdexcept>
#include <unistd.h>
void exhnd() {
fprintf(stderr, __FILE__ ": Custom exception handler invoked in pid %d\n", getpid());
void *trace_elems[20];
struct BtOnDrop<T> {
inner: T
}
impl<T> BtOnDrop<T> {
fn new(inner: T) -> Self { BtOnDrop { inner } }
}
impl<T> std::ops::Deref for BtOnDrop<T> {
type Target = T;
fn deref(&self) -> &<Self as std::ops::Deref>::Target { &self.inner }
}
@jcaesar
jcaesar / waskid.sh
Last active January 18, 2021 00:45
Rust: build wasm32-wasi binaries through ad-hoc docker
#!/usr/bin/env bash
set -e
echo '
FROM ubuntu:18.04
RUN apt-get update && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get install -yq \
build-essential \
let Expr
: Type → Type
= λ(A : Type) →
∀(Expr : Type → Type) →
∀(If : { cond : Text, thenE : Expr A, elseE : Expr A } → Expr A) →
∀(Ref : Text → Expr A) →
∀(Lit : A → Expr A) →
Expr A
let example
@jcaesar
jcaesar / playground.rs
Last active October 21, 2020 00:20 — forked from rust-play/playground.rs
Get class path from java class file
fn main() -> anyhow::Result<()> {
println!("{}", get_name(include_bytes!("../Class.class"))?);
Ok(())
}
fn get_name(cf: &[u8]) -> anyhow::Result<String> {
use anyhow::Context;
use classfile_parser::constant_info::ConstantInfo::{Class, Utf8};
use classfile_parser::constant_info::ClassConstant;
@jcaesar
jcaesar / docker-run-example.sh
Created May 24, 2019 04:35
Cargo in docker with somewhat working build caching
#!/usr/bin/env bash
set -eu
cd "$(dirname "$0")"
DOCKERF="$(cat <<EOF
FROM debian
RUN apt update && apt -yq install sudo build-essential libclang-dev clang curl # extra hoops for rdkafka
RUN echo 'rust ALL=(ALL:ALL) NOPASSWD:ALL' >>/etc/sudoers