Skip to content

Instantly share code, notes, and snippets.

View cjohansen's full-sized avatar

Christian Johansen cjohansen

View GitHub Profile
@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"
(defn page []
(enlive/sniptest (slurp (io/resource "index.html"))
[:body] (enlive/append
(enlive/html [:script (browser-connected-repl-js)]))))
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);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/* Basic reset */
* {
margin: 0;
padding: 0;
}
table {
width: 100%;
border-collapse: collapse;
<body>
<style>
/* Basic reset */
* {
margin: 0;
padding: 0;
}
table {
width: 100%;
@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))
function createSearchBox(data, service) {
var Input = React.createComponent({
render: function () {
return React.DOM.input({
onClick: function () {
service.doStuff();
}
});
}
});
function createComponent(def) {
return React.createComponent({
render: function () {
return def.render(this.props);
}
});
}
.mod, .tabs, pre, h1, h2, h4, h5, p, ul, ol, hr, table {margin: 1rem 0;}
.bd, .media {overflow:hidden;}
.media .img {float:left; margin-right: 0;}
.media .imgExt {float:right; margin-left: 0;}