Skip to content

Instantly share code, notes, and snippets.

View dotherightthing's full-sized avatar

Dan Smith dotherightthing

  • Do The Right Thing
  • Wellington, New Zealand
View GitHub Profile
@dotherightthing
dotherightthing / test-custom-shortcode.md
Last active August 15, 2019 06:13
[Test custom shortcode] #wordpress

Test custom shortcode

@dotherightthing
dotherightthing / eslint-disable-rule.md
Last active September 4, 2019 04:33
[Disable ESLint] Disable ESLint rules using comments #linters #js
@dotherightthing
dotherightthing / sass-lint-disable.md
Last active November 1, 2018 04:22
[Disable Sass-lint] Disable Sass-lint rules using comments #linters #scss
@dotherightthing
dotherightthing / phpcs-disable.md
Last active November 1, 2018 04:22
[Disable PHP Code Sniffer] Disable PHP Code Sniffer rules using comments #linters #php
@dotherightthing
dotherightthing / sublime-build-php.md
Last active August 14, 2019 04:47
[Sublime PHP build system] Add a PHP build system to Sublime #sublime #php
@dotherightthing
dotherightthing / embed-oembed.md
Last active November 1, 2018 10:48
[oEmbed] oEmbed provides a JSON representation of a resource to consumers, to allow them to embed it in their own page. #embeds

oEmbed

The resource can be specified as one of the following types:

  • photo - an embeddable image
  • video - an embeddable video
  • link - embeddable information about a URL
  • rich - embeddable HTML, usually using an iframe to provide styled and interactive content
@dotherightthing
dotherightthing / character-encoding-utf-8.md
Last active November 1, 2018 10:48
[UTF-8] Why UTF-8 is great. #utf8 #I18n #unicode

UTF-8

Some great information from UTF-8: The Secret of Character Encoding.

Meta tag

I've used the charset meta tag with a UTF-8 value for a long long time and now it's the default in HTML5.

While this can also be achieved on the server, the meta tag is an easy and human-readable way to instruct the browser to use UTF-8.

@dotherightthing
dotherightthing / caching-assets.md
Last active September 9, 2019 23:41
[Asset caching policy] The Cache-Control header is the most important header to set as it effectively ‘switches on’ caching in the browser. #caching #performance

Asset caching policy

Disclaimer

This content is paraphrased from Increasing Application Performance with HTTP Cache Headers. It's how I learn.

Summary

HTTP caching occurs when the browser stores local copies of web resources for faster retrieval the next time the resource is required. As your application serves resources it can attach cache headers to the response specifying the desired cache behavior.

@dotherightthing
dotherightthing / php-version-remote-url.md
Last active November 1, 2018 09:35
[Get PHP version used by a website] #php #curl #security

Get PHP version used by a website

In web browser

  1. curl -I http://www.websitename.com
  2. Append a PHP string to the URL, to display an image-based easter egg that corresponds to a version of PHP

To disable on server

@dotherightthing
dotherightthing / php-autoloading-and-namespaces.md
Last active November 1, 2018 10:49
[Autoloading and Namespaces] Namespacing prevents classes from leaking into the global scope. #php #wordpress #dev

Autoloading and Namespaces

composer.json

This object instructs Composer to automatically require PHP files inside src, which use the namespace WPDTRT_Plugin:

"autoload": {
  "psr-4": {
 "DoTheRightThing\WPPlugin\\": "src/"