This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$image = imagecreatefrompng( 'trees.png' ); | |
$width = imagesx( $image ); | |
$height = imagesy( $image ); | |
// Create | |
$output = imagecreatetruecolor($width, $height); | |
for( $y = 0; $y < $height; $y++ ){ | |
for( $x = 0; $x < $width; $x++ ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printf syntax | |
%[parameter][flags][width][.precision][length]type | |
https://carlalexander.ca/php-string-formatting/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function compose_url(array $server){ | |
// Scheme | |
$scheme = ''; | |
if (isset($server['SERVER_PROTOCOL'])) { | |
$scheme = explode('/', $server['SERVER_PROTOCOL']); | |
$scheme = strtolower($scheme[0]); | |
if (isset($server['HTTPS']) && 'off' != $server['HTTPS']) { | |
$scheme .= 's'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name | |
slug | |
version | |
author | |
author_profile | |
contributors | |
requires | |
tested | |
compatibility | |
rating |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ratio = width / height | |
width = height * ratio | |
height = width / ratio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Content-type: multipart/form-data, boundary={$boundary} | |
Content-Length: {$contentLength} | |
--{$boundary} | |
content-disposition: form-data; name="field1" | |
{$field1} | |
--{$boundary} | |
content-disposition: form-data; name="field2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IMAGETYPE_UNKNOWN 0 | |
IMAGETYPE_GIF 1 | |
IMAGETYPE_JPEG 2 | |
IMAGETYPE_PNG 3 | |
IMAGETYPE_SWF 4 | |
IMAGETYPE_PSD 5 | |
IMAGETYPE_BMP 6 | |
IMAGETYPE_TIFF_II 7 | |
IMAGETYPE_TIFF_MM 8 | |
IMAGETYPE_JPEG2000 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE a,b,c | |
FROM wp_posts a | |
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) | |
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) | |
WHERE a.post_type = 'revision' |