Skip to content

Instantly share code, notes, and snippets.

require "pry-byebug"
require "openssl"
require "jwt"
require "securerandom"
priv_key = File.open("path/to/private/key") do |f|
OpenSSL::PKey.read(f.read)
end
payload = {
ActiveRecord::Delegation.delegate :as_csv, to: :records
class Hash
def as_csv
values
end
end
class Object
def as_csv(options = nil) #:nodoc:
require "pry-byebug"
require "openssl"
require "jwt"
require "securerandom"
priv_key = File.open(ENV.fetch("IDENT_PRIV_KEY")) do |f|
OpenSSL::PKey.read(f.read)
end
profile = {
@ysv
ysv / migr.rb
Last active January 29, 2020 15:13
# frozen_string_literal: true
class RemoveLegacyUsers < ActiveRecord::Migration[6.0]
def change
add_index :asset_proposals, %i[code owner_id], unique: true
add_index :asset_proposals, %i[contract_address owner_id], unique: true
end
end
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "applogic.name" -}}
{{- printf "applogic" -}}
{{- end -}}
{{/*
@ysv
ysv / config.rb
Last active September 9, 2019 09:50
module MyApp
def config
Config.instance
end
class Config
include Singleton
attr_reader :env
@ysv
ysv / car.rb
Created September 4, 2019 17:29
RPM_TO_SPEED_MULTIPLIER = 10
class Tire
def initialize(producer:, diameter:)
@producer = producer
@diameter = diameter
@dirty = [true, false].sample
end
def dirty
D, [2019-08-31T15:55:06.908599 #45740] DEBUG -- : Trade Load (1.1ms) SELECT `trades`.* FROM `trades` ORDER BY `trades`.`id` ASC LIMIT 1
D, [2019-08-31T15:55:06.908599 #45740] DEBUG -- : ↳ lib/tasks/kafka.rake:38
D, [2019-08-31T15:55:06.930825 #45740] DEBUG -- : Market Load (1.2ms) SELECT `markets`.* FROM `markets` WHERE `markets`.`id` = 'btcusd'
D, [2019-08-31T15:55:06.930961 #45740] DEBUG -- : ↳ lib/tasks/kafka.rake:38
D, [2019-08-31T15:55:06.949899 #45740] DEBUG -- : Member Load (2.0ms) SELECT `members`.* FROM `members` WHERE `members`.`id` = 57
D, [2019-08-31T15:55:06.950030 #45740] DEBUG -- : ↳ lib/tasks/kafka.rake:38
D, [2019-08-31T15:55:06.960981 #45740] DEBUG -- : Order Load (1.4ms) SELECT `orders`.* FROM `orders` WHERE `orders`.`id` = 1791
D, [2019-08-31T15:55:06.961084 #45740] DEBUG -- : ↳ lib/tasks/kafka.rake:38
D, [2019-08-31T15:55:06.987764 #45740] DEBUG -- : Member Load (1.6ms) SELECT `members`.* FROM `members` WHERE `members`.`id` = 57
D, [2019-08-31T15:55:06.987868 #45740]
@ysv
ysv / pairs.rb
Last active August 29, 2019 14:49
squad = %w[Ania Dania Andrey Anton Pasha]
squad.shuffle
.append(squad.sample)
.each_slice(2) { |f, s| pp "#{f} and #{s}"}
CURRENCY_PARAMS = {
name: { desc: -> { API::V2::Admin::Entities::Currency.documentation[:name][:desc] } },
deposit_fee: {
type: { value: BigDecimal, message: 'admin.currency.non_decimal_deposit_fee' },
values: { value: -> (p){ p >= 0 }, message: 'admin.currency.invalid_deposit_fee' },
desc: -> { API::V2::Admin::Entities::Currency.documentation[:deposit_fee][:desc] },
default: 0.0
}
#...
}