Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Tom J Nowell tomjn

🎯
Focusing
Block or report user

Report or block tomjn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tomjn
tomjn / tomjn_http2_push.php
Created Jan 25, 2019
A naive and incomplete, but functional approach to http2 push
View tomjn_http2_push.php
<?php
/**
* Plugin name: HTTP2 Push scripts
* Author: Tom J Nowell
*/
function tomjn_get_dep_url( /*\WP_Dependency*/ $dep ) {
global $wp_version;
$relative = str_replace( site_url(), '', $dep->src );
$ver = $dep->ver;
@tomjn
tomjn / gist:194136e3ecbe693cf1749c4622ea00a3
Created Jan 15, 2019
Provisioner log of tideways utility
View gist:194136e3ecbe693cf1749c4622ea00a3
==> default: Running provisioner: utility-mte90-tideways (shell)...
default: Running: /var/folders/jx/3t2z3sgx7sb3mwlml6v2xskh0000gp/T/vagrant-shell20190115-33101-1pdjm18.sh
default: Installing Tideways & XHgui
default: File copied for php 7.0
default: cp:
default: cannot stat ‘/home/vagrant/tideways.ini’
default: : No such file or directory
default: cp:
default: cannot stat ‘/home/vagrant/mongodb.ini’
default: : No such file or directory
View rest_endpoint.php
<?php
function toms_addition_endpoint( \WP_REST_Request $request ) {
$result = $request['a'] + $request['b'];
return rest_ensure_response( $result );
}
function toms_addition_routes() {
register_rest_route( 'tomjn/v1', '/addition', array(
View datastore.lua
DataStore = {
data = {},
subscribers = {}
}
function DataStore:new (o)
o = o or {} -- create object if user does not provide one
setmetatable(o, self)
self.__index = self
return o
end
@tomjn
tomjn / securing-acf.php
Created Jul 2, 2018
ACF's `the_field` function is insecure by default, here's a selection of wrappers that fix that
View securing-acf.php
<?php
function the_field_url( $selector, $post_id=0, $format_value=true ) {
echo esc_url( get_field( $selector, $post_id, $format_value ) );
}
function the_field_url_raw( $selector, $post_id=0, $format_value=true ) {
echo esc_url_raw( get_field( $selector, $post_id, $format_value ) );
}
View example.lua
ai = ....
p = {x=0,y=0,z=0}
units = UnitQuery( ai, {
within={
position=p
radius=100
},
canMove=false
})
View placementhandler.lua
PlacementHandler = class(Module)
function PlacementHandler:Name()
return "PlacementHandler"
end
function PlacementHandler:internalName()
return "placementhandler"
end
View gfx_shard_debug.lua
function widget:GetInfo()
return {
name = "Shard FX",
desc = "Adds glow effect at debug points",
author = "AF and Floris",
date = "May 2018",
license = "GNU GPL, v2 or later",
layer = 2,
enabled = true,
}
@tomjn
tomjn / wwwphpcs.php
Created May 9, 2018
BEHOLD probably one of the hackiest things I've done in a long time
View wwwphpcs.php
<?php
require_once( 'vendor/squizlabs/php_codesniffer/autoload.php' );
// set the current working directory as the current directory
chdir( __DIR__ );
$_SERVER['argv'] = [
'phpcs',
'test.php',
'--report=json',
View placementhandler.lua
PlacementHandler = class(Module)
function PlacementHandler:Name()
return "PlacementHandler"
end
function PlacementHandler:internalName()
return "placementhandler"
end
You can’t perform that action at this time.