Skip to content

Instantly share code, notes, and snippets.

View ArturT's full-sized avatar

Artur Trzop ArturT

View GitHub Profile
@ArturT
ArturT / config initializers virtus.rb
Created September 23, 2015 17:38
Entity and Repository
EntityVirtus = Virtus.model
ValueObjectVirtus = Virtus.value_object
class UUID < Virtus::Attribute
class String < ::String
end
def coerce(value)
value.present? ? String.new(value) : nil
@ArturT
ArturT / square_spec.rb
Created September 29, 2015 11:43
Exercise. Create class Square to pass tests or implement tests for the class.
require 'rspec'
class Square
def initialize(x, y)
@x = x
@y = y
end
def area
@x * @y
@ArturT
ArturT / presenters.rb
Created September 30, 2015 12:27
Example of BasePresenter and BaseListPresenter
# BASE PRESENTERS
class BasePresenter
def initialize(item)
@item = item
end
def to_hash
raise NotImplementedError
end
@ArturT
ArturT / attempts.rb
Created November 30, 2015 13:52
Delayed_job: On error, the job is scheduled again in 5 seconds + N ** 4, where N is the number of attempts. https://github.com/collectiveidea/delayed_job
def time(n)
5 + n ** 4
end
total_hours = 0
25.times do |n|
seconds = time(n)
puts "---------- #{n} ---------"
puts "Seconds: #{seconds}"
@ArturT
ArturT / prepare-commit-msg.rb
Last active October 31, 2017 15:25 — forked from marioizquierdo/git-commit-msg-jira-trello.rb
git hook prepare commit message for JIRA. It adds story id and story url in commit message.
#!/usr/bin/env ruby
#
# Git prepare-commit-msg hook for JIRA project.
#
# Name your feature brach like: my-feature-STORY_ID for instance feature-LL-123
#
# Install:
# Create a file with this content in `yourproject/.githooks/prepare-commit-msg`
# or put this file somewhere, for example `~/.githooks/prepare-commit-msg`, and symlink it:
#
@ArturT
ArturT / README.md
Last active October 24, 2016 18:59 — forked from joakimk/README.md
CircleCI elixir build example

This runs a build for a small elixir (phoenix) project in about 40 seconds by caching as much of the compiled files as possible.

We've been using this for months in multiple projects without any issues. Please ping be if there is any issues with this script and I'll update it.

It should be generic enough to work on any elixir app using mix.

If you have a elixir_buildpack.config, then enable that section in the build script to keep versions in sync!

Extra note

@ArturT
ArturT / Fix OpenSSL Padding Oracle vulnerability (CVE-2016-2107) - Ubuntu 14.04
Last active June 20, 2018 11:46
Fix OpenSSL Padding Oracle vulnerability (CVE-2016-2107) - Ubuntu 14.04
# Based on http://fearby.com/article/update-openssl-on-a-digital-ocean-vm/
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ wget ftp://ftp.openssl.org/source/openssl-1.0.2h.tar.gz
$ tar -xvzf openssl-1.0.2h.tar.gz
$ cd openssl-1.0.2h
$ ./config --prefix=/usr/
$ make depend
@ArturT
ArturT / init.coffee
Created November 10, 2016 17:12
Toggle vim mode plus in Atom editor. Based on http://chibicode.com/useful-atom-vim-mode-snippets/
atom.commands.add 'atom-text-editor',
'user:toggle-vim-mode-plus': (event) ->
if atom.packages.isPackageDisabled("vim-mode-plus")
atom.packages.enablePackage("vim-mode-plus")
else
atom.packages.disablePackage("vim-mode-plus")
@ArturT
ArturT / virtus_spec.rb
Created November 24, 2016 13:29
FakeEntity Virtus model with overridden status.
require 'spec_helper'
class FakeEntity
include Virtus.model(coerce: true)
attribute :status, String
attribute :internal_status, String
def initialize(**kwargs)
super
@ArturT
ArturT / circle.yml
Last active May 1, 2017 14:40
How to auto balance CI build with RSpec in Queue Mode and yarn tests executed only on first CI node
test:
override:
# run yarn tests only on first CI node
# note we will do yarn install on first CI node so other CI nodes can run rspec tests in the mean time
- case $CIRCLE_NODE_INDEX in 0) bundle exec yarn install; yarn flow -- check; yarn test -- --runInBand ;; esac:
parallel: true # Caution: there are 8 spaces indentation!
# Step for Dynamic RSpec allocation
# It will auto balance the whole build
- bundle exec rake knapsack_pro:queue:rspec: