Skip to content

Instantly share code, notes, and snippets.

View fedek6's full-sized avatar
🎯
Focusing

Konrad Fedorczyk fedek6

🎯
Focusing
View GitHub Profile
@fedek6
fedek6 / opcache-preload.php
Created October 30, 2020 09:18
Working WordPress opcache preloading config
<?php
/**
* WordPress opcache preloading.
* Requires PHP >= 7.4.
*
* @author Konrad Fedorczyk <contact@realhe.ro>
* @link https://stitcher.io/blog/preloading-in-php-74
*
* @version 1.0.0
*/
@fedek6
fedek6 / .user.ini
Created July 27, 2018 12:12
Simple PHP large upload test script
upload_max_filesize = 2048M
post_max_size = 2048M
max_input_time = 3600
@fedek6
fedek6 / convetions.md
Created May 13, 2022 08:37
React props naming conventions

Props naming

  • Array – use plural nouns. e.g. items
  • Number – use prefix num or postfix count, index etc that can imply a number. e.g. numItems, itemCount, itemIndex
  • Bool – use prefix is, can, has
    • is: for visual/behavior variations. e.g. isVisible, isEnable, isActive
    • can: fore behavior variations or conditional visual variations. e.g. canToggle, canExpand, canHaveCancelButton
    • has: for toggling UI elements. e.g. hasCancelButton, hasHeader
  • Object – use noun. e.g. item
  • Node – use prefix node. containerNode
@fedek6
fedek6 / functions.php
Created March 13, 2018 09:56
Ajax support for WP Newsletter plugin (https://www.thenewsletterplugin.com)
<?php
/** @constant string THEME_NAME **/
define( 'THEME_NAME', get_option('stylesheet') );
/**
* Custom script
*/
function my_scripts_method() {
wp_enqueue_script(
'custom-script',
@fedek6
fedek6 / removeSublimeContextMenu.bat
Created November 9, 2017 12:30
Remove Sublime integration added by: roundand/OpenWithSublimeText3.bat
@echo off
rem add it for all file types
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /f
rem add it for folders
@reg delete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /f
pause
@fedek6
fedek6 / profiler.sh
Created March 11, 2024 10:30
Bash profiler for app
#!/bin/bash
# Check if a PID was provided
if [ -z "$1" ]; then
echo "Usage: $0 <pid>"
exit 1
fi
PID=$1
OUTPUT_FILE="usage.txt"
@fedek6
fedek6 / useLocalStorage.ts
Created August 2, 2021 20:32
Working useLocalStorage hook for Next.js (no warnings in console)
/* eslint-disable no-console */
/* eslint-disable react-hooks/exhaustive-deps */
import { useState, useEffect } from "react";
export const useLocalStorage = <T>(key: string, initialValue: T) => {
const [storedValue, setStoredValue] = useState<T | undefined>();
const setValue = (value: T) => {
window.localStorage.setItem(key, JSON.stringify(value));
};
@fedek6
fedek6 / DocsContainer.js
Created March 17, 2022 08:18
Sorybook with dark mode support for docs (using stitches, but this can be edited)
import React from "react";
import { DocsContainer as BaseContainer } from "@storybook/addon-docs/blocks";
import { useDarkMode } from "storybook-dark-mode";
import { themes } from "@storybook/theming";
export const DocsContainer = ({ children, context }) => {
const dark = useDarkMode();
return (
<BaseContainer
@fedek6
fedek6 / unique_hex_string.php
Created September 11, 2023 07:49
Generate unique hex string in PHP
<?php
function generate_unique_hex_string($length) {
// Calculate the number of bytes needed for the desired length of the hexadecimal string
$byte_length = ceil($length / 2);
// Generate random bytes
$random_bytes = random_bytes($byte_length);
// Convert the random bytes to a hexadecimal string
$hex_string = bin2hex($random_bytes);
@fedek6
fedek6 / Readme.md
Created August 15, 2021 18:15
Working Linaria config for Storybook (Webpack 5)

You must use Storybook with webpack5!

npx sb@next init --builder webpack5

Remember to install all nedded packages because debugging babel deps might be tricky.

Enjoy!