Skip to content

Instantly share code, notes, and snippets.

Pavel Evstigneev Paxa

Block or report user

Report or block Paxa

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
@Paxa
Paxa / swagger.slim
Created Apr 24, 2019
swagger ui dist
View swagger.slim
doctype html
html[lang="en"]
head
meta(charset="UTF-8")
title Installments API
link[rel="stylesheet" type="text/css" href="//unpkg.com/swagger-ui-dist@3/swagger-ui.css"]
body
#swagger-ui
@Paxa
Paxa / debug.conf
Created Jan 21, 2019
Nginx minimal config for debugging
View debug.conf
# run with:
# nginx -c $(pwd)/debug.conf
daemon off;
worker_processes 1;
events {
worker_connections 128;
}
@Paxa
Paxa / icco_example.rb
Created Mar 29, 2018
fog-backblaze example
View icco_example.rb
gem 'fog-core', '>2.0'
gem 'fog-backblaze'
require 'fog/core'
require 'fog/backblaze'
TEST_BUCKET = ENV['B2_BUCKET'] || 'fog-demo-1505931432'
if !ENV['B2_ACCOUNT_ID'] || ENV['B2_ACCOUNT_ID'] == ""
puts "Missing env B2_ACCOUNT_ID"
View connect.rb
tcp_socket = Socket.tcp("mysite.com", 32500, connect_timeout: 60)
ssl_context = OpenSSL::SSL::SSLContext.new()
ssl_context.client_cert_cb = Proc.new do
[
OpenSSL::X509::Certificate.new(File.open("./client.crt")),
OpenSSL::PKey.read(File.open("./client.key"))
]
end
View _usage.js
const express = require('express');
const asyncRouter = require('../lib/async_router');
var router = asyncRouter(express.Router());
router.get('/', async (req, res, next) => {
// mkaing async errors
});
@Paxa
Paxa / 1.rb
Created Jul 13, 2017
rabbit migrate
View 1.rb
desc "Create rabbitmq setup"
task :setup_rabbit => :environment do
QueueWorker::HostSelector.mute_logger
Rails.logger = Logger.new(STDOUT)
options = {}
if ENV['UNDO']
options = {delete_all: true, raise_errors: false}
end
if ENV['RECREATE']
@Paxa
Paxa / 1_output_jakarta_to_singapore.txn
Last active May 12, 2017
Persistent HTTPS vs not persistent
View 1_output_jakarta_to_singapore.txn
Run from cloud server in Jakarta, sending requests to cloud server in Singapore
Warming up --------------------------------------
excon 1.000 i/100ms
net-http2 1.000 i/100ms
net-http 1.000 i/100ms
net-http2 persistent 6.000 i/100ms
excon persistent 5.000 i/100ms
http persistent 6.000 i/100ms
Calculating -------------------------------------
@Paxa
Paxa / async.rb
Last active May 12, 2017
Safe way to run threads on rails
View async.rb
module Async
##
# Run code in thread, handle exceptions, release DB connections
#
# Async(:send_email) { Mailer.send }
#
def self.run(name)
parent_t = Thread.current
working_thread = Thread.new do
begin
@Paxa
Paxa / ar_pool_stats.rb
Created Apr 20, 2017
ActiveRecord pool stats for Rails < 5.1
View ar_pool_stats.rb
unless ActiveRecord::ConnectionAdapters::ConnectionPool.method_defined?(:stat) # will be in Rails 5.1
class ActiveRecord::ConnectionAdapters::ConnectionPool
def stat
synchronize do
{
size: size,
connections: @connections.size,
busy: @connections.count { |c| c.in_use? && c.owner.alive? },
dead: @connections.count { |c| c.in_use? && !c.owner.alive? },
idle: @connections.count { |c| !c.in_use? },
View .tm_properties
invisiblesMap = "~ \t┊"
include = "{$include,.*}"
exclude = "{$exclude,.git,tmp/cache}"
You can’t perform that action at this time.