Skip to content

Instantly share code, notes, and snippets.

👨‍🔬
Coding every day...

Vasily Kolesnikov v-kolesnikov

Block or report user

Report or block v-kolesnikov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View jwt.rb
# 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 Dec 29, 2018 — forked from ostinelli/ecdsa_example.rb
ECDSA usage from Ruby.
View ecdsa_example.rb
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 Dec 13, 2018
Using a container to manage tests components
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
@v-kolesnikov
v-kolesnikov / context.yml
Created Jul 10, 2018 — forked from adam12/context.yml
ERB vs Erubis vs Erubi
View context.yml
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.
View rom_sql_yaml.md

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
end
@v-kolesnikov
v-kolesnikov / timezone_helper.rb
Created Mar 8, 2018
Ruby timezone invariable tests
View timezone_helper.rb
require 'faker'
RSpec.configure do |config|
config.before do
ENV['TZ'] = Faker::Address.time_zone
end
end
@v-kolesnikov
v-kolesnikov / Vagrantfile
Last active Apr 18, 2018
Nomad sandbox
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",
You can’t perform that action at this time.