Skip to content

Instantly share code, notes, and snippets.

View WalrusSoup's full-sized avatar

JL WalrusSoup

View GitHub Profile
@cryptoskillz
cryptoskillz / gist:98b8e7090b7cc8d51531bb9dcfe7654a
Created December 5, 2021 16:48
Tips on how to use a KV namespace with Cloudflare Pages
This gist aims to show you how to use KV datastore using Cloudflare pages. The reason I created this quick guide is it took
me almost 2 weeks to get it working, mainly because it is very new and the documentation is not up fully fleshed out yet
https://developers.cloudflare.com/workers/runtime-apis/kv
https://developers.cloudflare.com/pages/platform/functions
https://blog.cloudflare.com/wrangler-v2-beta/
Steps:
Install wrangler 2
@jjsquady
jjsquady / mysql-sail.md
Last active March 9, 2024 16:50
Laravel Sail - GRANT ALL PRIVILEGES to user

Run this command in sail project folder:

docker-compose exec mysql bash

execute the mysql -u root -p command

provide the default password password

then executes

@chavesm
chavesm / remove_type_attr_1148073.php
Last active June 29, 2021 11:42
Remove unnecessary "type" attribute from MI script code to keep HTML validators happy. Second file adds async attribute to external gtag script.
<?php // Ignore this line if copying to child theme's functions.php
/** Remove the unnecessary "type" attribute from MI script code by leaving it out of the filter. */
function remove_type_attr_1148073() {
return array(
'data-cfasync' => 'false' // Ask CloudFlare Rocket Loader not to execute.
);
}
add_filter( 'monsterinsights_tracking_analytics_script_attributes', 'remove_type_attr_1148073' );
@wilmardo
wilmardo / .php-cs.dist.php
Last active April 6, 2021 20:35
PHP-CS-Fixer matching the Laravel StyleCI rules. The order of rules is the same as here: https://docs.styleci.io/presets#laravel. The linecount of the rules is exactly the same (110 without risky).
<?php
# source: https://docs.styleci.io/presets#laravel
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'align_multiline_comment' => true,
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
@CollinChaffin
CollinChaffin / How_to_disable_ATT_DNS_Redirection.md
Created August 29, 2018 21:26
How to disable the very little-known AT&T setting that can appear to hijack your home DNS lookups and redirect to 104.239.207.44

How to disable the very little-known AT&T setting that can appear to hijack your home DNS lookups and redirect to 104.239.207.44

Issue

DNS queries on home network suddenly resolving hosts to 104.239.207.44.

Symptoms

You will see SPORADIC mis-resolutions of EVERYTHING to that 104.239.207.44 address if their crappy router happens to hear your PC's DHCP request - EVEN IF ANOTHER DHCP SERVER ON THE NETWORK assigns the ultimate address.

@holmberd
holmberd / php-pools.md
Last active May 30, 2024 10:30
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@jamesmacwhite
jamesmacwhite / ffmpeg_mkv_mp4_conversion.md
Last active May 13, 2024 10:18
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

@hopbit
hopbit / intellij-idea-shortcuts.md
Last active April 25, 2024 08:32
IntelliJ IDEA Keyboard Shortcuts Cheatsheet

Modes

distraction mode
fullscreen mode
autoscroll from/to source
termial settings -> don't override shortcuts presentation asist

Editing

@paulirish
paulirish / what-forces-layout.md
Last active May 31, 2024 22:37
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',