This file contains 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 alpakit.async | |
(:require [cljs.core.async] | |
[cljs.core.async.interop :refer-macros [<p!]])) | |
(defn promise? [obj] | |
#?(:clj false) | |
#?(:cljs (= js/Promise (type obj)))) | |
This file contains 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
// https://qntm.org/clean | |
package fitnesse.html; | |
import fitnesse.responders.run.SuiteResponder; | |
import fitnesse.wiki.*; | |
public class SetupTeardownIncluder { | |
public static String render(PageData pageData) throws Exception { |
This file contains 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
(unpack | |
;; data | |
{:parent {:nested [{:name "banana" :price 1} | |
{:name "banana2" :price 2}]}} | |
;; query: | |
{:all-names [:parent :nested [[:name]]] | |
:all-names-in-caps [:parent :nested [[:name to-upper]]] | |
:max-price [:parent :nested [[:price] *|> max]] | |
:same+1-to-price {:parent [:parent {:nested [:nested [[{:name :name | |
:price [:price inc]}]]]}]}}) |
This file contains 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
;; this macro will send paint instructions to hudini paint worklet and will setup | |
;; custom css keys so that we can pass params (color in this example) | |
(defpaint color-circle [{:keys [color]} {:keys [width height ctx]}] | |
(doto ctx ;; <-- need to make a nicer paint API, for now it's almost 1:1 with the js api | |
(.arc (/ width 2) (/ height 2)) | |
(.fillColor color) | |
(.fill))) | |
This file contains 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
(def player (ref {:health 500 :attack 10 :items #{}})) | |
(def mob1 (ref {:health 100 :attack 2 :items #{"big-banana"}})) | |
(def mob2 (ref {:health 100 :attack 4 :items #{"banana"}})) | |
(defn attack! [attacker enemy] | |
(dosync | |
(let [attacker-value (:attack @attacker) | |
enemy-value (:attack @enemy)] | |
(alter enemy update :health - attacker-value) |
This file contains 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 adventofcode.playground.d4 | |
(:require [clojure.string :as s])) | |
(defn line->date+event [line] | |
(let [[_ date-string event-string] (s/split line #"\[(.*?)\]")] | |
{:date (.getTime (doto (new js/Date date-string) | |
(.setSeconds 0) | |
(.setMilliseconds 0))) | |
:event (case (s/trim event-string) |
This file contains 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
/** | |
* Built-in Log Configuration | |
* (sails.config.log) | |
* | |
* Configure the log level for your app, as well as the transport | |
* (Underneath the covers, Sails uses Winston for logging, which | |
* allows for some pretty neat custom transports/adapters for log messages) | |
* | |
* For more information on the Sails logger, check out: | |
* http://sailsjs.org/#/documentation/concepts/Logging |
This file contains 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
// implementation details here, you want to look at the other files first | |
function init(React) { | |
let createElement = React.createElement; | |
let _cache = new WeakMap(); // can also be a regular map.. | |
let _currentElement = null; // this is where updateState will lookup the current state | |
let createWrapper = (fn) => | |
class StateWrapper extends React.Component { | |
constructor(props) { |
This file contains 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
// StoreAtom is a mutable ref that holds the immuable data, it's basically a shitty | |
// version of reagent/atom.. but becuase mobx is awesome it works :) | |
export defualt function StoreAtom(schema) { | |
const _state = mobx.observable(schema); | |
// expose schema as getter | |
Object.defineProperties(this, | |
_(schema) | |
.reduce((props, v, k) => _.extend( |
This file contains 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
// this is how I write React with JS.. | |
// | |
// "View" is a simple wrapper around React's API similar to this one: | |
// https://github.com/vitalipe/react-hut#createhutview---component-api | |
// | |
// "Type" is based on React.PropTypes with a few simple extentions... | |
const UserComponent = View.define({ | |
props : { |
NewerOlder