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 / 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 / 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
unbind C-b
set -g prefix C-z
# Set status bar
set -g status-bg black
set -g status-fg white
set -g status-left '#[fg=green]#H'
set-option -g allow-rename off
set-option -g automatic-rename off
@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) {
{:user {:plugins [[cider/cider-nrepl "0.13.0"]
[lein-ring "0.9.7" :exclusions [org.clojure/clojure]]
[lein-pprint "1.1.1"]
[lein-vanity "0.2.0" :exclusions [org.clojure/clojure]]
[lein-voom "0.1.0-20160311_203101-g259fbfc" :exclusions [org.clojure/clojure]]
[com.jakemccrary/lein-test-refresh "0.16.0"]
[com.palletops/lein-shorthand "0.4.0" :exclusions [org.clojure/clojure]]]
:dependencies []
:repl-options {}
:shorthand {. {pp clojure.pprint/pprint}}}
@rosado
rosado / gist:5481196
Created April 29, 2013 12:03
Useful bash functions
function histogram () {
awk ' NF > 0{ counts[$0] = counts[$0] + 1; } END { for (word in counts) print word, counts[word]; }'
}
function awk-average () {
awk '{ s+=$1 } END { print 's/NR' }'
}