Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active November 14, 2023 03:46
Google Maps + D3
license: gpl-3.0
@drankard
drankard / with-query-results-cursor
Created November 3, 2011 08:31
clojure jdbc - query with cursor
(def *default-fetch-size* 500)
(defn with-query-results-cursor [[sql & params :as sql-params] func]
(sql/transaction
(with-open [stmt (.prepareStatement (sql/connection) sql)]
(doseq [[index value] (map vector (iterate inc 1) params)]
(.setObject stmt index value))
(.setFetchSize stmt *default-fetch-size*)
(with-open [rset (.executeQuery stmt)]
(func (resultset-seq rset))))))
@gijs
gijs / index.html
Created July 4, 2012 16:56 — forked from pere/index.html
d3.js circles in leaflet.js
<html>
<head>
<title>Testing d3.js in Leaflet.js</title>
<link rel="stylesheet" href="leaflet.css" />
<script type="text/javascript" src="http://d3js.org/d3.v2.min.js?2.9.3"></script>
<script src="http://code.leafletjs.com/leaflet-0.3.1/leaflet.js"></script>
<style type="text/css">
@megakorre
megakorre / func-interface.clj
Created July 18, 2012 18:43
functional interface implementation in clojure
(defmacro fi
[interface args & code]
(let [interface-type (.getMapping *ns* interface)
methods (-> (.getMethods interface-type)
seq)
method-sym (.getName (first methods))]
(when-not (= (count methods) 1)
@mbertrand
mbertrand / index.html
Last active October 25, 2023 23:58
D3.js + OpenLayers
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>D3.js and Openlayers - US States</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/blitzer/jquery-ui.css" type="text/css">
<script src="http://d3js.org/d3.v2.min.js?2.9.3"></script>
@frankvilhelmsen
frankvilhelmsen / gist:5336873
Last active September 6, 2021 17:23
call oracle stored procedure returning-java types from clojure
(ns package.classnamere)
(:import java.sql.Types)
(def db {:classname "oracle.jdbc.driver.OracleDriver"
:....
:password (System/getenv "password")})
(defn prepared-statement " on oracle stored procedure " []
(jdbc/with-connection db
(with-open [stmt (.prepareCall (jdbc/connection) "{ call PACKAGE.PROCEDURE(?, ?) }")]
@paulkaplan
paulkaplan / fabricBezierCurve.js
Last active February 2, 2024 08:30
Cubic bezier curves with fabric.js renderer
var CubicBezier = function(canvas, opts){
if(!opts) opts = {};
this.start = opts.start || new Vec2(100,100);
this.end = opts.end || new Vec2(400, 400);
this.c1 = opts.c1 || new Vec2(100, 300);
this.c2 = opts.c2 || new Vec2(300, 100);
this.curve = new fabric.Path( this.toSVGPath() );
@mezis
mezis / query_finder.sql
Last active May 26, 2024 20:03
Finding long-running queries in MySQL
SELECT id,state,command,time,left(replace(info,'\n','<lf>'),120)
FROM information_schema.processlist
WHERE command <> 'Sleep'
AND info NOT LIKE '%PROCESSLIST%'
ORDER BY time DESC LIMIT 50;
@josue
josue / nginx_s3_proxy.conf
Last active March 7, 2023 07:31
Simple Nginx Proxy to S3 Bucket Asset
server {
listen 80;
listen 443 default_server ssl;
ssl on;
ssl_certificate /etc/ssl/certs/myssl.crt;
ssl_certificate_key /etc/ssl/private/myssl.key;
server_name *.example.com;
root /var/www/vhosts/website;
@mgdelacroix
mgdelacroix / client.groovy
Created May 20, 2014 13:02
Simple Groovy client-server comunication
def socket = new Socket('localhost', 5000)
socket.withStreams { input, output ->
println input.newReader().readLine()
output << 'Imma socket'
}