Skip to content

Instantly share code, notes, and snippets.

View belgoros's full-sized avatar

Serguei Cambour belgoros

View GitHub Profile
@belgoros
belgoros / Guardian JWT.md
Created October 24, 2019 14:04 — forked from nikneroz/Guardian JWT.md
Elixir + Phoenix Framework + Guardian + JWT. This is tutorial and step by step installation guide.

Elixir + Phoenix Framework + Guardian + JWT + Comeonin

Preparing environment

We need to generate secret key for development environment.

mix phoenix.gen.secret
# ednkXywWll1d2svDEpbA39R5kfkc9l96j0+u7A8MgKM+pbwbeDsuYB8MP2WUW1hf

Let's generate User model and controller.

@belgoros
belgoros / example.rb
Last active November 19, 2019 16:28
AMS for a non-AR model, Rails 5.2.3
# models/user.rb
class User
include ActiveModel::Model
attr_accessor :username, :first_name, :last_name, :id
end
#serializers/user_serializer.rb
class UserSerializer < ActiveModelSerializers::Model
attributes :id, :first_name, :last_name, :username
@belgoros
belgoros / en.yml
Created March 15, 2020 16:12
Rails 6 translation file example
en:
hello: "Hello !"
world: "Hello World !"
@belgoros
belgoros / gist:6a8b233ea70abd449202aa3baecbdffa
Created July 31, 2020 07:46 — forked from leftclickben/gist:322b7a3042cbe97ed2af
Steps to migrate from SVN to GitLab

Steps to migrate from SVN to GitLab

This process worked for me. I take no responsibility for any damage or loss incurred as a result of following or not following these steps or, for that matter, anything else you might do or not do.

Setup

  • SVN is hosted at svn.domain.com.au.
  • SVN is accessible via http (other protocols should work).
  • GitLab is hosted at git.domain.com.au and:
@belgoros
belgoros / spring_dynamodb_errors.txt
Created August 16, 2020 16:50
Spring and DynamoDB integration test errors
➜ spring-dynamodb-integration git:(master) mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ---< com.nibado.example.spring-testcontainers:spring-testcontainers >---
[INFO] Building spring-testcontainers 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ spring-testcontainers ---
[INFO] Deleting /Users/serguei/projects/java/spring-dynamodb-integration/target
[INFO]
@belgoros
belgoros / git_configuration.md
Created August 31, 2020 13:49
Customizing Git - Git Configuration

Customizing Git - Git Configuration

Setup your credentials

git config --global user.name "Firstname Lastname"
git config --global user.email "your.email@example.org"

Avoid merge commits for pulling

@belgoros
belgoros / stored_procedure_service.rb
Created May 8, 2021 15:53 — forked from ys/stored_procedure_service.rb
Execute stored procedure
class StoredProcedureService
def self.instance
@instance ||= StoredProcedureService.new
end
def execute(name, *args)
results = []
begin
connection.execute("CALL #{name}(#{args.join(',')})").each(as: :hash, symbolize_keys: true) do |row|
{
"id": "Demo-Realm",
"realm": "Demo-Realm",
"notBefore": 0,
"revokeRefreshToken": false,
"refreshTokenMaxReuse": 0,
"accessTokenLifespan": 300,
"accessTokenLifespanForImplicitFlow": 900,
"ssoSessionIdleTimeout": 1800,
"ssoSessionMaxLifespan": 36000,
{
"info": {
"_postman_id": "55e9873b-b947-49c8-9fca-a98a8ac41587",
"name": "keycloak",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "token-employee1",
"request": {
{
"aud": [
"server"
],
"iat": 1621503452,
"auth_time": 1621503452,
"exp": 1621539452,
"iss": "http://localhost:8080/auth/realms/Demo-Realm",
"sub": "user",
"scope": "openid",