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 / app.rb
Created May 23, 2020 09:08
Single file Rails app
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rails', '~> 6.0'
end
require 'action_controller/railtie'
@v-kolesnikov
v-kolesnikov / Gemfile
Last active April 3, 2023 11:31
Asynchronous files downloader.
# frozen_string_literal: true
source "https://rubygems.org"
gem 'down'
gem 'dry-monads'
gem 'http'
@v-kolesnikov
v-kolesnikov / config.ru
Last active June 9, 2019 19:53
Uploading 765MB file with `ethon` gem
# frozen_string_literal: true
require 'rack'
run Rack::URLMap.new(
'/upload' => ->(*) { [200, {}, []] }
)
@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

# frozen_string_literal: true
require 'bundler/inline'
gemfile(true) do
gem 'jwt'
gem 'rspec'
end
require 'jwt'
@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 / spec_helper.rb
Created December 13, 2018 12:42
Using a container to manage tests components
# frozen_string_literal: true
require_relative '../system/my_app/container'
module MyApp
module Tests
class Container < Dry::System::Container
use :env, inferrer: -> { 'test' }
configure do
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/inline'
gemfile(true) do
gem 'dry-types', '0.13.3'
gem 'mysql2'
gem 'rom-repository', '2.0.2', require: false
@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.