Instantly share code, notes, and snippets.

Coding every day...

Vasily Kolesnikov v-kolesnikov

View GitHub Profile
View jwt.rb
# frozen_string_literal: true
require 'bundler/inline'
gemfile(true) do
gem 'jwt'
gem 'rspec'
require 'jwt'
View ecdsa_example.rb
require 'openssl'
require 'base64'
# ===== \/ sign =====
# generate keys
key ="secp256k1")
public_key = key.public_key
public_key_hex = public_key.to_bn.to_s(16).downcase # public key in hex format
View spec_helper.rb
# 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
View id_in_schema_spec.rb
#!/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
View context.yml
- name: Adobe Systems
name2: Adobe Systems Inc.
symbol: ADBE
price: 39.26
change: 0.13
ratio: 0.33
- name: Advanced Micro Devices
name2: Advanced Micro Devices Inc.

ROM-SQL and serialized YAML data

New projects that use rom-db interact with existing db schemas quite often, especially with schemas that are built on top of Rails applications. And you can probably came across to a serialized YAML data here. ActiveRecord provides API to store unstructured key-value data into single database column with serialize method:

# Serialize preferences as Hash using YAML coder.
class User < ActiveRecord::Base
  serialize :preferences, Hash
View timezone_helper.rb
require 'faker'
RSpec.configure do |config|
config.before do
ENV['TZ'] = Faker::Address.time_zone
View Vagrantfile
# frozen_string_literal: true
# -*- mode: ruby -*-
# vi: set ft=ruby :
script = <<~SCRIPT
# Update apt and get dependencies
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y unzip curl vim \
apt-transport-https \
View karabiner.json
"title": "Diamond Cursor",
"rules": [
"description": "Change fn + I/J/K/L to Arrow Keys",
"manipulators": [
"type": "basic",
"from": {
"key_code": "i",