Skip to content

Instantly share code, notes, and snippets.

View greylabel's full-sized avatar

Grant Gaudet greylabel

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active April 21, 2025 02:29
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@crittermike
crittermike / wget.sh
Last active March 28, 2025 18:44
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@crittermike
crittermike / .platform.app.yaml
Last active August 6, 2021 04:50
A sample .platform.app.yaml file for hosting Grav CMS on Platform.sh
name: grav_app # Rename this to whatever you want.
type: php:7.1
disk: 1024
web:
locations:
"/":
root: "app" # Assuming Grav lives in an app/ directory.
passthru: /index.php
expires: 1h
mounts:
<?php
/**
* This plugin creates a new paragraph entity based on the source.
*
* @MigrateProcessPlugin(
* id = "mds_paragraph"
* )
*/
class ParagraphMigrateProcessor extends ParagraphProcessBase {

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@ModulesUnraveled
ModulesUnraveled / drushrc.php
Last active May 14, 2017 23:34
Useful Drush shell-aliases for Drupal 8 development.
<?php
/**
* These aliases (while working) are NO LONGER MAINTAINED.
*
* Development has moved to a full github repo here:
* https://github.com/ModulesUnraveled/Drush-Shell-Aliases
*
* I'm doing this to make it more easy to include them in your Drupal 8 projects.
@crittermike
crittermike / MyCustomBlock.php
Last active October 23, 2020 17:42
Drupal 8 block with custom cache context and tags
<?php
class MyCustomBlock extends BlockBase {
public function build() {
return array(
'#markup' => $this->t('My custom block content'),
'#cache' => array(
'contexts' => ['url.path'], // https://www.drupal.org/developing/api/8/cache/contexts
'tags' => ['node:1', 'node:2'] // https://www.drupal.org/developing/api/8/cache/tags
),
sub vcl_recv {
#FASTLY recv
# If geo_override header is supplied use that instead of built in geoip library. For testing.
if ( req.http.geo_override ) {
set req.http.X-Geo-Country = req.http.geo_override;
} else {
set req.http.X-Geo-Country = geoip.country_code;
}
@joshenders
joshenders / mitmproxy.md
Last active July 23, 2023 14:49
mitmproxy configuration for iPad

Successful mitmproxy-3.7 setup tested on OS X 10.13.6 and iPhone X running 12.1.4

Enable IP forwarding and disable ICMP redirects to keep the iPad sending traffic to the proxy

sudo sysctl -w net.inet.ip.forwarding=1
sudo sysctl -w net.inet.ip.redirect=0

net.inet.ip.forwarding
Enable IP forwarding between interfaces

@typhonius
typhonius / BehatTask.php
Last active August 29, 2015 14:18
Basic BehatTask.php class for Phing.
<?php
/**
* A Phing task to run Behat commands.
*/
require_once 'phing/Task.php';
/**
* A Behat task. Runs behavior-driven development tests against a codebase.
*