Skip to content

Instantly share code, notes, and snippets.

@rosado
rosado / clipboard.sh
Created April 15, 2022 07:55
copy & paste
# Source: https://gist.github.com/RichardBronosky/56d8f614fab2bacdd8b048fb58d0c0c7
# Linux
_copy(){
cat | xclip -selection clipboard
}
_paste(){
xclip -selection clipboard -o
}
@rosado
rosado / try-tagged.clj
Last active November 19, 2020 15:05
try-tagged macro
(defn- try-tagged-template
[tag-test catch-symbol & body]
(let [catch-tagged-form (last body)
[catch-sym ex tag data-sym & catch-body] catch-tagged-form]
(s/validate [(s/one (s/eq catch-symbol) 'catch)
(s/one s/Symbol 'exception-binding)
(s/one s/Keyword 'tag)
(s/one s/Symbol 'ex-data-binding)]
[catch-sym ex tag data-sym])
`(let [tag-test# ~tag-test
@rosado
rosado / r3.js
Created July 3, 2020 18:45
Radio 3 bookmarklet for radio3.io
javascript:(function(){
function encode (s) {
s = s.toString ();
s = s.replace (new RegExp (/" %"/, "g"), " percent");
return (encodeURIComponent(s));
}
var url="http://radio3.io/?";
var link = "link=" + encode(location.href);
var title="&title=" + (document.title);
var desc="&description=" + (document.getSelection());
@rosado
rosado / README.md
Created March 17, 2019 16:36
SCRIPT-8
@rosado
rosado / kismet.sh
Created April 25, 2018 19:37
kismet on r-pi setup instructions
sudo apt-get install git-core build-essential
sudo apt-get install libncurses5-dev libpcap-dev libpcre3-dev libnl-dev libmicrohttpd12 libmicrohttpd-dev
wget http://kismetwireless.net/code/kismet-2016-07-R1.tar.xz
tar -xvf kismet-2016-07-R1.tar.xz
cd kismet-2016-07-R1
./configure
make
sudo make suidinstall
sudo groupadd kismet
sudo usermod -a -G kismet pi
@rosado
rosado / inline-css.js
Created November 17, 2016 20:15
inline-css
var options = {
'url': '/foo/bar/'
}
var inlineCss = require('inline-css')
var fs = require('fs')
fs.readFile('/Users/foo/Downloads/index.htm', 'utf8', function (err, data){
if (err){
return console.log(err);
}
inlineCss(data, options).then(function(html) {
@rosado
rosado / Makefile
Last active February 2, 2022 00:41
test if directory exists in a makefile
all: txtfile
TARGET_DIR = target-dir
txtfile: $(TARGET_DIR)
touch $(TARGET_DIR)/file.txt
target-dir:
test ! -d $(TARGET_DIR) && mkdir $(TARGET_DIR)
@rosado
rosado / gist:12ef6afad830236b7330
Created December 4, 2015 10:05
Sublime Text bindings for Home/End on Mac OS X
[
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["shift+end"], "command": "move_to", "args": { "to": "eol", "extend": true } },
{ "keys": ["shift+home"], "command": "move_to", "args": { "to": "bol", "extend": true } }
]
@rosado
rosado / jvm options
Created October 21, 2015 12:05
JVM opts from clojure-users group
;; https://groups.google.com/forum/#!topic/clojure/JgxFQLP2E34
:jvm-opts ^:replace ["-server"
;;"-XX:+AggressiveOpts"
;;"-XX:+UseFastAccessorMethods"
;;"-XX:+UseCompressedOops"
"-Xmx4g"]
@rosado
rosado / Channels (almost like in Newsqueak).md
Created July 27, 2015 18:30
Channels (almost like in Newsqueak) again

(published May 24, 2010, blog no longer exists)

Years ago I saw a really good talk by Rob Pike about a little known language called Newsqueak. I can’t remember if I had anything more than a mild interest in concurrent programming, but that talk got my attention. I read all I could find about concurrency in Newsqueak. Fun ideas are fun to play with.

I wrote a short article about channels, which are Newsqueak’s construct for synchronization between threads. I tried to emulate behavior of channels in C# via locking and signaling. I was aware that there probably is no 1:1 mapping between what Newsqueak calls processes and managed threads in .NET (though I’m not sure to this day how many processes could Newsqueak spawn before bringing machine to a halt) but the exercise was fun enough to do it anyway.

Now, this was long enough ago, that C# didn’t have syntax for lambdas and was