Skip to content

Instantly share code, notes, and snippets.

View roman01la's full-sized avatar
🇺🇦

Roman Liutikov roman01la

🇺🇦
View GitHub Profile
import React from "react";
import im from "immer";
// global state
let db = {};
// subscribers
let subscribers = [];
// subscribe hook
(defn compute-sat [grid-size grid]
(for [y (range grid-size)
x (range grid-size)]
(let [pl (nth grid (+ (* y grid-size) x))
up (if (zero? y) 0 (nth grid (+ (* (dec y) grid-size) x)))
left (if (zero? x) 0 (nth grid (+ (* y grid-size) (dec x))))
up-left (if (or (zero? x) (zero? y)) 0 (nth grid (+ (* (dec y) grid-size) (dec x))))]
(- (+ pl up left) up-left))))
(defn sum-of-square [grid-size sat x y n]
(ns aoc2018.day10)
(defn read-point [s]
(->> (re-find #"position=<\s*(-?\d+),\s*(-?\d+)>\s*velocity=<\s*(-?\d+),\s*(-?\d+)\s*>" s)
rest
(map #(Integer/parseInt %))))
(def input
(->> (slurp "resources/aoc2018/day10.txt")
clojure.string/split-lines
(ns instructions.core
(:require [reagent.core :as r]))
(defmulti table-cell first)
(defmethod table-cell :default [[_ v]]
[:td v])
(defmethod table-cell :name [[_ v]]
[:td [:strong v]])
{:paths ["."]}
(ns rnstyles.core
(:require [clojure.string :as cstr])
(:import (cljs.tagged_literals JSValue)))
;; Sablono's stuff
;; Converting Clojure data into ClojureScript (JS)
;; ====================================================
(defprotocol IJSValue
(to-js [x]))
@roman01la
roman01la / README.md
Last active May 30, 2018 15:54
ClojureScript workshop @ AmsterdamJS '18

Setup

Please do this before workshop. Ping me on Slack if you have any problems with setup.

  1. If you don't have it yet, download and install JDK 8 and Node/NPM (Node/NPM is optional) on your machine
  2. Install Clojure CLI
  3. Clone workshop repository that we are going to work with
  4. cd into repo's directory and execute the following commands
  • npm run build to start dev server
  • npm run ide to start IDE server, which we will work in
(ns code.server-render
(:require
[clojure.string :as str]
[cljss.builder :as cljss])
(:import
[clojure.lang IPersistentVector ISeq Named Numbers Ratio Keyword]))
(defn nothing? [element]
(and (vector? element)
// create state object with initial value
this.state = {
  count: 0
};

// compute next state value
this.setState(state => {
  return { count: state.count + 1 }
});
@roman01la
roman01la / specs.clj
Created March 22, 2018 21:56
Figma File API specs
(ns figma.specs
(:require [clojure.spec.alpha :as s]))
(def color-chan
(s/and number? #(<= 0 % 1)))
(def alpha-chan
(s/and number? #(<= 0 % 1)))
;;=============================================