Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan danneu

  • Texas
View GitHub Profile
@danneu
danneu / 1-db.clj
Last active Aug 29, 2015
My Datomic boilerplate. (resources/schema.edn, resources/data-functions.edn, src/xxx/db.clj)
View 1-db.clj
(ns xxx.db
(:require [clojure.java.io :as io]
[clojure.string :as str]
[datomic.api :as d])
(:import [datomic Util]
[java.util Date]))
;; Datomic utils ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn read-all
@danneu
danneu / core.clj
Last active Aug 29, 2015
Crazy vs. Psychic
View core.clj
(ns casino.core)
;; Strategies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; A strategy is a function applied to a sequence of turns.
(defn crazy-strat1
"Random pick."
[_]
(rand-nth [true false]))
View mud.clj
(ns mud.sandbox
(: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
@danneu
danneu / hangman.clj
Last active Aug 29, 2015
my friend next to me at this coffee shop is learning python http://inventwithpython.com/chapter9.html
View hangman.clj
(ns scratch.hangman
(:require
[clojure.java.io :as io]
[clojure.string :as str]))
(def hangman-frames
(str/split
(slurp (io/resource "data/hangmen.txt"))
#"\n\n"))
View ch_163_fallout_hacking_game.clj
(ns daily.ch-163-fallout-hacking-game
(:require
[clojure.java.io :as io]
[clojure.string :as str]))
(def all-words
"The entire dictionary of available words."
(str/split-lines (slurp (io/resource "enable1.txt"))))
(defn word-difference
@danneu
danneu / 0-reset-and-init-db.sql
Last active Aug 29, 2015
heroku db-spec -- the :sslmode/:ssl/:sslfactory trifecta were necessary for me to let my laptop connect to my remote heroku postgres db.
View 0-reset-and-init-db.sql
DROP TABLE IF EXISTS users CASCADE;
CREATE TABLE users (
id serial PRIMARY KEY,
uname text NOT NULL UNIQUE,
digest text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
View slug.clj
(ns drugcritic.slug
(:require [clojure.string :as str]))
;;Stop at '-<number>'
;;Stop at '.'
;;Stop at <number>
;;Stop at 'and'
;;Stop at ';'
;;Stop at '('
;;Stop at 'preservative free'
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
View game1.hs
main :: IO ()
main = do
runGame []
runGame :: [Integer] -> IO ()
runGame nums = do
putStrLn "Give me a number (or 0 to stop):"
inputStr <- getLine
let inputNum = (read inputStr) :: Integer
if inputNum == 0
View gist:056234ad4b167a4f376e
RestClient.post("http://localhost:3000/lol",
{:id => "peat", :label => "Peat Bakke", :attributes => [{:for => "attribute_name", :value => 1}, {:for => "something_else", :value => "wee"}]}.to_json,
:content_type => :json)
You can’t perform that action at this time.