Skip to content

Instantly share code, notes, and snippets.

@glorphindale
glorphindale / gist:1b97f91d101e888c1541
Created July 7, 2014 16:29
Коэффициенты косинуса и синуса
(ns visimath.circles
(:import [java.awt.event KeyEvent])
(:require [quil.core :as qc]))
(def state (atom {:sin 1 :cos 1}))
(defn deg->pos [radius deg cos-k sin-k]
(let [rads (qc/radians (* 1 deg))
posx (* radius (Math/cos (* cos-k rads)))
posy (* radius (Math/sin (* sin-k rads)))]
@glorphindale
glorphindale / gist:9646119
Created March 19, 2014 16:56
Преобразования данных
(ns enlive-examples.process
(:require [clojure.string :as string]
[cheshire.core :as chesh]
[clojure.pprint :as pp]))
(def data (chesh/parse-string (slurp "codefest-2013-raw.json") true))
;; Sex
(defn person->name [person]
@glorphindale
glorphindale / gist:9234032
Created February 26, 2014 17:16
Пример использования enlive для выдирания информации из страниц
(ns enlive-examples.core
(:require [clojure.string :as string]
[net.cgrand.enlive-html :as html]
[cheshire.core :as chesh]))
(def ^:dynamic *base-url* "http://2013.codefest.ru/members/")
(defn fetch-url [url]
(html/html-resource (java.net.URL. url)))
@glorphindale
glorphindale / gist:8348423
Last active January 2, 2016 19:09
Значащие отступы
// Python
def func(arg1, arg2):
count = size(arg1) + size(arg2)
print count
print arg1
// C
int func(string arg1, string arg2) {
int count = arg1.size() + arg2.size();
printf("%d", count);
@glorphindale
glorphindale / config-parse.clj
Created August 15, 2013 15:58
Парсим простой человеколюбивый файл конфигурации.
(require '[clojure.string :as cs])
(def conf
"key1=val1
key2 = val2
key3 = \\
val3
key\\
4=val4
key5=\\
val5
@glorphindale
glorphindale / gist:3565013
Created September 1, 2012 05:54
К вопросу о скобках в лиспах
# C++
Stage process(State state) {
return
stage4(
stage3(
stage2(
stage1(
stage))));
}