Today I Learned

5 posts by piotrmotak

Preserve console logs

Debugging code in javascript might be tricky sometimes. Especially when we want to log into console events that triggers page reload. But we can preserve logs. For example in Chrome we go into console -> console settings (this lower one button) -> preserve log


Chrome dev tools will show all logs and only inform us by logging image info that it changed page.

Pass hex color to fill svg in background url (SCSS)

Passing svg into background url might be useful for eg. in case of dropdown arrow selects.

but there is a problem if you want to pass dynamically color to fill that svg. url is not accepting # from that hex.

I found that if we use

@use "sass:string";
@use "sass:color";

we can build something similar to encodeURI

@function escape-url-hex-color($hex_color) {
  $string: string.quote($ie-color-string);
  $color: string.slice($string, 4);
  @return '%23' + $color;

then we can easily use it to set color variable and pass it to fill attribute.

Searching for files in AWS s3 from rails console

first set your credentials to AWS_ACCESS_KEY_ID, AWS_REGION, AWS_SECRET_ACCESS_KEY in .env


rails c
s3_client =

if credentials are set it will by default look for them there, but there is much more other options

then we can

    bucket: 'S3_BUCKET',
    max_keys: 'max_records by def 1000',
    prefix: 'some/key/to/file/'

It is good to note that prefix doesn’t begin from ‘/‘

also it works from ‘aws-sdk’ > 2.3.2