Skip to content

Instantly share code, notes, and snippets.

@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());

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 / 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");
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 / PKGBUILD
Created November 16, 2012 04:58
PKGBUILD for imapfilter
# Maintainer: Mark Foxwell <fastfret79@archlinux.org.uk>
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')
@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
#!/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
#
<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>
open("/home/bct/.mozilla/plugins", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 11
access("/home/bct/.mozilla/plugins/libflashplayer.so", F_OK) = 0
open("/home/bct/.netscape/plugins", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/browser/plugins", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/mozilla/plugins", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/firefox/plugins", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib64/browser-plugins", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/browser-plugins", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/mozilla/plugins", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/netscape/plugins", O_RDONLY|O_NONBLO
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'time'
get '/' do
haml <<END
%h1 test cookies.