Skip to content

Instantly share code, notes, and snippets.

View LispyAriaro's full-sized avatar

Efe Ariaroo LispyAriaro

  • London, United Kingdom
View GitHub Profile
(def urls (array "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png"
"http://b.tile.openstreetmap.org/${z}/${x}/${y}.png"
"http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"))
(def OSM (js/OpenLayers.Layer.XYZ. "OSM (with buffer)" urls (extend-object! (js-obj) {"transitionEffect" "resize"
"buffer" 2
"wrapDateLine" true
"sphericalMercator" true})))
(def plot (js/OpenLayers.Map. (extend-object! (js-obj) {"div" "plot"
(ns cljs-minimal.core
(:require [cljs.core.async :as async :refer [put! <! >! <!! >!! chan]])
(:require-macros [cljs.core.async.macros :as m :refer [go]]))
(defn get-position []
(let [out (chan)
geo (.-geolocation js/navigator)]
(.getCurrentPosition geo (fn [pos] (put! out pos)))
out))
@LispyAriaro
LispyAriaro / pi.clj
Last active August 29, 2015 14:15 — forked from bmabey/pi.clj
(defn calculate-pi
"Calculates Pi using the approximation 4 * (1 - 1/3 + 1/5 - 1/7 + ...)"
[iterations]
(let [odd-numbers (filter odd? (iterate inc 1))]
(* 4.0
(apply + (map / (cycle [1 -1]) (take iterations odd-numbers))))))
(println "calculated pi =" (calculate-pi 100000))
(println "Math/PI =" Math/PI)
(ns three.demo)
(def camera (THREE.Camera. 75 (/ window/innerWidth
window/innerHeight) 1 10000))
(set! (.z (.position camera)) 1000)
(def scene (THREE.Scene.))
(def geometry (THREE.CubeGeometry. 200 200 200))
(def obj (js/Object.))
(set! (.color obj) 0xff0000)
(set! (.wireframe obj) true)
(def material (THREE.MeshBasicMaterial. obj))
@LispyAriaro
LispyAriaro / DD.jl
Last active August 29, 2015 14:20 — forked from kmsquire/DD.jl
module DD
import Base: similar, sizehint, empty!, setindex!, getindex, get,
pop!, delete!, start, next, done, isempty, length
export DefaultDict
type DefaultDict{K,V,F} <: Associative{K,V}
d::Dict{K,V}
@LispyAriaro
LispyAriaro / DD.jl
Last active August 29, 2015 14:20 — forked from kmsquire/DD.jl
module DD
import Base: similar, sizehint, empty!, setindex!, getindex, get,
pop!, delete!, start, next, done, isempty, length
export DefaultDict
type DefaultDict{K,V,F} <: Associative{K,V}
d::Dict{K,V}
@LispyAriaro
LispyAriaro / gist:803e5e37cb735da6dbb8
Last active September 17, 2015 01:16 — forked from flyingmachine/gist:4004807
clojure korma heroku db connection
(defdb db
(if (System/getenv "DATABASE_URL")
(let [db-uri (java.net.URI. (System/getenv "DATABASE_URL"))
user-and-password (clojure.string/split (.getUserInfo db-uri) #":")]
{:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:user (get user-and-password 0)
:password (get user-and-password 1) ; may be nil
:subname (if (= -1 (.getPort db-uri))
(format "//%s%s" (.getHost db-uri) (.getPath db-uri))
@LispyAriaro
LispyAriaro / 0_reuse_code.js
Created January 5, 2016 09:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@LispyAriaro
LispyAriaro / gist:ee5eea83a0df359e4989ae51d68c058d
Created April 9, 2016 07:50
VLC plugin - delete currently playing file
--[[
INSTALLATION (create directories if they don't exist):
- put the file in the VLC subdir /lua/extensions, by default:
* Linux (all users): /usr/share/vlc/lua/extensions/
* Linux (current user): ~/.local/share/vlc/lua/extensions/
* Mac OS X (all users): /Applications/VLC.app/Contents/MacOS/share/lua/extensions/
* Windows: not supported - getting permission error on delete...
- Restart VLC.
]]--
@LispyAriaro
LispyAriaro / Mist.md
Created May 2, 2016 15:56 — forked from jamii/Mist.md
Mist: an open-source clojure library for p2p NAT traversal, dynamic addressing and pubsub

About

Building decentralised services is an exercise in accidental complexity. Connectivity is the first hurdle. Users move around, go on- and off-line and lurk behind NAT. For centralised systems we have ICE. For decentralised systems there is no standard solution.

Mist will take an abstract address representing a user, locate their machine, punch a hole and return a local UDP proxy to talk to that user. It will be cross-platform, provide a simple api and be easy to use with existing UDP programs.

As a bonus, the implementation also provides a p2p pubsub system.

The design is based heavily on Jeremy Miller's telehash protocol (although simplified and streamlined) and draws ideas from libswift. It is also based on lessons learned from my telehash implementation.