Skip to content

Instantly share code, notes, and snippets.

View jmgimeno's full-sized avatar

Juan Manuel Gimeno jmgimeno

View GitHub Profile
@jmgimeno
jmgimeno / README.md
Created February 25, 2014 16:07 — forked from jstcki/README.md

Using D3 in a React TransitionGroup to transition elements. D3 is used purely for transitions, no data-joins are used. The distinction between entering and exiting elements is handled by the TransitionGroup component. See the React documentation for more features.

Alternative implementations only with D3 and using React without addons.

Note: This implementation is around 30% slower in processing 1000 circles than the other two. Also, componentWillEnter() only is triggered when the TransitionGroup is being re-rendered and not when it is mounted (notice the gray circle at the start).

@jmgimeno
jmgimeno / README.md
Created February 25, 2014 16:07 — forked from jstcki/README.md

Avoid restarting running transitions by either starting one just on the .enter() selection or by using selection.filter() to only select elements which are not in transit yet.

Alternative implementations combining D3 with React and React TransitionGroup.

@jmgimeno
jmgimeno / README.md
Created February 25, 2014 16:06 — forked from jstcki/README.md
(ns mc-map.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]))
(enable-console-print!)
(def app-state (atom {:mapOptions #js {:center (google.maps.LatLng. -34.397 150.644)
:zoom 8}}))
(defn map-view [app owner]
@jmgimeno
jmgimeno / why.clj
Created January 22, 2014 05:52 — forked from brandonbloom/why.clj
;;;; Super top secret talk stuff nobody should ever see. Shhh.
(in-ns 'user)
(defmacro bench [& body]
`((re-find #"\"(.*)\"" (with-out-str (time (do ~@body)))) 1))
*ns*
(require 'clojure.walk)
(ns tetris.core
(:import (java.awt Color Dimension BorderLayout)
(javax.swing JPanel JFrame JOptionPane JButton JLabel)
(java.awt.event KeyListener))
(:use clojure.contrib.import-static deflayout.core
clojure.contrib.swing-utils)
(:gen-class))
(import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_DOWN VK_UP VK_SPACE)
@jmgimeno
jmgimeno / brush.js
Created September 21, 2013 22:13 — forked from enjalot/brush.js
if(!d3.chart) d3.chart = {};
d3.chart.brush = function() {
var g;
var data;
var width = 600;
var height = 30;
var dispatch = d3.dispatch(chart, "filter");
function chart(container) {
(ns prime-factors.core
(:require [clojure.core.logic :refer :all])
(:require [clojure.core.logic.fd :refer [in interval eq]]))
(defn factor-pairs [number]
(run* [pair]
(fresh [factor1 factor2]
(in factor1 factor2 (interval 2 number))
(eq (= number (* factor1 factor2)))
(== pair [factor1 factor2]))))
object BenchmarkCommon {
import scala.util.Random
val DatasetSize = 10000
val Iterations = 10000
val ArrayPoolSize = 1000
val ArrayPool = {
def randomArray(): Array[Int] = {
val array = new Array[Int](DatasetSize)
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._