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 / security-tls-and-ssl.md
Last active November 1, 2018 10:50
[TLS vs SSL] TLS and SSL are protocols that provide data encryption and authentication between applications (e.g. browsers & email clients) and servers. #security #http2 #ssl #tls

TLS (Transport Layer Security) and SSL (Secure Sockets Layer)

Summary

TLS (Transport Layer Security) and SSL (Secure Sockets Layer) are protocols that provide data encryption and authentication between applications and servers in scenarios where that data is being sent across an insecure network, such as checking your email. - SSL versus TLS – What’s the difference?

Key differences

  • A program can initiate a secure connection with a server by Port ('explicit' - SSL), or by Protocol ('implicit' - TLS)
  • A negotiation between the client and the server determines which protocol is used. This is based on which software is installed on each and how each is configured.
@dotherightthing
dotherightthing / php-stack-trace.md
Last active November 1, 2018 10:51
[Generating a Stack Trace in PHP] What called what from where? #php #debugging #wordpress

Generating a Stack Trace

Source: StackOverflow - Print PHP Call Stack

Sample output when called from a WordPress Widget Subclass:

#0 /Volumes/DanBackup/Websites/wp-network/wp-includes/class-wp-widget-factory.php(106): WPDTRT_Widget->__construct()
#1 /Volumes/DanBackup/Websites/wp-network/wp-includes/widgets.php(113): WP_Widget_Factory->register('WPDTRT_Attachme...')
#2 /Volumes/DanBackup/Websites/wpdtrt-attachment-map/wpdtrt-attachment-map.php(202): register_widget('WPDTRT_Attachme...')
@dotherightthing
dotherightthing / browsers-in-app.md
Last active November 3, 2018 01:58
[In-app browsers] #browsers #facebook

In-app browsers

Source: The Facebook browser – the biggest browser that you ignore

“In-app browsers” are not actual browsers, but a webview window running off your device’s core browser.

the real motivation is to increase dwell time

Links that open in Facebook’s browser are able to keep sharing data, helping build up a thicker, more valuable advertising profile of that user.

@dotherightthing
dotherightthing / composer-nested-dependencies.md
Last active August 15, 2019 06:28
[Composer - Loading nested dependencies] How to load a development dependency, used by a dependency of your primary project. require-dev vs require #composer #php

Composer - Loading nested dependencies

Problem

My wpdtrt-plugin repository used my wpdtrt-helpers plugin during development.

I documented the dependency by adding wpdtrt-helpers to the Composer file:

{
@dotherightthing
dotherightthing / php-unit-testing-revisited.md
Last active November 1, 2018 10:41
[PHP Unit Testing, revisited] #php #unit-testing #wordpress
@dotherightthing
dotherightthing / wordpress-permalink-edit-button.md
Last active December 16, 2018 22:16
[Missing Permalink Edit button] If the %postname% placeholder is programatically removed from the permalink, WordPress will remove the corresponding 'Edit' button. #wordpress #php
@dotherightthing
dotherightthing / bash-profile-path.md
Last active October 6, 2021 23:21
[Bash Profile] The .bash_profile is loaded before Terminal loads your shell environment. It contains all the startup configuration and preferences for your command line interface. #bash #cli #macos

Bash Profile / PATH

What is Bash?

Bash (the Bourne Again SHell) is an interactive shell, which responds to user typed commands with actions.

Understanding start-up files

When Bash starts up, it executes the commands in a variety of 'dot' files, including ~/.bash_profile.

@dotherightthing
dotherightthing / jquery-noconflict-mode.md
Last active November 1, 2018 10:47
[Using $ in $.noConflict() mode] Use jQuery's $ shortcut in No-Conflict Mode, by passing it into functions as a local variable #js #jquery

Using $ in $.noConflict() mode

How to use the dollar sign as an alias for the jQuery object

Because the jQuery object is used so often, having a short alias is very useful and the dollar sign is so conventional that when people are looking at jQuery code, they are often looking for this dollar sign as an indicator that the jQuery object is being used.

Now we could use a simple assignment to say $ = jQuery and just leave it at that, but the issue is that we don't know if the dollar sign is being used by some other JavaScript library ... So in order to make sure that the dollar sign doesn't get overridden somewhere along the lines, we need to make the dollar sign a local variable for each function that we write

Source: BuildAModule: How to use the dollar sign as an alias for the jQuery object

@dotherightthing
dotherightthing / wordpress-passing-variable-to-template-part.md
Created November 1, 2018 10:59
[Passing variables to template-parts] Pass PHP variables to WordPress partials as query_vars. #php #wordpress
@dotherightthing
dotherightthing / pagespeed-wordpress.md
Created November 1, 2018 11:02
[PageSpeed] WordPress Cheatsheet. #wordpress #performance

PageSpeed

JavaScript

  1. load using official WordPress mechanism (wp_enqueue_script, $in_footer)
  2. use Autoptimize plugin to move any header scripts into the footer, and to concatenate all footer scripts into a single minified file. Don't exclude js/jquery/jquery.js. Note that files that are named *.min.js aren't (re)minified by Autoptimize.
  3. use vanilla JavaScript for essential page transformations, to bypass wait time for jQuery load and setup

CSS Stylesheets