Skip to content

Instantly share code, notes, and snippets.

View davidcraig's full-sized avatar

David Craig davidcraig

View GitHub Profile
@davidcraig
davidcraig / keybase.md
Created March 10, 2017 18:17
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 March 31, 2017 07:56
PhantomJS - Take a screenshot of a webpage as seen in the browser.
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 March 31, 2017 09:03
PHP script to install packages globally on a linux/mac box
<?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 March 31, 2017 09:04
PHP: Countdown to a given date
<?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 March 31, 2017 09:09
PHP: CSS Asset Pipeline
<?php
$files = [
// Insert Files Here
];
$str = '';
function combine_file_contents($filename, $str)
{
@davidcraig
davidcraig / template.php
Last active July 19, 2017 08:53
Drupal 7 - Add transformed page title as a body class.
<?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 December 8, 2017 13:11
Blockstack.org verification
Verifying my Blockstack ID is secured with the address 19f4LPMy5SXcgPz6VcBubrkRuGZSvmvSKY https://explorer.blockstack.org/address/19f4LPMy5SXcgPz6VcBubrkRuGZSvmvSKY
@davidcraig
davidcraig / functions.php
Created January 23, 2018 11:36
WordPress - Remove version number from enqueued scripts/styles.
// 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 April 18, 2018 08:30
VueJS Debugging: Listing registered components.
const app = new Vue({
el: '#app'
});
// Output list of components to the browser devtools.
console.log(app.$options.components);
@davidcraig
davidcraig / colours.css
Created March 16, 2019 18:58
Flat UI Colours - CSS Variables and Sass Variables
/* 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;