Skip to content

Instantly share code, notes, and snippets.

@maicher
maicher / gist:db59b29cb6054e63855ffe1c4030dd9d
Last active April 14, 2021 14:48
webdevelopment zagadnienia
- grafika
- - konwertowanie obrazków pomiędzy formatami
- - rodzaje kompresji, formaty obrazów i ich cechy (np że png waży więcej od jpg i dlaczego)
- - popularne filtry
- - cięcie layoutu - co to znaczy, jak się to robi
- - czym się różni grafika wektorowa od rastrowej
- - przeźroczyste tło w obrazkach (wady, zalety)
- opensource i free software
- - co to znaczy? na czym polega?
- - popularne projekty opensource
@maicher
maicher / fraud.rb
Created January 28, 2020 13:53
Fraud user
u = User.new(params)
if u.save
# redirect
else
# render form with errors
end
# task: Dodać sprawdzanie czy user jest fraudem.
@maicher
maicher / controller.rb
Created January 28, 2020 13:35
Inputs with dry-validation v2
def new
# initialize a hash from
@inputs = Form.new(
user_name: '',
some_field: some_object.default_some_field,
something: {
a: '',
b: 'some default value'
}
)
@maicher
maicher / controller.rb
Last active January 28, 2020 13:35
Inputs with dry-validation v1
def new
# initialize a hash from
@inputs = {
user_name: '',
some_field: some_object.default_some_field,
something: {
a: '',
b: 'some default value'
}
}
class CreateUser
class Error < StandardError; end
# ...
end
# contoller
begin
user = CreateUser.new(params).call
p "User #{user.username} created succesfully"
@maicher
maicher / sequence_diagrams_01.rb
Created February 1, 2018 11:22
Sequence diagrams
class A
def call
# do something
end
end
class B
def call(argument)
# do something different
end
@maicher
maicher / cache_proposal.md
Last active December 13, 2017 12:08
My proposal for implementing caching in OfferProvider componenet

Caching in OfferProvider

  • Why? - To improve performance (that is not call db an each provider request).
  • Where? - At the point of fething data from OfferProvider component (repositories).
  • How? - By using Rails.cache#fetch

Introduction

Why we don't like caching?

@maicher
maicher / git
Last active June 14, 2017 13:44
Some useful git commands
# Managing own fork
### Configure upstream
git remote -v
git remote add upstream git@github.com:wimdu/wimdu.git
### Syncing to upstream
git checkout master
git fetch upstream master
git reset --hard upstream/master
@maicher
maicher / print_translations.rb
Created May 12, 2017 15:37
Script for generating translation hash. For passing I18n translations to frontend.
def print_translations(hash, phrase_key, i = 0)
hash.each do |k, v|
if v.is_a?(Hash)
i.times { print ' ' }
print "#{k.to_s.camelize(:lower)}: {\n";
print_translations(v, "#{phrase_key}.#{k}", i + 1)
i.times { print ' ' }
print "},\n"
else i.times { print ' ' }
print "#{k.to_s.camelize(:lower)}: t('#{phrase_key}.#{k}'),\n"
@maicher
maicher / container.rb
Last active February 3, 2017 14:07
Container pattern
module Container
# Initialized once (kind'a singleton)
def self.a
@a ||= Object.new
end
# Initialized every time.
def self.b
Object.new
end