This file contains hidden or 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
type rank = Ace | Two | Three| Four | Five | Six | Seven| Eight | Nine | Ten | Jack | Queen | King ; | |
type suit = Spade | Hearts | Diamond | Club | |
type card = { rank, suit } | |
type deck = list(card) | |
/* type deck = List(card) | EmptyDeck */ | |
/* draw card(s) (don't forget the effect on the deck) | |
ensure the deck is shuffled |
This file contains hidden or 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
0 |
This file contains hidden or 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
for i in *; do ( cd $i; pwd; git --no-pager log --since="2016-02-12T16:36:00-07:00" --author jason --format=oneline; pwd ); done | less |
This file contains hidden or 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
(defn timeout [ms] | |
(let [c (chan)] | |
(js/setTimeout (fn [] (close! c)) ms) | |
c)) | |
(defn run-kmean | |
[] | |
(go | |
(dotimes [iteration 10] | |
(<! (timeout 1000)) |
This file contains hidden or 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
subscriptions : Model -> Sub Msg | |
subscriptions model = | |
Time.every second NextRunTicktions : Model -> Sub Msg |
This file contains hidden or 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
randomPoints : Generator (List(Point)) | |
randomPoints = | |
Random.list 200 (Random.map (\(x, y) -> Point x y) (Random.pair (int 1 999) (int 1 399))) | |
-- here we create a command that the elm runtime will execute and then pass the results back via the Update function | |
initialModel : (Model, Cmd Msg) | |
initialModel = | |
(Model [] [] 6 0 False, (Random.generate DrawPoints randomPoints)) |
This file contains hidden or 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
(defn random-point [] | |
{:x (rand-int 1000) :y (rand-int 500)}) |
This file contains hidden or 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
(require '[clojure.spec :as s]) | |
(require '[clojure.spec.gen :as gen]) | |
;; PASSPHRASES - generate a random 5 word passphrase | |
;; naive approach was to generate a random string and contrain to match a five word pattern | |
;; however this hit 100 generation limit imposed by clojure.spec | |
(defn words [str] (clojure.string/split str #" ")) | |
(def five-words? (comp (partial = 5) count words)) | |
(gen/generate (s/gen (s/and string? five-words?))) |
This file contains hidden or 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
// publish an event when a user selects and address in our React component | |
onAddressSelected(addressIndex) { | |
this.state.selectedAddressIndex = addressIndex; | |
this.state.address = Object.assign({}, this.state.addresses[index]); | |
this.setState(this.state); | |
// using tinypubsub to wrap our js events | |
$.publish('address.selected', {address: this.state.address, type: this.props.addressType}); | |
} | |
.... |
This file contains hidden or 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
// When submitting the form we use standard jquery validation | |
$form.submit(function handleSubmit(ev) { | |
// call the React address component instance and ask it to validate itself and return any errors | |
const errors = addressInstance.validate(); | |
// if there are errors cancel the form submit | |
if(errors.length > 0) { | |
ev.preventDefault(); | |
} | |
.... | |
} |
NewerOlder