Skip to content

Instantly share code, notes, and snippets.

Aleksandr Zhuravlev zelark

Block or report user

Report or block zelark

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View aoc2019-day2.clj
(def input [1,12,2,3, 1,1,2,3, 1,3,4,3, 1,5,0,3, 2,13,1,19, 1,5,19,23, 2,10,23,27, 1,27,5,31, 2,9,31,35, 1,35,5,39, 2,6,39,43, 1,43,5,47, 2,47,10,51, 2,51,6,55, 1,5,55,59, 2,10,59,63, 1,63,6,67, 2,67,6,71, 1,71,5,75, 1,13,75,79, 1,6,79,83, 2,83,13,87, 1,87,6,91, 1,10,91,95, 1,95,9,99, 2,99,13,103, 1,103,6,107, 2,107,6,111, 1,111,2,115, 1,115,13,0, 99,2,0,14, 0])
(defn add [m p1 p2 p3]
(let [a (get m p1)
b (get m p2)]
(assoc m p3 (+ a b))))
(defn mul [m p1 p2 p3]
(let [a (get m p1)
b (get m p2)]
View xcrun-error.md

Problem:

xcrun: error: invalid active developer path (/Applications/Xcode.app/Contents/Developer/), missing xcrun at: /Applications/Xcode.app/Contents/Developer/usr/bin/xcrun

Solution:

xcode-select --install

# optional
View rich-already-answered-that.md

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link below in the summary jumps at the answer on this page.
  • The link on the question itself points back at the original post.

Summary

@zelark
zelark / clojure-programming-blog.md
Last active Nov 26, 2019
#clojure #clojurescript #blog #grumpy.website
View clojure-programming-blog.md

Clojure Programming: Blog

  • Part 1: Начало статического блога. Immutant, Ring, Compojure, HTML rendering через Rum
  • Part 2: Forms, middlewares, redirects, 404 and error handling
  • Part 3: id generator, loops, cookies, sessions, authorization, working w/ files, macros
  • Part 4: Cookies, рефакторинг, неймспейсы, RSS фид
  • Part 5: Infinite Scroll на JS, sitemap.xml, robots.txt
  • Part 6: Настраиваем CLJS окружение
  • Part 7: Переделываем форму редактирования на Rum, клиент+сервер-сайд рендеринг, EDN-сериализация данных
  • Part 8: CLJS, drag-n-drop upload, browser API, Rum mixins, local state
@zelark
zelark / pg_test.types.clj
Last active Sep 20, 2019
Support json and jsonb Postgres types in Clojure.
View pg_test.types.clj
;; For supporting more PG types, see https://github.com/remodoy/clj-postgresql
(ns pg-test.types
(:require [cheshire.core :as json]
[clojure.java.jdbc :as jdbc])
(:import [org.postgresql.util PGobject]
[java.sql PreparedStatement]))
;; Writing
(defn- to-pg-json [data json-type]
View bmi.cljs
(ns test.bmi
(:require [reagent.core :as reagent]))
(defonce bmi-data (reagent/atom { :height 180 :weight 80 }))
(defn- calc! [param value]
(swap! bmi-data assoc param value)
(let [{:keys [height weight bmi]} @bmi-data
View project.clj
(defproject helloworld "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:min-lein-version "2.7.1"
View zipmap-evolution.clj
;; http://www.4clojure.com/problem/solutions/61
(fn [ks vs] (reduce (fn [m [k v]] (assoc m k v)) {} (map vector ks vs)))
(fn [ks vs] (apply assoc {} (mapcat vector ks vs)))
(fn [ks vs] (apply assoc {} (interleave ks vs)))
(fn [ks vs] (apply hash-map (interleave ks vs)))
View clojure-basics.clj
;; function execution
;; (func arg1 arg2 arg3 ... argN)
;; function defenition
;; (defn <name> <args> <body>)
'(1 2 3)
[1 2 3]
(defn hello [name] (println "Hello," name))
You can’t perform that action at this time.