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 / 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!

(function($, undefined){
/**
* acf
*
* description
*
* @date 14/12/17
* @since 5.6.5
*
@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 / Readme.md
Last active February 19, 2023 08:59
Automatic1111 instructions for low mem linux computers

Low mem automatic1111 setup for linux distros

Stop GDM to shake of some memory usage

This will give you 1GB extra vram on Pop!_OS. Use ctrl + alt + f3/f4 to switch between terminals.

sudo service gdm stop