Skip to content

Instantly share code, notes, and snippets.

View skrat's full-sized avatar

Dušan Maliarik skrat

View GitHub Profile
render: ->
React.DOM.div({class : 'wpbar'}, [
React.DOM.div({class : 'pbar'}, [
React.DOM.div({class : 'pbbar'
style : {width : (
Math.floor(@state.t * 100) + '%')}})
])
React.DOM.div({class : 'plabel'}, @state.phrase)
])
render: ->
React.DOM.div({className : 'wpbar'}, [
React.DOM.div({className : 'pbar'}, [
React.DOM.div({className : 'pbbar',\
style : {width : (
Math.floor(@state.t * 100) + '%')}})
])
React.DOM.div({className : 'plabel'}, @state.phrase)
])
(defn cubic-out [t b c]
(+ b (* c t t t)))
(defn ease-chan
[f b c step duration]
(let [out (chan)]
(go (doseq [t (range 0 duration step)]
(put! out (+ b (* (- c b) (f (/ t duration) 0 1))))
(<! (timeout step)))
(put! out c))
In [1]: def one(a=1,b=2):
...: print("a",a,"b",b)
...:
In [2]: one()
('a', 1, 'b', 2)
In [3]: one(*[2])
('a', 2, 'b', 2)
@skrat
skrat / maps.clj
Created August 18, 2014 11:25
Collecting maps' values
user=> (defn map-vals [f m]
#_=> (into {} (for [[k v] m] [k (f v)])))
#'user/map-vals
user=>
user=> (defn collect [ms]
#_=> (apply merge-with concat
#_=> (for [m ms] (map-vals list m))))
#'user/collect
user=>
@skrat
skrat / camera.clj
Created August 19, 2014 10:42
Orbiting camera
(defn camera
[x y]
(let [proj (js/mat4.perspective cam-proj
(/ js/Math.PI 4) (/ width height) 0.1 1000)
view (-> (js/mat4.identity cam-view)
(js/mat4.translate cam-view #js [0 0 (- camera-distance)])
(js/mat4.rotateX cam-view (/ y camera-speed))
(js/mat4.rotateY cam-view (/ x camera-speed))
(js/mat4.translate cam-view #js [0 (- (/ wall-height 2)) 0]))
viewr (js/mat3.fromMat4 cam-viewr view)]
"use strict";
require = (function e(t, n, r) {
function s(o, u) {
if (!n[o]) {
if (!t[o]) {
var a = typeof require == "function" && require;if (!u && a) return a(o, !0);if (i) return i(o, !0);throw new Error("Cannot find module '" + o + "'");
}var f = n[o] = { exports: {} };t[o][0].call(f.exports, function (e) {
var n = t[o][1][e];return s(n ? n : e);
}, f, f.exports, e, t, n, r);
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* https://raw.github.com/facebook/regenerator/master/LICENSE file. An
* additional grant of patent rights can be found in the PATENTS file in
* the same directory.
*/
(function (global) {
var to5Runtime = global.to5Runtime = {};
to5Runtime.extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* https://raw.github.com/facebook/regenerator/master/LICENSE file. An
* additional grant of patent rights can be found in the PATENTS file in
* the same directory.
*/