Skip to content

Instantly share code, notes, and snippets.

View palkan's full-sized avatar
✈️
Transcontinental hustle

Vladimir Dementyev palkan

✈️
Transcontinental hustle
View GitHub Profile
@cheeaun
cheeaun / rdrc2017.md
Last active October 11, 2017 06:56
RedDotRubyConf 2017 links & resources 😘
class Object
def defer(method, *args)
@current_fibers ||= []
@tracepoint ||= TracePoint.trace(:return) do |tp|
@current_fibers.reverse_each do |fib|
fib.resume
end
end
@current_fibers << Fiber.new do
module ApplicationPolicy
READ = :read
MANAGE = :manage
MANAGE_FIELD = { parent_role: MANAGE } # NOTE(rstankov): Used for GraphQL fields
UPDATE = :update
MODERATE = :moderate
@Earendil95
Earendil95 / task_hooks.md
Last active August 8, 2019 17:12
Git hooks for automatic reference issues in commit

Description

This hooks will remind you to reference task in your commit, and remember your task ref for branch. Your commit messages will have style "[reference] message"

Usage

  1. Create two files in your repo - e.g. [PROJECT_ROOT]/hooks/prepare-commit-msg.rb and [PROJECT_ROOT]/hooks/post-checkout.rb
  2. Copy to first file (here will assume that this is a [PROJECT_ROOT]/hooks/prepare-commit-msg.rb):
#!/usr/bin/env ruby
@avlazarov
avlazarov / grpc.conf
Last active August 23, 2019 14:51
AnyCable gRPC connection issue
upstream grpcservers {
server 0.0.0.0:50051;
server 0.0.0.0:50052;
}
server {
listen 50050 http2;
server_name localhost;
access_log /var/log/nginx/grpc_log.json;
@palkan
palkan / postgres_queries_and_commands.sql
Last active December 5, 2019 13:01 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query

Benchmarks for GC Compactor

GC benchmarks for trunk vs gc-compact seem to be about the same:

$ make benchmark ITEM=gc
./revision.h unchanged
/Users/aaron/.rbenv/shims/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
	            --executables="compare-ruby::/Users/aaron/.rbenv/shims/ruby --disable=gems -I.ext/common --disable-gem" \
	            --executables="built-ruby::./miniruby -I./lib -I. -I.ext/common  -r./prelude --disable-gem" \
@Ceroce
Ceroce / recursion.erl
Created June 27, 2017 10:09
Erlang: Fibonacci with Tail recursion + determining if an integer is perfect.
-module(recursion).
-export([fib/1, fibtail/1, fibtail/3, isPerfect/1]).
fib(0) ->
0;
fib(1) ->
1;
fib(N) when N > 0 ->
fib(N-1)+fib(N-2).
--- Setup
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
DROP TABLE IF EXISTS planner_checksums CASCADE;
CREATE TABLE IF NOT EXISTS planner_checksums (
identifiers_checksum uuid,
attributes_checksum uuid,
version INT
);
CREATE INDEX planner_checksums_idx ON planner_checksums(identifiers_checksum);
@palkan
palkan / 00_Readme.md
Last active July 16, 2022 06:50
graphql-ruby fragment caching

PoC: GraphQL Ruby fragment caching

This example demonstrates how we can cache the response fragments in graphql-ruby.

Existing solutions only allow caching resolved values but not all the GraphQL machinery (validation, coercion, whatever).

Caching response parts (in case of Ruby, sub-Hashes) is much more efficient.

Benchmarks