Skip to content

Instantly share code, notes, and snippets.

<div class="alert">
<a href="#" class="button">
Push Me
</a>
<div class="alert-box">
<p>This is an alert pertaining to the button.</p>
</div>
</div>
#!/bin/sh
#
# action
# new: add new profile template (creates file if not found), then edit
# edit: edit file (fall back to 'new' if file not found)
# load: load from file
# once: use temporary file to edit form once
# (empty): if file not available, new; otherwise, load
#
@bct
bct / gist:3913085
Created October 18, 2012 16:37
shell functions for lazy ruby developers
function lsgems() {
rubyversion=$(ruby -v | cut -f2 -d' ' | sed 's/p/-p/')
gemroot=~/.rvm/gems/ruby-"$rubyversion"/gems
ls "$gemroot"
}
function cdgem() {
rubyversion=$(ruby -v | cut -f2 -d' ' | sed 's/p/-p/')
gemroot=~/.rvm/gems/ruby-"$rubyversion"/gems
@bct
bct / PKGBUILD
Created November 16, 2012 04:58
PKGBUILD for imapfilter
# Maintainer: Mark Foxwell <[email protected]>
pkgname=imapfilter
pkgver=2.5.3
pkgrel=1
pkgdesc="A mail filtering utility for processing IMAP mailboxes"
arch=('i686' 'x86_64')
url="https://github.com/lefcha/imapfilter"
license=('MIT')
depends=('lua' 'pcre' 'openssl')
use std::comm::*;
use std::libc::funcs::posix88::unistd;
// this simulates a processing-intesive task.
fn test(x: bool) -> bool {
unsafe {
unistd::sleep(1);
}
@bct
bct / literals.rs
Created August 21, 2013 21:55
experimenting with string literal lifetimes
struct Error {
msg: &'static str
}
fn error(msg: &'static str) -> Error {
Error { msg: msg }
}
fn main() {
let err = error("successful syntax error");

Keybase proof

I hereby claim:

  • I am bct on github.
  • I am bct (https://keybase.io/bct) on keybase.
  • I have a public key whose fingerprint is 975A CD85 5C79 1B0F D3FA 8BC2 F14C E7BB 1C46 35D2

To claim this, I am signing this object:

@bct
bct / test-bridge.js
Created February 13, 2024 18:44
jspybridge memory growth example
const EventEmitter = require("node:events");
const emitter = new EventEmitter();
const sleep = (waitTimeInMs) =>
new Promise((resolve) => setTimeout(resolve, waitTimeInMs));
async function doLoop() {
while (true) {
emitter.emit("ping", new Date().toISOString());
@bct
bct / microvm-with-usb-passthrough.nix
Created September 2, 2024 13:29
microvm.nix with USB passthrough
# declarative microvms do not run as root. in order for USB passthrough to work they need access
# to the USB devices in /dev/bus/usb. qemu does not print any kind of error if it does not have
# access; the devices just don't show up.
#
# we can fix this by using udev to grant the "kvm" group access to the USB devices.
# in the guest:
microvm.devices = [
# RTL2838UHIDIR
# Realtek Semiconductor Corp. RTL2838 DVB-T
@bct
bct / paperless-2024-10-11.log
Created October 12, 2024 14:26
microvm boot failure
On `systemctl start microvm@paperless`:
-- Boot 5c29cac5196d44809796b7d03ed2267b --
Oct 12 03:23:15 systemd[1]: Starting MicroVM 'paperless'...
Oct 12 03:23:15 systemd[1]: Started MicroVM 'paperless'.
Oct 12 03:23:15 microvm@paperless[1819]: [73B blob data]
Oct 12 03:23:15 microvm@paperless[1819]: Booting from ROM...
Oct 12 03:23:15 microvm@paperless[1819]: PPrroobbiinngg EEDDDD ((eedddd==ooffff ttoo ddiissaabbllee))...... ook
Oct 12 03:23:15 microvm@paperless[1819]: [39B blob data]
Oct 12 03:23:15 microvm@paperless[1819]: early console in extract_kernel