Skip to content

Instantly share code, notes, and snippets.

@jellea
jellea / blueprintgen.js
Created October 10, 2013 14:27
Creates a API blueprint dynamically.
"use strict"
var fs = require('fs')
// Add Title, Sections and Endpoints first then generate
var Document = function(){
this.data = ""
this.append = function(input) {
this.data = this.data + '\n' + input

Notes and urls from my talk

Install Leiningen

brew install leiningen

Website

Om 'hello world' template

lein new mies-om hello-world

## How I do animations with ClojureScript/Om.
At yesterdays Clojure meetup Jack, the creator of the ClojureScript pixel editor Goya, asked me how I did my animations in my [ClojureScript app (desktop chrome only)](http://development.muuuuu.divshot.io) and what makes them so performant. Because I'm getting this question more often I decided to dedicate a blog post to it.
So, how do I do animations? My main answer is '90% with a bag of css tricks'. Unless you're making it really bold, like the guys of famo.us do, most of your animations are possible with just simple plain css.
Let me share two quick css tricks to make it a bit more understandable.
Using the ```transition``` property you can simply make an animation of specific (or all) properties of an element.
```div {transition: all 0.3s ease-in-out;} ``` (don't forget the browser prefixes!)
(defn draw-matrix [grid]
(for [x (range (count grid))]
(for [y (range (count (-> grid x :seq)))]
(button x y))))
@jellea
jellea / gist:3ac4c4e643329cc4ee4f
Last active August 29, 2015 14:04
Clojurescript and externs.

I guess a bit of documentation might come in handy since the documention on the compiler and externs is still poor

I wanted to include Hammer.js to my advanced compilation file output. So, I used the Closure extern generator to make a extern file. Adding the extern to my project.clj was easy, but I wanted it to be included in the output javascript as well. Apparently :preamble is meant for that, but it just didn't work. After a bit of fiddling around I found out that the preamble path is relative to <project root>/resources.

{:id "production"
 :source-paths ["src"]
 :compiler {
  :optimizations :advanced
 :output-to "www/out/triplet_mobile.js"
Verifying that +jellea is my Bitcoin username. You can send me #bitcoin here: https://onename.io/jellea
(ns drum-machine.core
(:require [om.core :as om :include-macros true]
[sablono.core :as html :refer-macros [html]]))
(enable-console-print!)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; UI
(def tau 6.2831853071)
(def properties [:fill :round :big :black])
(defrecord Piece [^Boolean fill ^Boolean round ^Boolean big ^Boolean black])
(defn gray2 [n]
(loop [nleft n combos '(())]
(if (zero? nleft)
combos
(recur (dec nleft) (concat (map #(conj % true) combos) (map #(conj % false) combos))))))
import org.philhosoft.p8g.svg.P8gGraphicsSVG;
/*
Show simultaneous on-screen display and SVG export, and how the viewport clips the graphics.
Also a simple text test.
*/
void setup()
{
// With screen display