Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Tom J Nowell tomjn

🎯
Focusing
View GitHub Profile
@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
View keybase.md

Keybase proof

I hereby claim:

  • I am tomjn on github.
  • I am tomjn (https://keybase.io/tomjn) on keybase.
  • I have a public key whose fingerprint is ABB2 BBF9 EDA1 F2FD 3296 284E FF13 19DC 40DE 196D

To claim this, I am signing this object:

@tomjn
tomjn / readme.md
Last active Mar 19, 2016
Copy paste into the terminal on OS X to download and install everything needed for VVV, then create a VVV vagrant box in ~/vvv
View readme.md

Open the "Terminal" application in MacOS X, then copy paste the script and press enter. It will install VVV and all its dependencies.

It will also install an additional site that will show how to add your own sites ( site-name.dev ).

When finished, it will do several things:

  • Open your www folder in Finder for editing
  • Open the VVV webpage for information
  • Open the CFTP Site init scaffold with information on how to add your own sites
@tomjn
tomjn / behave.js
Last active Apr 17, 2018
Adds a shortcode to WordPress that lets you test escaping and sanitising functions on content
View behave.js
/*
* Behave.js
*
* Copyright 2013, Jacob Kelley - http://jakiestfu.com/
* Released under the MIT Licence
* http://opensource.org/licenses/MIT
*
* Github: http://github.com/jakiestfu/Behave.js/
* Version: 1.5
*/
@tomjn
tomjn / class.wp-filter-return.php
Last active Nov 1, 2017
Easy method of returning or echoing strings on filters and actions
View class.wp-filter-return.php
<?php
class WP_Filter_Return {
private $val='';
public function __construct( $val ) {
$this->val = $val;
}
public function display() {
echo $this->val;
}