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
{-# LANGUAGE TemplateHaskell #-} | |
module Main where | |
import Control.Lens | |
import Data.Map (Map) | |
type SessionID = String | |
data Player = Player { |
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
(ns demo | |
(:require-macros [schema.macros :as sm]) | |
(:require [schema.core :as s])) | |
(defn twice | |
[x] | |
(* x 2)) |
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
(ann lookup-by | |
(All [a b] | |
[b (IFn [a -> b]) (Option (Seq a)) -> (Option a)])) | |
(defn lookup-by | |
"Convenience filter. Returns the first item in coll where (= value (lookup-fn item))" | |
[value lookup-fn coll] | |
(first (filter (fn _ [x] | |
(= value (lookup-fn x))) | |
coll))) |
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 'cl-lib) | |
(defun haskell-process-completions-at-point () | |
"A company-mode-compatible complete-at-point function." | |
(interactive) | |
(destructuring-bind (start . end) (bounds-of-thing-at-point 'symbol) | |
(let ((completions (haskell-process-get-repl-completions (haskell-process) | |
(symbol-name (symbol-at-point))))) | |
(list start end completions)))) |
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
(ns schemaspeed.core | |
(require [schema.core :as s])) | |
(def S {:name s/Str | |
:age s/Int | |
:things [s/Int]}) | |
(def xs | |
(doall (repeat 100000 | |
{:name "somename" |
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 'cl-lib) | |
(require 'thingatpt) | |
(defun haskell-process-completions-at-point () | |
"A company-mode-compatible complete-at-point function." | |
(-when-let (process (haskell-process)) | |
(-when-let (symbol (symbol-at-point)) | |
(destructuring-bind (start . end) (bounds-of-thing-at-point 'symbol) | |
(let ((completions (haskell-process-get-repl-completions (haskell-process) | |
(symbol-name symbol)))) |
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
var youtubeRegexp = /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['][^<>]*>|<\/a>))[?=&+%\w.-]*/gi; | |
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU")); | |
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU")); | |
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU")); | |
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU")); | |
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU")); | |
console.log(youtubeRegexp.test("https://www.youtube.com/watch?v=o4nCcgWFEwU")); | |
// Prints true, false, true, false... |
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 stateful-view [] | |
(let [!form (reagent/atom {:name nil})] | |
(fn [ui-channel view-arg-1 view-arg-2] | |
[:form | |
[:input {:defaultValue (-> !form deref :name) | |
:onChange #(swap! !form assoc :name (.. % target value))}]]))) | |
(defn regular-view | |
[ui-channel app] | |
[:div |
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
-- Both of these functions do the same thing: return some that, if given a DB connection, will return a list of records. | |
-- No type-checking, but obvious equivalence to SQL. | |
getPerson :: UUID -> SqlPersistM [Entity Person] | |
getPerson uuid = rawSql | |
rawSql "SELECT ?? FROM person WHERE person_id = ?" [uuid] | |
-- More DSL-ish, but more compile-time guarantees. | |
getPerson2 :: UUID -> SqlPersistM [Entity Person] | |
getPerson2 uuid = |
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
module Main (..) where | |
intersectingMagnitude : Line -> Position -> Angle -> List Length | |
intersectingMagnitude ( ( sx, sy ), ( sa, sm ) ) ( rx, ry ) ra = | |
let | |
sdx = | |
cos (degrees sa) | |
rdx = |