Skip to content

Instantly share code, notes, and snippets.

View unabl4's full-sized avatar

Dmitri Sinitsa unabl4

  • Inbank AS
  • Estonia, Harjumaa, Tallinn
View GitHub Profile
@mudge
mudge / pythagorean_means.rb
Last active May 20, 2021 10:55
A Ruby refinement to add methods to Enumerable for calculating the three Pythagorean means.
# A refinement to add methods to Enumerables for calculating the three
# Pythagorean means.
#
# See https://en.wikipedia.org/wiki/Pythagorean_means
module PythagoreanMeans
# Note that due to a bug refining modules in Ruby 2.7 [1], we can't `refine
# Enumerable` so we `refine Array` instead.
#
# See also https://interblah.net/why-is-nobody-using-refinements
@souhaiebtar
souhaiebtar / dbeaver.ini
Last active February 21, 2025 13:35
[dbeaver config file] .ini file for dbeaver #dbeaver #linux
# path on linux /usr/share/dbeaver/dbeaver.ini
# path on macos /Applications/DBeaverEE.app/Contents/Eclipse/dbeaver.ini
-vm
/usr/bin/java
-startup
plugins/org.eclipse.equinox.launcher_1.5.600.v20191014-2022.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.1100.v20190907-0426
-vmargs
-javaagent:/home/tunknown/.apps/dbeaver/dbeaver-agent.jar
@elderfo
elderfo / docker-cheat-sheat.md
Created February 9, 2019 14:41 — forked from dwilkie/docker-cheat-sheat.md
Docker Cheat Sheet

Build docker image

$ cd /path/to/Dockerfile
$ sudo docker build .

View running processes

@damc-dev
damc-dev / Notes_SpringBatch_CursorVsPagedReaders.md
Created August 14, 2018 17:29
[Note] Spring Batch - Cursor based vs page based item readers for retrieving records from a database

So from what I can tell from the docs [https://docs.spring.io/spring-batch/trunk/reference/html/readersAndWriters.html#database]

Cursor based item readers use a DB single connection load the entire ResultSet into app memory by default then the application iterates over the ResultSet with a cursor (So not a DB cursor) mapping one row and writing it out at a time so previous rows can be garbage collected.

Although you can set the maxRows to limit the amount of rows in the ResultSet at one time, then when the ResultSet needs more rows it will (using the same connection) fetch more (amount depends on the value of fetchSize). This continues until all rows from the query are loaded into the ResultSet and read.

Page based item readers make multiple queries each returning a different "page" of the results (size configurable with setPageSize method)

I assume cursor based item readers probably use more memory (unless configured appropriately) and be faster, where as the page based would typically consume less memo

@bgadrian
bgadrian / set.go
Last active November 3, 2025 21:18
How to implement a simple set data structure in golang
type Set struct {
list map[int]struct{} //empty structs occupy 0 memory
}
func (s *Set) Has(v int) bool {
_, ok := s.list[v]
return ok
}
@Kotauror
Kotauror / srand.md
Last active July 3, 2025 06:27
srand in RSPEC stubbing.

srand in RSPEC stubbing.

Without further ado - some thoughts on how to use srand in RSPEC testing. Example at the end.

How does the srand work line by line.

Line Input Output
1 srand(4) 281462327676453734791076087004180619592
@enricofoltran
enricofoltran / main.go
Last active September 30, 2025 12:29
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"

от Али-Бабы и разбойников, к лье под водой и к вархаммеру

Давайте я сразу скажу - речь пойдет о биткоинах. При этом не буду вас агитировать за или против - это вообще не мое дело. Я просто расскажу вам о своем отношении к этому феномену и мифам вокруг него.

Для начала стоит сказать, что я не рассматриваю биткоин как валюту. Это не средство, которое заменит кредитные карты или ежедневные расчеты - для этого есть lightning network и другие средства децентрализации. Для меня биткоин - это актив, максимально похожий на золото во всех его проявлениях, кроме физического присутствия. Биткоины добывают, причем, чем больше биткоинов люди уже добыли, тем сложнее добывать дальше. Количество биткоинов, которые вообще можно будет добыть и пустить в оборот, фиксировано. Обмен биткоинами происходит “из рук в руки”. Хранить биткоины не трудно, затратно только получить или передать их. Замените “биткоины” на “золото” - каждое из этих заявлений так же будет действительно.

Поведение “золотых с

@flaviocopes
flaviocopes / check-substring-starts-with.go
Last active June 23, 2024 09:05
Go: check if a string starts with a substring #golang
package main
import (
"strings"
)
func main() {
strings.HasPrefix("foobar", "foo") // true
}
@Yawenina
Yawenina / debounce-lodash.js
Last active May 7, 2024 09:44
lodash debounce and throttle source code
const nativeMax = Math.max;
const nativeMin = Math.min;
function debounce(func, wait, options) {
let lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,