Skip to content

Instantly share code, notes, and snippets.

View osnr's full-sized avatar

Omar Rizwan osnr

View GitHub Profile

A few years ago, I tried to turn a Pi Zero into a ‘synthetic USB stick’ – where you’d plug it into your laptop and it’d appear like an ordinary flash drive, but the program on the Zero could intercept reads and writes and dynamically generate content. Like a FUSE filesystem, but as a piece of hardware, sort of.

So you could edit a Python file on your laptop, save it to the USB drive, and then the output of your Python code would magically appear as a sibling file on the drive; things like that. I thought it would be particularly cool as a way to get some dynamism and programmability

@osnr
osnr / search-twitter-around-screenotate.md
Created February 9, 2021 03:40
Search your tweets around the time you took a screenshot.

If you have a Screenotate screenshot HTML file open in your browser, clicking this bookmarklet will search your old tweets from around the time you took the screenshot, so you can find your original tweet of it (if it exists).

Make a new bookmark with the below as URL, replacing from:rsnous with from:YourTwitterUsername:

javascript:void%20function(){const%20a=new%20Date(document.body.innerHTML.match(/%3Cdd%3E(\d\d\d\d\-\d\d\-\d\d)/)[1]),b=new%20Date(a.getTime());b.setDate(b.getDate()-1);const%20c=new%20Date(a.getTime());c.setDate(c.getDate()+1);const%20d=`from:rsnous%20since:${b.toISOString().slice(0,10)}%20until:${c.toISOString().slice(0,10)}`;window.location.href=`https://twitter.com/search%3Fq=${encodeURIComponent(d)}`}();

Or construct the bookmarklet URL yourself -- here's the source code:

diff --git a/lib/math.tcl b/lib/math.tcl
index 5bff734..48b7f0c 100644
--- a/lib/math.tcl
+++ b/lib/math.tcl
@@ -1,9 +1,17 @@
namespace eval ::vec2 {
- proc add {a b} {
- list [+ [lindex $a 0] [lindex $b 0]] [+ [lindex $a 1] [lindex $b 1]]
+ set cc [c create]
+ $cc code {
package require oo
set block {
class C {
procs {}
}
}
set tmp [file tempfile /tmp/blockXXXXXX].tcl
set fd [open $tmp w]; puts $fd $block; close $fd