Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan danneu

  • Texas
View GitHub Profile
View app.clj
(def app-routes
;; Echo back the json
(POST "/lol" req
(let [json (:body req) ; wrap-json-body parses the json into a clojure map
]
;; Now we echo back the json map. wrap-json-response converts our `json`
;; clojure map into a string
{:body json, :status 200})))
(def app
@danneu
danneu / mud.clj
Created Sep 10, 2014
a simple MUD that starts with one room (the spawn). users can build out in arbitrary directions. ex: `build east`
View mud.clj
(ns mud.builder1
(:require [schema.core :as s]
[clojure.java.io :as io]
[clojure.string :as str]
[clojure.set :as set]
[mud.ansi :as ansi])
(:import [java.net ServerSocket]
[java.io PrintWriter]))
(defn prompt
View mud.js
// mkdir mud
// cd mud
// npm install --save sprintf
var net = require('net');
var sprintf = require('sprintf').sprintf;
var vsprintf = require('sprintf').vsprintf;
// A convenient combination of console.log + sprintf formatting
// Example: log('[Client %s] Hello', 42); -> '[Client 42] Hello'
function log(msg) {
View ratelimit.clj
(ns x.ratelimit
(:require
[taoensso.carmine :as car :refer [wcar]]
[ring.util.response :as response]
[ring.mock.request :as mock])
(:import
[java.util Calendar]))
;; Util ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
View debug-middleware.clj
(def app
(-> app-routes
((fn [handler]
(fn [req]
(pprint req)
(let [res (handler req)]
(pprint res)
res))))
wrap-edn-params))
View timeago.cljs
(ns x.timeago
(:require-macros
[cljs.core.async.macros :refer [go-loop]])
(:require
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[clojure.string :as str]
[goog.string :as gstr]
[cljs.core.async :refer (<! >! chan timeout put!)]
[goog.string.format]))
View or-query.clj
(let [rules [[[popular? ?e]
[?friend :user/friends ?e]
[(count ?friend) ?friend-count]
[(< ?friend-count 10)]]
[[popular? ?e]
[?e :user/name "Obama"]]]]
(d/q '[:find ?e
:in $ %
:where (popular? ?e)]
(get-db) rules))
View qqcode.clj
(ns guild.markdown.render
(:require [hiccup.core]
;[markdown.core :as md]
[clojure.string :as str]
[guild.smilies :as smilies]
[guild.markdown.transformers :refer [autolink-transformer
escape-transformer]]
[markdown.transformers :refer [transformer-vector]]))
;; (defn bb-img [text]
View master.html
<body>
<!-- Global navigation -->
<ul id="navigation">
<li>...</li>
<li>...</li>
</ul>
<!-- Nested templates are rendered here, they just have to
define an 'embed' block -->
<div id="content">
View demo1.sql
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS games;
CREATE TABLE users (
id serial PRIMARY KEY,
uname text NOT NULL,
created_at timestamp with time zone NOT NULL DEFAULT NOW()
);
CREATE TABLE games (
You can’t perform that action at this time.