Skip to content

Instantly share code, notes, and snippets.

View skrat's full-sized avatar

Dušan Maliarik skrat

View GitHub Profile
#cloud-config
coreos:
etcd:
discovery: https://discovery.etcd.io/eeb0198338641f5c9b3c4f996bca8fc9
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
units:
- name: etcd.service
command: start
`/** @jsx React.DOM */`
# The above line HAS to be the first line in the file for JSX to know to process it.
MySimpleComponent = React.createClass
render: -> `<pre>{this.props.mytext}</pre>pre>`
MyComponent = React.createClass
render: ->
`(
<ul>
{this.props.items.map(
require 'eventmachine'
require 'amqp'
EventMachine.run {
conn = AMQP.connect(:host => '127.0.0.1')
puts "Connecting to RabbitMQ. Running #{AMQP::VERSION} version of the gem..."
ch = AMQP::Channel.new(conn)
q = ch.queue("amqpgem.examples.hello_world", :auto_delete => true)
x = ch.default_exchange
(defmacro joiner
[headers]
(let [extra [1 2 3]
joined (string/join "," (concat headers extra))]
`(some.one/doit ~joined)))
(defmacro joiner2
[headers]
(let [extra [1 2 3]]
`(some.one/doit (string/join "," (concat ~headers ~extra)))))
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)]