Skip to content

Instantly share code, notes, and snippets.

View mh120888's full-sized avatar

Matthew Higgins mh120888

View GitHub Profile
@mh120888
mh120888 / policy.json
Created November 21, 2019 18:02
policy.json
{
"data": [
{
"policy_reference": "0900047067",
"amount": "24.14"
},
{
"policy_reference": "0900047069",
"amount": "10.01"
},
@mh120888
mh120888 / questions.md
Created January 28, 2018 14:19
Questions to review

What's an example of a string? A number?

How are 2 and "2" different?

What is the difference beween == and === in javascript?

Why is 1 == true true but 1 === true false?

What happens if you put ! in front of something? For example, how are these different?

@mh120888
mh120888 / basic.clj
Created August 17, 2016 17:28
basic-hosted-ttt
(ns web-ttt.core
(:gen-class)
(:require [matts-clojure-ttt.game :as game])
(:import [server.MyServer]
[app.Application]
[httpmessage.HTTPResponse]
[cobspecapp.CobSpecApp]
[basichttpmessage.BasicHTTPMessageFactory]))
(def message-factory (basichttpmessage.BasicHTTPMessageFactory.))
@mh120888
mh120888 / time_to_first_move.md
Last active July 1, 2016 22:29
Clojure TTT Performance | Time to First Move
Feature Time, 3x3 board Time, 4x4 Board
Baseline 36s too slow, unknown
Memoize winning combos 30s too slow, unknown
Memoize move generation 4s out of memory exception
Depth-limit 0.7s out of memory exception
Reimplement minimax 1.5s out of memory exception
Add alpha-beta 0.1s 1.2s
@mh120888
mh120888 / SRP.clj
Created June 28, 2016 22:46
single responsibility clojure function
(defn get-starting-marker
[human-marker human-goes-first]
(if human-goes-first
human-marker
(board/get-other-marker human-marker)))
@mh120888
mh120888 / example.clj
Created June 28, 2016 00:12
Let bindings
(defn get-winner
[board]
(let [num-of-rows (get-number-of-rows board)
spaces-on-board (range (count board))
horizontal-coords (partition num-of-rows spaces-on-board)
vertical-coords (apply map list horizontal-coords)
diagonal-coords (generate-diagonal-coords num-of-rows)
coords-to-check (concat horizontal-coords vertical-coords diagonal-coords)]
(loop [coords-to-check coords-to-check
row-to-check (first coords-to-check)
@mh120888
mh120888 / extracted.clj
Created June 28, 2016 00:10
Should this be extracted?
(defn get-number-of-rows
[board]
(int (java.lang.Math/sqrt (count board))))
(defn get-winner
[board]
(let [num-of-rows (get-number-of-rows board)
...
@mh120888
mh120888 / example.clj
Created June 23, 2016 23:06
Generative ttt spec
(ns clojure-ttt.generative-spec
(:require [speclj.core :refer :all]
[clojure-ttt.core :as core]
[clojure-ttt.player :as player])
(:import [clojure_ttt.player ComputerPlayer]))
(def human-marker "x")
(def ai-marker "o")
(def computer-player (ComputerPlayer.))
@mh120888
mh120888 / example.clj
Last active June 23, 2016 21:54
Require + Import example in Clojure
(ns clojure-ttt.generative-spec
(:require [speclj.core :refer :all]
[clojure-ttt.core :as core]
[clojure-ttt.player :as player])
(:import [clojure_ttt.player ComputerPlayer]))
@mh120888
mh120888 / example.clj
Created June 23, 2016 21:50
Require examples
require `clojure.string
require `[clojure.string :as string]