Skip to content

Instantly share code, notes, and snippets.

View RunsFor's full-sized avatar
🎯

Ilya Konyukhov RunsFor

🎯
View GitHub Profile
@RunsFor
RunsFor / install.sh
Last active August 29, 2015 14:17 — forked from sletix/install.sh
#!/usr/bin/env bash
#
# Install latest ruby from brightbox with gems
#
# tested on precise version, and brightbox ruby-1.9.1 package ready for:
# precise(12.04)
#
# run this script on your ubuntu ~>
# `https://gist.githubusercontent.com/RunsFor/7af723f4dea1b73cfce9/raw | sudo bash`
#
@RunsFor
RunsFor / multithreaded.rb
Last active February 1, 2016 22:28
Multithreaded script performs slower than singlethreaded
require 'benchmark'
puts(Benchmark.measure do
count = 0
400_000_000.times do
count += 1
end
end)
puts(Benchmark.measure do
@RunsFor
RunsFor / define_singleton_method_jruby.rb
Last active February 1, 2016 22:04
jruby perform too slow comparing to mri
require 'benchmark'
objects = nil
puts(Benchmark.measure do
objects = 100_000.times.map { Object.new }
block = proc { nil }
objects.each { |obj| obj.define_singleton_method(:test_me, &block) }
end)
@RunsFor
RunsFor / commit-msg.example
Last active August 15, 2016 09:48
Git commit hook to extract issue id from the branch name and prefix commit message with it
#!/bin/bash
BRANCH_NAME=$(git branch | grep '*' | sed 's/* //')
if [ $BRANCH_NAME != '(no branch)' ]
then
# создаем временный файл
tempname="ticket-id-XXXX";
tempfile=`mktemp $tempname`;
@RunsFor
RunsFor / git-clone-graphql.txt
Created February 22, 2019 13:25
git show failed on a healthy commit
$ git clone git@github.com:tarantool/graphql.git
Cloning into 'graphql'...
remote: Enumerating objects: 125, done.
remote: Counting objects: 100% (125/125), done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 2642 (delta 97), reused 99 (delta 89), pack-reused 2517
Receiving objects: 100% (2642/2642), 1.30 MiB | 407.00 KiB/s, done.
Resolving deltas: 100% (1996/1996), done.
$ cd graphql
$ git show e4f77a257e0e77a65992b21c9547529e6b80f78d
@RunsFor
RunsFor / nginx.conf
Last active August 1, 2022 19:48
HTTP terminating tools comparison in tarantool (MacBook Pro 13 2017 3.5 Ghz Intel Core i7, 16GB)
worker_processes 8;
error_log logs/error.log info;
events {
worker_connections 4096;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
sendfile on;
@RunsFor
RunsFor / main.lua
Last active March 27, 2019 15:07
Count nil values in the index
box.cfg{}
statuses = { 'sent', 'delivered' }
uuid = require('uuid')
clock = require('clock')
box.schema.create_space('fragments')
box.space.fragments:create_index('pk')
box.space.fragments:create_index('status', { unique = false, parts = {{3, 'string', is_nullable = true}}})
for i =1,500000,1 do box.space.fragments:insert({i,uuid.str(), statuses[math.random(0,2)]}) end
@RunsFor
RunsFor / tarantool_socket_receive.txt
Created April 9, 2019 10:03
This gist shows inconsistent behaviour of tarantool's socket:receive function which internally uses different buffers for different types of calls
Tarantool 2.1.1-434-g881c7b59b
type 'help' for interactive help
tarantool> socket = require('socket')
---
...
tarantool> fiber = require'fiber'
---
...
@RunsFor
RunsFor / Kafka-segfault.txt
Created June 4, 2019 13:27
tarantool segfault when creating kafka consumer
Tarantool 2.1.1-434-g881c7b59b
type 'help' for interactive help
tarantool> kafka = require'kafka'
---
...
tarantool> consumer, err = kafka.Consumer.create({
> brokers = 'localhost:9292', -- brokers for bootstrap
> options = {
> ["enable.auto.offset.store"] = "true",
@RunsFor
RunsFor / smtp.lua
Last active November 20, 2019 13:28
This snippet tests how smtp client (curl internally) handles error messages from smtp server
#!/usr/bin/env tarantool
local socket = require('socket')
local log = require('log')
local vars = {}
local function smtp_server(s)
s:write('220 localhost ESMTP Tarantool\r\n')
local l