This file contains hidden or 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
import math | |
def to_buckets(lst, *buckets): | |
sums = [] | |
for i in buckets: | |
sums.append(sum(lst[:i])) | |
lst = lst[i:] | |
return sums | |
def std_dev(target, *values): | |
return math.sqrt(sum([(target-i)**2 for i in values])) |
This file contains hidden or 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
class CustomPDFConverter < (Asciidoctor::Converter.for 'pdf') | |
register_for 'pdf' | |
def init_pdf doc | |
@parents = [] | |
super | |
end | |
def convert_olist node | |
add_dest_for_block node if node.id |
This file contains hidden or 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
package dsl4 | |
import javax.script.Bindings | |
import javax.script.ScriptContext | |
import javax.script.ScriptEngineManager | |
class MyClass { | |
fun doAfterDelay(delay: Long, callback: Runnable) { | |
println("Java: before thread ${Thread.currentThread().id}") |
This file contains hidden or 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
package com | |
import java.lang.Exception | |
import java.util.* | |
/** | |
* SOLID principles: | |
* | |
* Single responsibility | |
* Open-closed |
This file contains hidden or 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
стек: достаём только с одного конца, FILO | |
очередь: кладём и достаём с разных концов, FIFO | |
массив: случайный доступ, доступ O(1), вставка/удаление O(N) | |
связанный список: случайный доступ, доступ O(N), вставка/удаление O(1) (1, next2) (2, null) -> (1, next3) (3, next2) (2, null) | |
хэш-мэп: пара ключ-значение, O(1), вычисляем хэш –> смещение, внутри хэш-мапа | |
hash(Obj1) = 10, 10 mod 4 = 2 | |
hash(Obj2) = 13, 13 mod 4 = 1 |
This file contains hidden or 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
package com | |
import com.sun.xml.internal.ws.util.CompletedFuture | |
import java.util.concurrent.* | |
import kotlin.random.Random | |
// Синхронность, параллельности от Асинхронности | |
// Аналогия клиенты в кофейне | |
class MyRunnable(val inp: String) : Runnable { |
This file contains hidden or 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
package com | |
import java.util.* | |
import java.util.concurrent.TimeUnit | |
import java.util.concurrent.locks.ReadWriteLock | |
import java.util.concurrent.locks.ReentrantLock | |
import java.util.concurrent.locks.ReentrantReadWriteLock | |
//T1 T2 T3 Т4...Т100 | |
//A,X,Y B,V,W C D,F,G,H |
This file contains hidden or 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
package com | |
import java.util.* | |
import java.util.concurrent.CompletableFuture | |
import java.util.stream.IntStream | |
import java.util.stream.StreamSupport | |
import kotlin.collections.ArrayList | |
import kotlin.streams.toList | |
import kotlin.time.ExperimentalTime | |
import kotlin.time.measureTime |
This file contains hidden or 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
package com | |
class AnyList (val size: Int){ | |
val data: Array<Any?> = Array(size) { null } | |
fun get(i: Int): Any? { | |
return data[i] | |
} | |
fun put(i: Any?, where: Int) { |
This file contains hidden or 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
-- Транзакция - связанный набор операций | |
-- | |
-- Atomicity Атомарность, выполняется либо целиком, либо целиком откатывается/отменяется | |
-- Вася Петя | |
-- 20 10 | |
-- 20-10 | |
-- СБОЙ СИСТЕМЫ | |
-- 10+10 | |
-- Consistency Консистентность, после завершения транзакции система должна оказаться в непротиворечивом состоянии |
NewerOlder