Skip to content

Instantly share code, notes, and snippets.

View cjohansen's full-sized avatar

Christian Johansen cjohansen

View GitHub Profile
function createComponent(def) {
return React.createComponent({
render: function () {
return def.render(this.props);
}
});
}
function createSearchBox(data, service) {
var Input = React.createComponent({
render: function () {
return React.DOM.input({
onClick: function () {
service.doStuff();
}
});
}
});
@cjohansen
cjohansen / core.clj
Last active August 29, 2015 14:06
Just for laughs: A simple macro that Java-ifies your Clojure.
(ns java-clj.core)
(defn java-1 [form]
(if (list? form)
(let [tail (map java-1 (rest (rest form)))]
(if (< 2 (count form))
`(~(second form) ~(first form) ~@tail)
`~form))
form))
<body>
<style>
/* Basic reset */
* {
margin: 0;
padding: 0;
}
table {
width: 100%;
/* Basic reset */
* {
margin: 0;
padding: 0;
}
table {
width: 100%;
border-collapse: collapse;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
var target = document.getElementById("puzzle-container");
var picture = target.getElementsByTagName("img")[0].src;
function render(game, player) {
var puzzleUI = Pizuzzle({
layout: player.layout,
picture: player.picture,
move: function (slot) {
game.move(player, slot.id);
render(game, player);
(defn page []
(enlive/sniptest (slurp (io/resource "index.html"))
[:body] (enlive/append
(enlive/html [:script (browser-connected-repl-js)]))))
@cjohansen
cjohansen / gist:8689463
Last active August 29, 2015 13:55
JavaScript "Dependency injection" in all its ridiculous glory.
// An innocent-looking function
function getInjected(lol) {
console.log(lol);
}
var di = initializeDI();
di.add("lol", 42);
// A pretty weird function call
di.invoke(getInjected); // "42"
@cjohansen
cjohansen / encoding.html
Created September 16, 2013 18:01
I'm looking for a way to dynamically specify the encoding of a file that is loaded into the browser locally as a file://
<head></head>
<body>
<script>
document.head.innerHTML += "<meta charset=\"utf-8\">";
document.body.innerHTML += "✓";
</script>
</body>