Skip to content

Instantly share code, notes, and snippets.

David Craig davidcraig

Block or report user

Report or block davidcraig

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
View keybase.md

Keybase proof

I hereby claim:

  • I am davidcraig on github.
  • I am davidcraig (https://keybase.io/davidcraig) on keybase.
  • I have a public key ASCS6tljw6uR0ejp0THG42z5SrUTSOesfVUvfRqJGDfojgo

To claim this, I am signing this object:

@davidcraig
davidcraig / script.js
Last active Mar 31, 2017
PhantomJS - Take a screenshot of a webpage as seen in the browser.
View script.js
var website = 'http://www.google.co.uk';
var filename = './google.jpg';
var page = require('webpage').create();
page.viewportSize = {
width: 1024,
height: 592
};
page.open(website, function(status) {
@davidcraig
davidcraig / setup.php
Created Mar 31, 2017
PHP script to install packages globally on a linux/mac box
View setup.php
<?php
$composer_src = "https://getcomposer.org/composer.phar";
$phpdoc_src = "http://phpdoc.org/phpDocumentor.phar";
$phpunit_src = "https://phar.phpunit.de/phpunit.phar";
$yes_values = ['', 'y', 'Y', 'yes', 'Yes'];
$bin_path = "/usr/local/bin/";
function install_package($name, $package_url)
@davidcraig
davidcraig / countdown.php
Last active Mar 31, 2017
PHP: Countdown to a given date
View countdown.php
<?php
$date = ''; // Pass in your date variable here, eg $date = '2014-09-08'
$today = new DateTime();
$to = new DateTime($date);
$countdown = $today->diff($to);
// Seperate variables for days, months, years, etc.
$seconds = $countdown->s;
$days = $countdown->d;
@davidcraig
davidcraig / css.php
Created Mar 31, 2017
PHP: CSS Asset Pipeline
View css.php
<?php
$files = [
// Insert Files Here
];
$str = '';
function combine_file_contents($filename, $str)
{
@davidcraig
davidcraig / template.php
Last active Jul 19, 2017
Drupal 7 - Add transformed page title as a body class.
View template.php
<?php
/**
* HTML template preprocessing.
*/
function MYTHEME_preprocess_html(&$variables) {
// Add the page title as a css class to allow for page specific targetting.
try {
if (!drupal_is_front_page()) {
$title = drupal_get_title();
@davidcraig
davidcraig / verification.block
Created Dec 8, 2017
Blockstack.org verification
View verification.block
Verifying my Blockstack ID is secured with the address 19f4LPMy5SXcgPz6VcBubrkRuGZSvmvSKY https://explorer.blockstack.org/address/19f4LPMy5SXcgPz6VcBubrkRuGZSvmvSKY
@davidcraig
davidcraig / functions.php
Created Jan 23, 2018
WordPress - Remove version number from enqueued scripts/styles.
View functions.php
// remove wp version param from any enqueued scripts
function enqueueRemoveWpVersion($src) {
if ( strpos($src, 'ver='))
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'enqueueRemoveWpVersion', 9999 );
add_filter( 'script_loader_src', 'enqueueRemoveWpVersion', 9999 );
@davidcraig
davidcraig / app.js
Last active Apr 18, 2018
VueJS Debugging: Listing registered components.
View app.js
const app = new Vue({
el: '#app'
});
// Output list of components to the browser devtools.
console.log(app.$options.components);
@davidcraig
davidcraig / colours.css
Created Mar 16, 2019
Flat UI Colours - CSS Variables and Sass Variables
View colours.css
/* Flat UI Colours: https://flatuicolors.com/palette/defo */
/* CSS Variables */
:root {
/* Greens */
--flat-ui-turquoise: #1abc9c;
--flat-ui-grean-sea: #16a085;
--flat-ui-emerald: #2ecc71;
--flat-ui-nephritis: #27ae60;
You can’t perform that action at this time.