Skip to content

Instantly share code, notes, and snippets.

View belgoros's full-sized avatar

Serguei Cambour belgoros

View GitHub Profile
@belgoros
belgoros / application_context_load_error.txt
Last active August 17, 2023 08:48
Spring Boot: fails to to load ApplicationContext when running a test
10:28:00.693 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.altran.plage.rest.SubsidiaryControllerTest]
10:28:00.700 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
10:28:00.705 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
10:28:00.719 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.altran.plage.rest.SubsidiaryControllerTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
10:28:00.726 [main] INFO org.springframework.boot.test.context.SpringBoo
@belgoros
belgoros / wgc.ex
Created April 19, 2023 19:50 — forked from am-kantox/wgc.ex
Wolf + Goat + Cabbage
defmodule WolfGoatCabbage.State do
defstruct banks: %{true => [], false => []}, ltr: true, history: []
end
defmodule WolfGoatCabbage.Subj do
defstruct me: nil, incompatible: []
end
defmodule WolfGoatCabbage do
alias WolfGoatCabbage.{State, Subj}
@belgoros
belgoros / testJsonArrayValues.java
Created April 17, 2023 14:38
Ignore specific node values when using `JSONAssert.assertEquals`
@Test
public void testJsonArrayValues() throws JSONException {
String expectedJson = """
{
"messageElements": {
"messageStatus": "SUCCESS",
"businessCorrelationId": "a80337639eb40758",
"errorList": []
},
"data": [
@belgoros
belgoros / phoenix - setup_tailwind.md
Created October 10, 2022 13:10
Set up Tailwind in a Phoenix application

Set up Tailwind CSS in a Phoenix application

  • add tailwind dependency to the mix.exs file: {:tailwind, "~> 0.16", runtime: Mix.env() == :dev}
  • Configure tailwind in config.exs, where it will read, and where it will output the data:
config :tailwind, version: "3.1.4", default: [
  args: ~w(
    --config=tailwind.config.js
@belgoros
belgoros / tm_properties
Created July 29, 2022 09:52 — forked from tedw/tm_properties
TextMate 2 Settings
spellChecking = true
spellingLanguage = 'en'
softTabs = true
softWrap = false
invisiblesMap = "~ \t┊"
TM_STRIP_WHITESPACE_ON_SAVE = true
TM_GIT = "/usr/local/bin/git"
TM_RUBY = "/usr/local/var/rbenv/shims/ruby"
@belgoros
belgoros / palindrome_products.rb
Last active July 28, 2022 06:01
Exercisme: palindromes exercise
class Palindromes
private
attr_reader :factors, :max_factor, :min_factor, :palindromes
def initialize(min_factor: 1, max_factor: 1)
@min_factor = min_factor
@max_factor = max_factor
@factors = (min_factor..max_factor).to_a
@palindromes = palindromes
@belgoros
belgoros / AWS S3-Paperclip5-Heroku.md
Created November 3, 2016 21:43
Setup Rails app with Paperclip 5, Amazon S3 and Heroku

Setting Amazon S3 for Paperclip and Heroku

The latest Paperclip release 5.1.0 has changed a little bit the way to set it up with Amazon S3 service (Amazon Simple Storage Service). Moreover, after googling a lot here and there, we could see many solutions and settings, some of them being outdated, some - often different and did not work well. So I decided to summarize in one replace all the steps needed to set up your Rails application deployed on Heroku and be able to use it with Paperclip 5 and Amazon S3 service.

In case you don't know, Heroku does not allow your Rails application to write and offers read only access. What means that you can't use Paperclip and save your files to Heroku's file system.

So you will have to find a way to upload/store/read your files. As stated in Paperclip documentation, Paperclip ships with 3 storage adapters:

@belgoros
belgoros / TestDouble.java
Created June 4, 2021 14:48 — forked from hillmanli-seekers/TestDouble.java
BigDecimal vs double: illustration of accuracy and performance impact
import java.math.BigDecimal;
import java.util.function.Consumer;
import java.util.function.DoubleSupplier;
import java.util.stream.DoubleStream;
public class TestDouble {
private static double doubleTotal = 0;
private static double kahanDoubleTotal = 0;
{
"exp": 1621497315,
"iat": 1621497015,
"jti": "b390e0bc-292f-423d-9eb9-8eeced0b5272",
"iss": "http://localhost:8080/auth/realms/Demo-Realm",
"aud": "account",
"sub": "aefc221c-1402-41b4-8fb0-4be2eaa003f2",
"typ": "Bearer",
"azp": "springboot-microservice",
"session_state": "93bf159e-c617-4436-9891-a0f0333e37d9",
{
"aud": [
"server"
],
"iat": 1621503452,
"auth_time": 1621503452,
"exp": 1621539452,
"iss": "http://localhost:8080/auth/realms/Demo-Realm",
"sub": "user",
"scope": "openid",