Skip to content

Instantly share code, notes, and snippets.

View asux's full-sized avatar

Oleksandr Ulianytskyi asux

View GitHub Profile
@asux
asux / sort_collection_validation.rb
Created July 27, 2018 11:52
SortCollection with Validated
# frozen_string_literal: true
module Bl
module Core
module Logic
class SortCollection
include Dry::Monads::Result::Mixin
include Dry::Monads::Validated::Mixin
include Dry::Monads::List::Mixin
include Dry::Monads::Do::All
@asux
asux / sort_collection.rb
Created July 27, 2018 11:50
SortCollection original
# frozen_string_literal: true
module Bl
module Core
module Logic
class SortCollection
include Dry::Monads::Result::Mixin
ALLOWED_ORDER_BY = %i[created_at updated_at rating votes_count last_activity_date answers_count].freeze
ALLOWED_ORDER_DIRS = %i[asc desc].freeze
@asux
asux / curl-lumosity
Created May 25, 2017 14:05
Unable reach lumosity.com from NordVPN
curl -v https://www.lumosity.com/ 2.4.1
* Trying 52.3.47.247...
* TCP_NODELAY set
* Connected to www.lumosity.com (52.3.47.247) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: *.lumosity.com
* Server certificate: RapidSSL SHA256 CA
* Server certificate: GeoTrust Global CA
> GET / HTTP/1.1
> Host: www.lumosity.com

Keybase proof

I hereby claim:

  • I am asux on github.
  • I am asux (https://keybase.io/asux) on keybase.
  • I have a public key whose fingerprint is 28C1 659A 5D5C 1D14 992B 6C32 D849 8251 A425 E31E

To claim this, I am signing this object:

@asux
asux / README.md
Last active August 29, 2015 14:15
Simple API design for store

Simple API design for store

Simple API design for WebGroup.

Data model

Store has categories and products beloned to. Each product may has several tags.

Response formats

All api calls returns data as JSON or XML. You must set Accept header to determine response format, eg Accept: application/json. If unsupported format given, server returns 406 Not acceptable.

@asux
asux / account.rb
Created May 14, 2014 14:29
with_visitor
def with_visitor
@depth = @depth.to_i + 1
@visitor ||= Interface::Millennial::Visitor.new(self)
yield @visitor
@visitor
ensure
@depth = @depth - 1
if @visitor and @depth == 0
@visitor.finish if @visitor
@visitor = nil
@asux
asux / Gemfile
Created March 13, 2013 14:12
Typical :development, :test groups for rails app
group :development do
gem 'capistrano'
gem 'capistrano_colors'
gem 'capistrano-unicorn',require: false
gem 'capistrano-deploy', require: false
gem 'rvm-capistrano', require: false
gem 'sextant'
gem 'awesome_print'
gem 'quiet_assets'
@asux
asux / open_subl
Last active December 11, 2015 20:39
Sublime Text 2 URI Handler for subl:// and txmt://
#!/usr/bin/env ruby
# /usr/local/bin/open_subl
require 'cgi'
require 'uri'
begin
query = CGI.parse(URI.parse(ARGV.first).query)
url = query['url'].first
file = URI.parse(url).path
line = query['line'].first
column = query['column'].first
@asux
asux / gist:4058567
Created November 12, 2012 10:34
git commit squashing
# Go back to the last commit that we want to form the initial commit (detach HEAD)
git checkout <sha1_for_B>
# reset the branch pointer to the initial commit,
# but leaving the index and working tree intact.
git reset --soft <sha1_for_A>
# amend the initial tree using the tree from 'B'
git commit --amend
@asux
asux / thin
Created October 2, 2012 15:24
rvm and bundler aware thin initscript for Gentoo
#!/sbin/runscript
### BEGIN INIT INFO
# Provides: thin
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: thin initscript
# Description: thin
### END INIT INFO