Skip to content

Instantly share code, notes, and snippets.

View matzeeable's full-sized avatar
💭
Looking for improvements!

Matthias Günter matzeeable

💭
Looking for improvements!
View GitHub Profile
type AnyFunction = (...args: any[]) => any
function useEvent<T extends AnyFunction>(callback?: T) {
const ref = useRef<AnyFunction | undefined>(() => {
throw new Error("Cannot call an event handler while rendering.")
})
// Or useInsertionEffect if it's React 18
useLayoutEffect(() => {
ref.current = callback
})
<?php
// Real Media Library Disable Auto Expands
if ( !function_exists( 'rml_custom_js' ) ) {
function rml_custom_js(){
$list = wp_rml_root_childs();
$idList = [];
foreach ($list as $listItem) {
$idList[$listItem->getId()] = false;
}
@b01
b01 / download-vs-code-server.sh
Last active April 22, 2024 14:22
Linux script to download latest VS Code Server, good for Docker (tested in Alpine).
#!/bin/sh
# Copyright 2023 Khalifah K. Shabazz
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the “Software”),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
@Raistlfiren
Raistlfiren / Dockerfile
Last active August 14, 2023 19:02
XDebug 3 and Docker Reference
FROM php:7.4-cli-alpine
# Install xdebug
RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del .phpize-deps
WORKDIR /var/www/html
@frafra
frafra / .gitlab-ci.yml
Created November 6, 2020 15:46
Build containers with GitLab CI without root nor daemons by using buildkit
build-container:
stage: build
image:
name: moby/buildkit:rootless
entrypoint: [ "sh", "-c" ]
variables:
BUILDKITD_FLAGS: --oci-worker-no-process-sandbox
before_script:
- |
mkdir ~/.docker
@spacedmonkey
spacedmonkey / Function.txt
Last active February 17, 2020 11:58
WordPress core private Functions and Classes.
Functions
startElement
endElement
_wp_menu_output
_add_themes_utility_last
_wp_ajax_delete_comment_response
_wp_ajax_add_hierarchical_term
wp_link_manager_disabled_message
_wp_credits_add_profile_link
@ahmadawais
ahmadawais / .babelrc
Last active August 2, 2020 00:55
Basic Gutenberg Custom Block with ESNext, Webpack, BabelJS— https://github.com/ahmadawais/Gutenberg-Boilerplate/tree/master/block/02-basic-esnext
{
"presets": [
[ "env", {
"modules": false,
"targets": {
"browsers": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"last 2 iOS versions",
@heiswayi
heiswayi / repo-reset.md
Created February 5, 2017 01:32
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
# Extension package to add on Ubuntu 14.04
sudo apt-get install libxml2-dev libbz2-dev libmcrypt-dev libreadline-dev libxslt1-dev autoconf -y
# Extension package to add on Ubuntu 18.04
sudo apt-get install libssl-dev
# Extension package to add on Ubuntu 20.04
sudo apt install -y pkg-config libssl-dev libsqlite3-dev libbz2-dev libxml2-dev libcurl4-openssl-dev libonig-dev libpq-dev libreadline-dev libxslt1-dev libzip-dev libsodium-dev libwebp-dev
# +apxs2
sudo apt-get install apache2-dev -y

How you can help reduce node_modules bloat

This recent reddit thread reveals discontent among the web development community about the sheer volume of stuff in a typical node_modules dir. 140MB in this case!

Is it a design flaw in npm?

Opinions in the thread varied from "I'm surprised npm even works" to "everything is fine". I'm not going to offer an opinion, just these two observations:

  1. node_modules dirs typically do contain lots of stuff that doesn't need to be there.
  2. The latest version mitigates overall size by flattening the dependency tree, but some of the bloat is beyond npm's control.