Skip to content

Instantly share code, notes, and snippets.

@mrfabbri
mrfabbri / evilevalworker.html
Created September 19, 2010 19:07
A web worker used to offload evaluation (by means of an "evil eval") of some JavaScript code written inside the browser. A very quick and dirty hack.
<html>
<head>
<title>
</title>
<style>
#input-area{
width: 400px;
height: 400px;
margin: 10px;
}
@mrfabbri
mrfabbri / eulerworker.html
Created September 19, 2010 19:34
A quick scaffolding html file to load a web worker at runtime, a sample web worker file is provided. Aimed at tinkering with project euler problems in JavaScript without freezing the browser.
<html>
<head>
<title>
</title>
<style>
#input-area{
width: 400px;
margin: 10px;
}
@mrfabbri
mrfabbri / greet-xmas.sh
Created December 25, 2010 15:58
A nerdy Christmas greeting script [original post: http://questionmark.blogsome.com/2008/12/24/nerdy-christmas-take-2/ ]
#!/bin/bash
#lights_off
#
# *==<
# /\
# / \
# / @ \
# / \
# / @ @ \
<html>
<head>
<script type="text/javascript">
var nw = require('nw.gui');
var win = nw.Window.get();
var nativeMenu = new nw.Menu({ type: 'menubar' });
if ('createMacBuiltin' in nativeMenu) {
nativeMenu.createMacBuiltin('node-webkit');
@mrfabbri
mrfabbri / keybase.md
Created August 3, 2014 08:58
Keybase proof

Keybase proof

I hereby claim:

  • I am mrfabbri on github.
  • I am mrfabbri (https://keybase.io/mrfabbri) on keybase.
  • I have a public key whose fingerprint is 429D DE03 5870 DBDA 08DF FA36 D98A B29A 1271 2285

To claim this, I am signing this object:

@mrfabbri
mrfabbri / record-droid-screencast.sh
Created October 5, 2014 10:26
Starts and stops screen and audio (Mac) recording of an android attached device via adb
#!/bin/sh
function stop_record() {
echo
echo "stopping audio recording"
cat << EOF | osascript -l AppleScript
tell application "Quicktime Player"
stop last item of (documents whose name contains "Audio Recording")
end tell
EOF
@mrfabbri
mrfabbri / streams-interleave.rkt
Last active August 29, 2015 14:08
Interleaving streams in Racket
#lang racket
;; produce a new stream with the elements of the given streams interleaved
(define (streams-interleave . streams)
(letrec ([loop (lambda (streams)
(let ([next ((car streams))])
(cons (car next)
(thunk (loop (append (cdr streams) (list (cdr next))))))))])
(thunk (loop streams))))
@mrfabbri
mrfabbri / hashmap.sml
Created November 3, 2014 00:05
A minimal HashMap implementation in SML
signature HASH_MAP =
sig
type 'a hashVector
type ('a, 'b) hashMap
val makeEmpty : (('a -> int) * ('a * 'a -> bool) * int) -> ('a, 'b) hashMap
val lookup : ('a, 'b) hashMap -> 'a -> 'b option
val insert : ('a, 'b) hashMap -> 'a * 'b -> unit
val remove : ('a, 'b) hashMap -> 'a -> unit
val load : ('a, 'b) hashMap -> int
end
@mrfabbri
mrfabbri / shadow-stream.rkt
Created November 3, 2014 21:30
Shadow stream in Racket
;; Returns a stream that shadows side-effects of the original stream
;; when accessed after the first time
(define (shadow-stream s)
(let ([shadow-next #f])
(thunk (begin
(when (not shadow-next)
(let ([next (s)])
(set! shadow-next (cons (car next) (shadow-stream (cdr next))))))
(cons (car shadow-next) (cdr shadow-next))))))
/**
* React v0.5.0
*
* Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0