Skip to content

Instantly share code, notes, and snippets.

View swilgosz's full-sized avatar

Seb Wilgosz swilgosz

View GitHub Profile
@swilgosz
swilgosz / keybase.md
Created November 25, 2021 10:02
Keybase Identity

Keybase proof

I hereby claim:

  • I am swilgosz on github.
  • I am swilgosz (https://keybase.io/swilgosz) on keybase.
  • I have a public key ASAqj6aeldNo8wOAOEwCVnMdfwX-0dsDTPKuV6g2N2CXYwo

To claim this, I am signing this object:

@swilgosz
swilgosz / .env_api_dev
Last active May 2, 2022 14:47
Development setup for dockerized Rails API applications.
RAILS_ENV=development
POSTGRES_ADAPTER=postgresql
POSTGRES_USER=postgres
POSTGRES_DB_NAME=sample_api_dev
POSTGRES_HOST=db
DB_PASSWORD=postgres
RAILS_LOG_TO_STDOUT=true
APP_HOME=/app/api
@swilgosz
swilgosz / default.config
Created February 23, 2020 19:48
Try to configure: /* => JS UI and /api/* => to Rails API.
server {
server_name sourcerio.com www.sourcerio.com;
listen 80;
listen 443 ssl http2;
include letsencrypt.conf;
client_max_body_size 10M;
keepalive_timeout 10;
proxy_set_header Host $host;
@swilgosz
swilgosz / pagination_meta_generator.rb
Created January 21, 2020 00:01
A Pagination Meta Generator for fast_jsonapi gem integration.
# frozen_string_literal: true
module Driggl
class PaginationMetaGenerator
DEFAULT_PAGE = 1
DEFAULT_PER_PAGE = 20
def initialize(request:, total_pages:)
@url = request.base_url + request.path
@page = (request.params[:page].presence || DEFAULT_PAGE).to_i
@swilgosz
swilgosz / deserialization.rb
Created June 3, 2019 17:43
How standard create action could look like using the fast_jsonapi gem.
def create
user = User.create!(params.require(:data).require(:attributes))
render json: UserSerializer.new(user), status: 201
end
@swilgosz
swilgosz / encrypted_mapper.rb
Last active February 2, 2019 17:32 — forked from mariuszkapcia/encrypted_mapper.rb
GDPR support for rails_event_store gem.
class EncryptedMapper
MissingEncryptionKey = Class.new(StandardError)
def event_to_serialized_record(domain_event)
metadata = {}
domain_event.metadata.each do |k, v|
metadata[k] = v
end
encryption_schema = domain_event.class.respond_to?(:encryption_schema) && domain_event.class.encryption_schema
@swilgosz
swilgosz / current.js.coffee
Last active May 21, 2018 08:45
This is the approach we have in our legacy JS/Coffee files. We are going to use webpacker in one of our projects and we do want to know which solution is best to achieve the same effect.
# app/assets/javascripts/application.js
#=require 'foo'
# app/assets/javascripts/foo.coffee
init: ->
console.log('this is function defined in foo')