Skip to content

Instantly share code, notes, and snippets.

View v-kolesnikov's full-sized avatar
✍️
I'm writing something just now! You can write me too! 😉

Vasily Kolesnikov v-kolesnikov

✍️
I'm writing something just now! You can write me too! 😉
View GitHub Profile
@v-kolesnikov
v-kolesnikov / uuid.rb
Created July 24, 2023 15:51 — forked from brandur/uuid.rb
UUID data type in Ruby
# typed: strict
# frozen_string_literal: true
require "base32"
require "securerandom"
require "ulid"
# A type to represent UUIDs. Particularly useful for annotating fields in API
# representations or Sorbet parameters to help prevent accidentally mixing up
# UUIDs and EIDs as they're being passed around as loose strings.
@v-kolesnikov
v-kolesnikov / hugofastsearch.md
Created June 22, 2022 13:52 — forked from cmod/hugofastsearch.md
Fast, instant client side search for Hugo static site generator

Super fast, keyboard-optimized, client side Hugo search

This is a fork of and builds upon the work of Eddie Webb's search and Matthew Daly's search explorations.

It's built for the Hugo static site generator, but could be adopted to function with any json index compatible with Fuse fuzzy search library.

To see it in action, go to craigmod.com and press CMD-/ and start typing.

Fast Search

@v-kolesnikov
v-kolesnikov / http_streaming.md
Created May 30, 2019 17:08 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@v-kolesnikov
v-kolesnikov / ecdsa_example.rb
Created December 29, 2018 11:55 — forked from ostinelli/ecdsa_example.rb
ECDSA usage from Ruby.
require 'openssl'
require 'base64'
# ===== \/ sign =====
# generate keys
key = OpenSSL::PKey::EC.new("secp256k1")
key.generate_key
public_key = key.public_key
public_key_hex = public_key.to_bn.to_s(16).downcase # public key in hex format
@v-kolesnikov
v-kolesnikov / context.yml
Created July 10, 2018 09:44 — forked from adam12/context.yml
ERB vs Erubis vs Erubi
list:
- name: Adobe Systems
name2: Adobe Systems Inc.
url: http://www.adobe.com
symbol: ADBE
price: 39.26
change: 0.13
ratio: 0.33
- name: Advanced Micro Devices
name2: Advanced Micro Devices Inc.
@v-kolesnikov
v-kolesnikov / latency.txt
Created November 10, 2017 14:52 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD

LLDB Cheat Sheet

A complete gdb to lldb command map.

Print out

  • Print object
(lldb) po responseObject
(lldb) po [responseObject objectForKey@"state"]
  • p - Print primitive type
class Jobs < ROM::Relation[:sql]
schema(:jobs) do
# ...
associations do
belongs_to :team
belongs_to :template
belongs_to :address
belongs_to :client
end
@v-kolesnikov
v-kolesnikov / _post.md
Created April 17, 2017 10:23 — forked from klapaucius/_post.md
spine-strict_lists

Строгость и нищета списков.

Map и структурная рекурсия.

Применить функцию к каждому элементу списка - это просто: ###GHC/Base.lhs

map _ []     = []
map f (x:xs) = f x : map f xs
@v-kolesnikov
v-kolesnikov / env_validation.rb
Created September 18, 2016 10:16 — forked from flash-gordon/env_validation.rb
ENV validation POC
require 'dry-validation'
class EnvValidation
class ENV
def inspect
ivs = instance_variables.each { |v| "#{v}=#{instance_variable_get(v)}" }.join(', ')
"ENV[#{ivs}]"
end
def to_s