Skip to content

Instantly share code, notes, and snippets.

View sshkarupa's full-sized avatar

Sergey Shkarupa sshkarupa

View GitHub Profile
@sshkarupa
sshkarupa / Dockerfile.yml
Created May 29, 2020 13:14 — forked from jgould22/Dockerfile
Postgres 12 - Alpine - pg_partman with pg_jobmon
FROM postgres:12-alpine
MAINTAINER Jordan Gould <jordangould@gmail.com>
# Based on https://github.com/andreaswachowski/docker-postgres/blob/master/initdb.sh
ENV PG_JOBMON_VERSION v1.3.3
ENV PG_PARTMAN_VERSION v4.2.2
# Install pg_jobmon
RUN set -ex \
\
@sshkarupa
sshkarupa / keybase.md
Created September 14, 2019 11:38
Keybase proof

Keybase proof

I hereby claim:

  • I am sshkarupa on github.
  • I am sshkarupa (https://keybase.io/sshkarupa) on keybase.
  • I have a public key ASB6KLzzD7c6kcrDMpj4Yez-HTtg-aU7fMDKwDTDIIllDQo

To claim this, I am signing this object:

@sshkarupa
sshkarupa / Makefile
Created May 26, 2019 13:52 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
tap 'homebrew/bundle'
tap 'homebrew/cask'
tap 'homebrew/core'
brew 'zsh'
brew 'ansible'
brew 'awscli'
brew 'webp'
brew 'gist'
brew 'git'
brew 'jq'
@sshkarupa
sshkarupa / gist:90b19d1e1534f7a8a249238c26e665f3
Created February 18, 2019 20:32 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@sshkarupa
sshkarupa / cheatsheet.md
Created November 4, 2018 16:09
Elixir cheat sheet

Elixir Cheat Sheet

Getting started

Hello world

# hello.exs
defmodule Greeter do
 def greet(name) do
@sshkarupa
sshkarupa / saga.rb
Created October 26, 2018 19:59 — forked from sclinede/saga.rb
Example of Full Saga implementation in Ruby (with Usage example, also)
class Saga
class << self
def with_redis; raise NotImplementedError; end
attr_accessor :cleanup_delay, :queue, :last_txid
def queue
Thread.current[:saga_queue] ||= []
end
def last_txid
module SimpleRailway
class Result
attr_accessor :success, :data
def initialize(success, data)
@success = success
@data = data
end
def success?; !!success; end
def failure?; !success?; end
# Usage:
#
# class Mail
# include SimpleStateMachine
#
# self.initial_state = 'unread'
# self.transitions_map = {
# read: {from: 'unread', to: 'read'},
# unread: {from: 'any', to: 'unread'},
# delete: {from: 'any', to: 'deleted'},
@sshkarupa
sshkarupa / rails-jsonb-queries
Created September 24, 2018 12:37 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")