Skip to content

Instantly share code, notes, and snippets.

View nha's full-sized avatar
🐢
https://turtlequeue.com

nha

🐢
https://turtlequeue.com
View GitHub Profile
@fogus
fogus / main.clj
Created January 17, 2012 21:26 — forked from lynaghk/main.clj
Cassowary constraint solver in ClojureScript
;;Using the Cassowary constraint solver from ClojureScript
;;This demo shows using multimethods for readable constraint syntax using +, -, and =.
;;Output is a row of circles with random radii spaced so that the space between their boundaries is uniform.
(ns c2.main
;;refer-clojure :exclude is currently broken in ClojureScript master
;;Ticket open: http://dev.clojure.org/jira/browse/CLJS-114
;;Fix applied here: https://github.com/lynaghk/clojurescript/tree/114-refer-clojure-exclude
(:refer-clojure :exclude [+ - =])
(scss->clj "/Users/noprompt/git/yui/pure/src/grids/css/grids-core.css"
'pure.grids)
;; =>
((ns
pure.grids
(:require [garden.stylesheet] [garden.units] [garden.def]))
(garden.def/defstyles
grids
[".pure-g"
{:letter-spacing "-0.31em"}
@piotr-yuxuan
piotr-yuxuan / math-and-simple-call-in-core-logic.clj
Created January 16, 2016 16:10
Learning try-and-diy: how can I simplify this example?
(ns firstshot.chessknightmove
(:refer-clojure :exclude [== >= <= > < =])
(:use clojure.core.logic
clojure.core.logic.arithmetic))
(defn knight-moves
"Returns the available moves for a knight (on a 8x8 grid) given its current position."
[x y]
(let [xmax 8 ymax 8]
(run* [q]
@frenchy64
frenchy64 / spec.clj
Created August 31, 2016 09:10
spec demo
(ns runtime-infer-demo.server-port
{:lang :core.typed
:core.typed {:features #{:runtime-infer}}}
(:require [clojure.core.typed :as t]
[clojure.spec :as s]))
(deftest configure-server-port-test
(is
(= (->
(configure-server-port
;; an answer to http://kotka.de/blog/2010/03/The_Rule_of_Three.html#summary
;; memoize from core.clj:
(defn memoize
[f]
(let [mem (atom {})]
(fn [& args]
(if-let [e (find @mem args)]
(val e)
(let [ret (apply f args)]

Literate Clojure

@pnf
pnf / qaxl.clj
Created October 28, 2016 20:46
(ns qaxl.core
(:use clojure.walk clojure.pprint qaxl.cache)
(:require [co.paralleluniverse.pulsar.async :as qa]
[clojure.core.async :as a]
[co.paralleluniverse.pulsar.core :as q]
[clojure.test :refer [function?]]
[co.paralleluniverse.fiber.httpkit.client :as hk]
[co.paralleluniverse.pulsar.core :refer [fiber]]
[clojure.core.match :refer [match]]))
@pesterhazy
pesterhazy / react-native-navigators.md
Last active March 2, 2017 22:37
React Native Navigator choices

To implement RN navigation (showing scenes, animating transitions, ability to navigate back in a stack), there are a number of components to choose from.

Here's a list with some (non-authoritative) features:

  • Navigator (and its close cousin NavigatorIOS): included with RN, janky imperative interface
  • NavigationExperimental: also included in RN, more functional but still has "experimental" in it name
  • exponent/ex-navigator: provided by exponent, a wrapper around Navigator with a better interface (deprecated in favor of react-navigation?)
  • exponent/ex-navigation: also by exponent, a successor (?) of ex-navigator (deprecated in favor of react-navigation?)
  • [wix/react-native-naviga
@lynaghk
lynaghk / main.clj
Created January 6, 2012 15:26
Cassowary constraint solver in ClojureScript
;;Using the Cassowary constraint solver from ClojureScript
;;This demo shows using multimethods for readable constraint syntax using +, -, and =.
;;Output is a row of circles with random radii spaced so that the space between their boundaries is uniform.
(ns c2.main
;;refer-clojure :exclude is currently broken in ClojureScript master
;;Ticket open: http://dev.clojure.org/jira/browse/CLJS-114
;;Fix applied here: https://github.com/lynaghk/clojurescript/tree/114-refer-clojure-exclude
(:refer-clojure :exclude [+ - =])
(def react-navigation (js/require "react-navigation"))
; Core
(def createNavigationContainer (.-createNavigationContainer react-navigation))
(def StateUtils (.-StateUtils react-navigation))
(def PropTypes (.-PropTypes react-navigation))
(def addNavigationHelpers (.-addNavigationHelpers react-navigation))
(def NavigationActions (.-NavigationActions react-navigation))