Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
module Types
class Hashid < GraphQL::Schema::Scalar
graphql_name "UID"
default_scalar true
description "Unique identifer"
def self.coerce_input(value, _ctx)
HashidHelper.decode(value)
@numbata
numbata / resume.json
Last active July 4, 2019 00:38
resume_data
{
"meta": {
"theme": "elegant"
},
"basics": {
"name": "Andrei Subbota",
"label": "Senior Ruby Developer",
"email": "subbota@gmail.com",
"phone": "+357-9557-5417",
"skype": "subbota_gmail.com",
require 'pathname'
def rwalk(path)
current_directory = Pathname.new(path)
breadcrumbs = [[current_directory, Dir.foreach(current_directory)]]
Enumerator.new do |y|
loop do
current_directory, current_iterator = breadcrumbs.last
@numbata
numbata / README.md
Last active October 17, 2017 07:37

Суть задания

Предлагается написать клиента для вымышленного сервиса базы-кинофильмов. Сервис предоставляет api, который отдает список фильмов. Формат выдачи такой:

https://gist.github.com/numbata/5ed307d7953c3f7e716f/b7887adc444188d8aa8e61d39b82950f28c03966

Можно грузить json напрямую с гитхаба:

https://gist.githubusercontent.com/numbata/5ed307d7953c3f7e716f/raw/b7887adc444188d8aa8e61d39b82950f28c03966/movies.json
@numbata
numbata / docker-run-ssh
Last active September 11, 2015 11:54
docker-compose patсh
#!/bin/bash
# cat /usr/local/bin/docker-run-ssh
# "docker run" with SSH Agent Forwarding for boot2docker
# QuickStart:
# 1. Download to ~/bin/docker-run-ssh and chmod +x it
# 2. docker-run-ssh [normal args to docker run...]
# Use a unique ssh socket name per-invocation of this script
@numbata
numbata / web-servers.md
Last active August 29, 2015 14:27 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@numbata
numbata / split_sql.sh
Created August 29, 2012 08:35
split a sql file into per-table
#!/bin/bash
# Splitting a sql file containing a whole database into per-table files is quite easy:
# - Grep the .sql for any occurence of DROP TABLE.
# - Generate the file name from the table name that is included in the DROP TABLE statement.
# - Echo the output to a file.
# by Marcus Pauli
file=$1 # the input file
directory="$file-splitted" # the output directory
@numbata
numbata / http_status_codes.rb
Created August 21, 2012 12:52
Ruby status Code symbols
# 1.9.3-p194 :015 > pp Rack::Utils.const_get('HTTP_STATUS_CODES')
{100=>"Continue",
101=>"Switching Protocols",
102=>"Processing",
200=>"OK",
201=>"Created",
202=>"Accepted",
203=>"Non-Authoritative Information",
204=>"No Content",
205=>"Reset Content",
# Example
> ./rpn.rb '3 + 4 * 2 / (1 - 5) * 2'
RPN: 3 4 2 * 1 5 - / 2 * +
Result: -1.0
@numbata
numbata / rwt.sh
Created January 23, 2012 08:55
MySQL replcation waiting estimated time
# Грубые наброски
# 1327306923
# 217341
watch -n 2 'E=`mysql -u root -A -e "show slave status \G" | grep "Seconds_Behind_Master" | grep -o -E "[0-9]+"`;T=`date +%s`;TT=`expr 217341 - $E`;EE=`expr $T - 1327306923`;S=`echo "scale=2; $TT/$EE"|bc`;ES=`echo "scale=2; $E/$S/60"|bc`;echo "Estimates minutes: $ES . Speed: $S"'