Skip to content

Instantly share code, notes, and snippets.

View huksley's full-sized avatar
🐈
Step on no pets

Ruslan Gainutdinov huksley

🐈
Step on no pets
View GitHub Profile
@huksley
huksley / intercept.js
Created April 11, 2023 12:36
Intercept and log HTTP(s) requests. Direct socket connections are not logged
const nock = require("nock");
nock.recorder.rec({
output_objects: true,
logging: o => {
const oo =
typeof o === "string"
? JSON.parse(o.substring(0, o.lastIndexOf("}") + 1).substring(o.indexOf("{")))
: o;
logger.info(
@huksley
huksley / deploy.yml
Last active February 11, 2024 07:21
Full configuration example for mrsk for NextJS. Save as config/deploy.yml See more at https://github.com/mrsked/mrsk
# yaml-language-server: $schema=https://raw.githubusercontent.com/kjellberg/mrsk/validate-with-json-schema/lib/mrsk/configuration/schema.yaml
service: testexample
image: githubuser/test/main
servers:
web:
hosts:
- 1.1.1.1
labels:
traefik.http.routers.web.rule: Host(`test.example.com`)
traefik.http.routers.web_secure.entrypoints: websecure

Using square brackets and escapes in rule names generates null style

https://github.com/styled-components/styled-components/tree/legacy-v5

Description

Using classes like grid-cols-[minmax(300px,_1fr)_3fr] from https://tailwindcss.com/docs/grid-template-columns#arbitrary-values causes silent failure with classes not being applied properly.

When debugging, I can see that Styled Components generate style rules such as .hHkAEe{null;} signaling there is some bug inside which stops processing all styles for a component if such class rule exists.

@huksley
huksley / pg.conf
Last active March 6, 2023 07:21
Run postgres and redis in a single shell command
# Postgres minimal config
port = 5432
listen_addresses = 'localhost'
max_connections = 100
shared_buffers = 32MB
huge_pages = off
temp_buffers = 8MB
max_prepared_transactions = 0
work_mem = 512kB
maintenance_work_mem = 2MB
#!/bin/bash
function zerodep() {
if [ -z "$1" ]; then
echo "Usage: zerodep <package>"
return
fi
F=node_modules/$1/package.json;
SRC=$(jq -r ".homepage" $F);
@huksley
huksley / FontPicker.tsx
Last active February 14, 2023 21:11
Font change React component for any website https://developers.google.com/fonts/docs/developer_api
import { useCallback } from "react";
import useSWR from "swr";
/**
* Allows you to choose any font from Google Fonts, overriding your CSS var --font-family
* Create a key at https://developers.google.com/fonts/docs/developer_api
*/
export const FontPicker = ({ families }: { families?: string[] }) => {
const { data: fonts } = useSWR(
process.env.GOOGLE_WEBFONTS_KEY
@huksley
huksley / jobroles.md
Created February 6, 2023 10:07
AWS Job roles

Job roles

From AWS questionairre

Data Engineer

Implement, monitor, and maintain database or ETL systems and infrastructure to support analytical data warehousing

Human Resources

Recruit, develop talent, and/or manage employee-related functions such as benefits, career path, or mental health

@huksley
huksley / ResizableElement.tsx
Created December 2, 2022 20:56
Resizable element for responsive test. Based on TailwindCSS implementation
import { motion, useTransform, useMotionValue } from "framer-motion";
import { useEffect, useRef } from "react";
function Well({
as: Component = "div",
style,
className,
containerClassName,
html,
children
@huksley
huksley / build-docker.sh
Created December 1, 2022 07:43
Pass environment variables in the shell to subcommand by some prefix, e.g. DOCKER_
#!/bin/bash
# Pass all DOCKER_ARG_NAME=VALUE as --build-arg NAME=VALUE
docker buildx build . --tag test1 \
(for N in "${!DOCKER_ARG_@}"; do echo -n "--build-arg ${N/DOCKER_ARG_/}=${!N} "; done)
@huksley
huksley / decodeGoogleNewsUrl.ts
Last active May 5, 2024 09:49
This script decodes Google News generated encoded, internal URLs for RSS items
/**
* Google News started generate encoded, internal URLs for RSS items
* https://news.google.com/rss/search?q=New%20York%20when%3A30d&hl=en-US&gl=US&ceid=US:en
*
* This script decodes URLs into original one, for example URL
* https://news.google.com/__i/rss/rd/articles/CBMiSGh0dHBzOi8vdGVjaGNydW5jaC5jb20vMjAyMi8xMC8yNy9uZXcteW9yay1wb3N0LWhhY2tlZC1vZmZlbnNpdmUtdHdlZXRzL9IBAA?oc=5
*
* contains this
* https://techcrunch.com/2022/10/27/new-york-post-hacked-offensive-tweets/
*