Skip to content

Instantly share code, notes, and snippets.

View mareksuscak's full-sized avatar
🏠
Working from home

Marek Suscak mareksuscak

🏠
Working from home
View GitHub Profile
@mareksuscak
mareksuscak / README.md
Last active October 18, 2023 20:53
NodeJS Cache

How to Use

The interface was greatly inspired by Rails' low level caching implementation.

import { MemoryStore, Cache } from './cache'

const store = new MemoryStore({ ttl: 30 * 1000, max: 10 })
const cache = new Cache(store)
@mareksuscak
mareksuscak / utf8mb4.sql
Last active February 23, 2024 10:23
MySQL utf8 to utf8mb4 conversion
-- adapted from https://dba.stackexchange.com/a/104866/247902
USE information_schema;
SELECT CONCAT("SET foreign_key_checks = 0;") AS _sql UNION
SELECT CONCAT("ALTER DATABASE `",table_schema,"` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;") AS _sql
FROM `TABLES` WHERE table_schema LIKE "<YOUR_DATABASE>" AND TABLE_TYPE='BASE TABLE' GROUP BY table_schema UNION
SELECT CONCAT("ALTER TABLE `",table_schema,"`.`",table_name,"` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;") AS _sql
FROM `TABLES` WHERE table_schema LIKE "<YOUR_DATABASE>" AND TABLE_TYPE='BASE TABLE' GROUP BY table_schema, table_name UNION
SELECT CONCAT("ALTER TABLE `",`COLUMNS`.table_schema,"`.`",`COLUMNS`.table_name, "` CHANGE `",column_name,"` `",column_name,"` ",data_type,"(",character_maximum_length,") CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci",IF(column_default IS NOT NULL," DEFAULT \'",""),IF(column_default IS NOT NULL,column_default,""),IF(column_default IS NOT NULL,"\'",""),IF(is_nullable="YES"," NULL"," NOT NU
@mareksuscak
mareksuscak / mixins.scss
Created October 5, 2020 22:07
Cross-browser multi-line clamping in SCSS
/* Multiline Clamp Mixin */
// Helper Function for Multiline Clamp Mixin
@function multiline-block-height($lines, $font-size, $line-height) {
@return $lines * floor($font-size * $line-height);
}
@mixin multiline-clamp($lines: 2, $font-size: 16px, $line-height: 1.4, $fill-space: false) {
font-size: $font-size;
display: block;
@mareksuscak
mareksuscak / README.md
Last active November 16, 2020 04:14
Gatsby + S3 no trailing slash redirect patch
@mareksuscak
mareksuscak / grafana-redis-exporter-dashboard-by-pod.json
Created September 26, 2019 09:49
Redis Exporter 1.x Dashboard for Grafana (breakdown by pod instead of an IP)
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prom",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@mareksuscak
mareksuscak / messenger.yaml
Created September 11, 2019 22:40
Symfony 4.4 Messenger - Alternative approach to different middleware for producer and consumer
framework:
messenger:
# ...
# Read more to learn why there are two buses (TL;DR: different middleware on each side - producer and consumer)
# https://github.com/symfony/symfony/issues/32436#issuecomment-530565499
default_bus: command.bus
buses:
command.bus:
@mareksuscak
mareksuscak / AddConsumerBusNameStampMiddleware.php
Last active September 11, 2019 22:36
Symfony 4.4 Messenger - Different middleware on the consumer and producer side
<?php
namespace App\Messenger\Middleware;
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messenger\Middleware\StackInterface;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Stamp\BusNameStamp;
# This is sort of a workaround, read more here:
@mareksuscak
mareksuscak / Brewfile
Last active August 20, 2019 22:42
Brewfile
tap "homebrew/cask-versions"
tap "homebrew/services"
# Unix
brew "git"
brew "git-lfs"
brew "jq"
brew "yq"
brew "openssl"
brew "thoughtbot/formulae/rcm"
@mareksuscak
mareksuscak / README.md
Last active June 27, 2018 00:07
4 Years of React — Lessons Learned

4 Years of React — Lessons Learned

Design

  • Use wireframes as a visual aid for breaking UIs down into components
  • Have a design system in place and stick to it strictly
  • Involve the designer in creating a design system of components
  • Use sane CSS architecture — CSS modules w/ BEVM combined w/ utility first CSS