Skip to content

Instantly share code, notes, and snippets.

View Ivana-'s full-sized avatar
🏠
Working from home

Андрей Ivana-

🏠
Working from home
View GitHub Profile
@Ivana-
Ivana- / output.txt
Created July 31, 2024 22:43
Simple equation solver
sandbox=>
equation 1 : (x + 50) * 10 - 15 = 10
(((x + 50) * 10) - 15) = 10
((x + 50) * 10) = (10 + 15)
(x + 50) = ((10 + 15) / 10)
x = (((10 + 15) / 10) - 50)
solution: x = (((10 + 15) / 10) - 50) = -95/2
equation 2 : ((x + 10) + 30) = 10 + 20
@Ivana-
Ivana- / task.clj
Last active July 18, 2024 11:03
Ping Pong Machine's task, n in range [0, 30]
(defn full-square? [n]
(let [r (int (Math/round (Math/sqrt n)))]
(= (* r r) n)))
(defn f [i s]
(if-not (seq s)
(when i (list (list i)))
(when-let [rs (->> s
(filter #(or (nil? i) (full-square? (+ % i))))
@Ivana-
Ivana- / tinkoff_2.clj
Created February 17, 2024 23:51
Тинькофф курс All to Scala 2 задание
(ns tinkoff-2
(:import [java.util Date]))
;; мутабельный thread-safe (!) атом для хранения списка неотправленных сообщений
(def data (atom []))
;; У вас есть метод `readData` для получения порции непрерывных данных.
;; Данные нужно сразу отослать всем потребителям при помощи `sendData`.
;; Технические детали
@Ivana-
Ivana- / tinkoff_1.clj
Created February 17, 2024 23:50
Тинькофф курс All to Scala 1 задание
(ns tinkoff-1
(:import [java.util Date]))
;; У вас есть два эквивалентных сервиса, в которых можно узнать статус заявки
;; при помощи функций `getApplicationStatus1` и `getApplicationStatus2`.
;; Каждый из сервисов может вернуть один из ответов:
;; * `Response.Success` в случае успешно выполненного запроса
;; * `Response.RetryAfter` в случае, если сервис не может выполнить запрос, поле `delay` - желательная задержка перед повторным запросом
;; * `Response.Failure` в случае, если в ходе обработки запроса произошла ошибка
@Ivana-
Ivana- / index.html
Last active January 5, 2024 00:51
Bare-bones dynamic html using fetch in body
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.unauthorized-display-none { display: none }
.authorized-display-none { display: none }
</style>
</head>
.....................................................................................................................................................#########.................................................................................................................................................
.....................................................................................................................................................#*******#.................................................................................................................................................
.....................................................................................................................................................#*******#.................................................................................................................................................
................................................................................................................
@Ivana-
Ivana- / toast.cljs
Created August 29, 2022 15:25
Toast cljs
;; toast ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn- create-element-from-hiccup [hiccup-data]
(let [tmp (.createElement js/document "div")
content (rds/render-to-static-markup hiccup-data)]
(aset tmp "innerHTML" content)
(.-firstChild tmp)))
(defn- get-create-toast-container []
(let [container-id "ivana_toast_container"]
@Ivana-
Ivana- / task.sql
Created April 13, 2021 15:03
SQL HW - day 2
create table organization (
id int,
parent int,
name text
);
insert into organization (id, parent, name)
values (1, null, 'ГКБ 1')
,(2, null, 'ГКБ 2')
,(3, 1, 'Детское отделение')
@Ivana-
Ivana- / take-first-sorted-by.clj
Created November 26, 2020 17:25
Lazysecs efficient reducer, which returns n first elements of sequence, sorted by keyfn & comp
(defn take-first-sorted-by
"Performs the same result as (take n (sort-by keyfn comp coll))
but more efficient in terms of time and memory"
([n keyfn coll] (take-first-sorted-by n keyfn compare coll))
([n keyfn ^java.util.Comparator comp coll]
(if (pos? n)
(let [m ^java.util.TreeMap (java.util.TreeMap. comp)
m-size (volatile! 0)
;; if it is guaranteed that (keyfn v) will be unique for all v in coll
;; we can attach :unique? key to keyfn meta and algorythm will use single val map
@Ivana-
Ivana- / cps.js
Created July 13, 2020 00:47
CPS in javascript (JavaScript Core, strict mode - for TCO)
"use strict";
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// волшебная троица
const cons = (x, y) => [x,y]
const car = (l) => l[0]
const cdr = (l) => l[1]
const nil = cons(null, null)