Skip to content

Instantly share code, notes, and snippets.

View gosub's full-sized avatar

Giampaolo Guiducci gosub

View GitHub Profile
@gosub
gosub / gist:8540067
Created January 21, 2014 13:31
Variable binding in a clojure threading macro, simulating a Haskell where clause
(defmacro where [& body]
"where is identical to let, but with bindings
at the end of the argument list."
`(let ~(last body)
~@(butlast body)))
(-> 5
(+ i)
(- j)
import time
import sys
ms = int(sys.argv[1]) if len(sys.argv) > 1 else 250
words, start = 0, time.time()
print "\n"*2
try:
for line in sys.stdin:
@gosub
gosub / xsl_bookmarklet.js
Created June 17, 2014 07:23
A bookmarklet for applying an XSLT stylesheet to an XML document - just insert the base64 encoded xsl in atob("") - tested on firefox
javascript:(function(){var parser=new DOMParser();var ss=parser.parseFromString(atob(""),'application/xml');var xsltProcessor=new XSLTProcessor();xsltProcessor.importStylesheet(ss);var newdoc=xsltProcessor.transformToDocument(content.document);var myWindow=window.open("data:text/html,"+encodeURIComponent(newdoc.documentElement.innerHTML),"_blank","");myWindow.focus();}());
import Window
import Mouse
main = render <~ Window.dimensions ~ allMoves
mousePos =
let nomalize = \(w,h) (x,y) -> (toFloat x - toFloat w / 2, toFloat h / 2 - toFloat y)
in nomalize <~ Window.dimensions ~ Mouse.position
mouseDownAndPos = lift2 (,) Mouse.isDown mousePos
@gosub
gosub / pontometro.py
Last active December 2, 2015 15:53
from datetime import date
# per ogni festa che cade di:
# sabato o domenica, -1 punto (niente ponte e niente festa)
# lunedi' o venerdi', +2 punti (niente ponte, ma festa dopo finesettimana)
# martedi' o giovedi', +3 punti (ponte!!)
# mercoledi', +1 punti (solo festa)
punteggio = [2, 3, 1, 3, 2, -1, -1]
feste = [(1,1), # capodanno
(6,1), # epifania
@gosub
gosub / nokia_sms_tone.sh
Created July 28, 2015 11:22
Shell script to generate with SoX the famous nokia sms tone (SMS in morse)
#!/bin/sh
FILENAME="nokia_sms_tone_morse.wav"
# DOT = short bip, 0.1s
DOT="|sox -n -p synth 0.1 sine 2500 synth 0.1 sine mix 5000 synth 0.1 sine mix 7500"
# DASH = long bip, 0.3s
DASH="|sox -n -p synth 0.3 sine 2500 synth 0.3 sine mix 5000 synth 0.3 sine mix 7500"
@gosub
gosub / sc3-plugins.nix
Created February 23, 2016 16:18
Nix package definition for sc3-plugins
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "sc3-plugins-3.7.0-beta";
src = fetchgit {
url = "https://github.com/supercollider/sc3-plugins";
rev = "a963ecb";
sha256="0840jwh7ljmhg34zblahqx3abk42a3y3gvgb740r558rphbp1p19";
fetchSubmodules = true;
@gosub
gosub / hn_3_years_ago.js
Created December 24, 2017 16:37
Hacker News 3 years ago
var t = new Date();
var y = t.getFullYear();
var m = t.getMonth();
var d = t.getDate();
var p1 = (new Date(y-3, m, d, 0,0,0,0).getTime() + "").slice(0,-3);
var p2 = (new Date(y-3, m, d, 23,59,0,0).getTime() + "").slice(0, -3);
var u = "https://hn.algolia.com/?query=&sort=byPopularity&prefix&page=0&dateRange=custom&type=story&dateStart=" + p1 + "&dateEnd="+ p2;
window.location.href=u;
@gosub
gosub / hn_time_machine.js
Last active December 31, 2017 10:43
Hacker News Time Machine
var t = new Date();
t.setFullYear(t.getFullYear() - 3);
var past = prompt("HN time machine", t.toISOString().substr(0,10));
if (past != null) {
var p = new Date(past);
var p1 = (new Date(p.getFullYear(), p.getMonth(), p.getDate(), 0, 0, 0, 0).getTime() + "").slice(0,-3);
var p2 = (new Date(p.getFullYear(), p.getMonth(), p.getDate(), 23, 59, 59, 0).getTime() + "").slice(0, -3);
var u = "https://hn.algolia.com/?query=&sort=byPopularity&prefix&page=0&dateRange=custom&type=story&dateStart=" + p1 + "&dateEnd="+ p2;
window.location.href=u;
}
@gosub
gosub / wallpaper_sketch_2019-04-03.js
Created April 3, 2019 17:05
Phone Wallpaper Sketch 2019-04-03
// wallpaper sketch 2019-04-03
// by Giampaolo Guiducci
// [email protected]
// https://github.com/gosub
// render with: editor.p5js.org
function setup() {
createCanvas(1080, 1920);
background(30);
//noStroke();