Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View stuartjnelson's full-sized avatar

Stuart Nelson stuartjnelson

View GitHub Profile
@stuartjnelson
stuartjnelson / Ternary Statement PHP.php
Created February 10, 2016 16:45
Sublime Text Snippet PHP Ternary Statement
<snippet>
<content>
<![CDATA[
\$var = ( !empty( \$my_var ) ) ? \$my_var : 'default value';
]]></content>
<tabTrigger>ternary</tabTrigger>
<scope>source.php</scope>
<description>ternary …</description>
</snippet>
@stuartjnelson
stuartjnelson / get_the_content.php
Created May 31, 2016 17:00
Getting `the_content()` from another post.
<?php
$my_postid = 12;//This is page id or post id
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
?>
@stuartjnelson
stuartjnelson / cloudSettings
Last active June 26, 2019 11:39
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-06-26T11:39:00.251Z","extensionVersion":"v3.3.0"}
@stuartjnelson
stuartjnelson / node-check-for-img.js
Created March 20, 2020 19:10
Node check for images
// Currenet setup
.use('/images/', express.static( path.resolve(`${imagePath}/images/`)) )
// New idea
.get('/' + 'images' + '/*', function (req, res) {
const imgUrl = `${imagePath}${req.url}`
console.log(`imgUrl: ${imgUrl}`)
const urlExists = url => new Promise(
(resolve, reject) => request.head(url) .on("response", res => resolve(res.statusCode.toString()[0] ==="2"))