Skip to content

Instantly share code, notes, and snippets.

View gosub's full-sized avatar

Giampaolo Guiducci gosub

View GitHub Profile
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 / 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 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 / 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)