This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def app | |
(-> app-routes | |
((fn [handler] | |
(fn [req] | |
(pprint req) | |
(let [res (handler req)] | |
(pprint res) | |
res)))) | |
wrap-edn-params)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( |