Skip to content

Instantly share code, notes, and snippets.

@machuu
machuu / WSL2_VPN_Workaround_Instructions.md
Last active April 8, 2025 07:50
Workaround for WSL2 network broken on VPN

Overview

Internet connection and DNS routing are broken from WSL2 instances, when some VPNs are active.

The root cause seems to be that WSL2 and the VPN use the same IP address block, and the VPN routing clobbers WSL2's network routing.

This problem is tracked in multiple microsoft/WSL issues including, but not limited to:

@javilobo8
javilobo8 / download-file.js
Last active March 17, 2025 14:25
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@Jakobud
Jakobud / _linear-interpolation.scss
Last active February 21, 2023 18:40
Linear Interpolation SASS function
/// linear-interpolation
/// Calculate the definition of a line between two points
/// @param $map - A SASS map of viewport widths and size value pairs
/// @returns A linear equation as a calc() function
/// @example
/// font-size: linear-interpolation((320px: 18px, 768px: 26px));
/// @author Jake Wilson <[email protected]>
@function linear-interpolation($map) {
$keys: map-keys($map);
@if (length($keys) != 2) {
@nat-c
nat-c / nc-custom-wp-error-pages
Last active February 9, 2023 10:37
Custom WordPress Error Pages (not 404; this one is handled via your theme): A php snippet to put in your functions.php or in your plugin to get rid of the default WP error pages and have custom ones that match with your theme. The code is taken from a CRM application I'm building on top of WordPress [personal project] and slightly modified to be…
<?php
add_filter( 'wp_die_handler', 'nc_get_custom_error_handler' );
function nc_get_custom_error_handler() {
return 'nc_custom_error_handler';
}
function nc_custom_error_handler( $message, $title = '', $args = array() ) {
$defaults = array( 'response' => 500, 'back_link' => false );
<?php
/**
* Create ACF setting page under Events CPT menu
*
* @since 1.0.0
*/
if ( function_exists( 'acf_add_options_sub_page' ) ){
acf_add_options_sub_page(array(
'title' => 'Event Settings',
'parent' => 'edit.php?post_type=events',