Skip to content

Instantly share code, notes, and snippets.

View danielgwood's full-sized avatar

Daniel Wood danielgwood

View GitHub Profile
@danielgwood
danielgwood / gist:ceee3ba0b4133b2846e1ad752614a52e
Created July 9, 2021 06:38
Bookmarklet to remove overflow hidden from <body>
javascript:(function(){document.body.style.overflow = 'visible';})();
@danielgwood
danielgwood / altcontroller_contact_form.php
Created December 30, 2014 11:46
Concrete5.7 external forms issue
<?php
/**
* Alternative controller file - this one is actually loaded, though I'm forced to put it somewhere silly.
* (installed at concrete/blocks/external_form/form/controller/contact_form.php)
*/
namespace Concrete\Block\ExternalForm\Form\Controller;
class ContactForm extends \Concrete\Core\Controller\AbstractController
@danielgwood
danielgwood / wordpress.md
Last active March 6, 2016 00:16
Wordpress plugins

Wordpress plugins

Appearance

  • Unique Headers
  • Simple Page Sidebars

Security

  • Akismet
  • AntiVirus
  • Block Bad Queries (BBQ)
  • Wordfence Security
@danielgwood
danielgwood / gist:1510463
Created December 22, 2011 14:23
Human formatted time between dates (JavaScript)
/**
* Given two dates (or one date and assume "now" for the second), convert this to
* a human-readable string, like "2 months".
*
* I use this to put "3 months ago" strings into plugins. My use case has the date
* coming in as a seconds-only UNIX epoch, so the params are expected at this.
*
* @param time1 integer Number of seconds since UNIX epoch
* @param time2 integer Number of seconds since UNIX epoch
* @return string
@danielgwood
danielgwood / gist:1244903
Created September 27, 2011 12:07
MongoDB shell cheatsheet
// A bunch of functions you can use in the MongoDB shell
// taken from http://api.mongodb.org/js/1.8.2/index.html
// amongst other sources
// Used in place of print() to view the contents of objects
printjson(x);
printjsononeline(x);
// File system interaction
ls(...);
@danielgwood
danielgwood / gist:953089
Created May 3, 2011 09:56
Round a decimal to the nearest half
<?php
/**
* Round a decimal to the nearest half, so:
* 0 becomes 0
* 0.2 becomes 0
* 1 becomes 1
* 2.5 becomes 2.5
* 2.51 becomes 2.5
* 2.49 becomes 2.5
@danielgwood
danielgwood / Date.php
Created April 25, 2011 20:15
Some utility functions for working with dates in PHP
<?php
class Date
{
/**
* Returns time difference between two timestamps, in human readable format.
*
* @param int $time1 A timestamp.
* @param int $time2 A timestamp, defaults to the current time.
* @param string $output Formatting string specifying which parts of the date to return in the array.
@danielgwood
danielgwood / gist:941117
Created April 25, 2011 20:12
Number of seconds -> neatly formatted duration
<?php
/**
* Parse a number of seconds into a more readable format.
*
* @param int $seconds Length of time.
* @param string $minSeparator Placed between min and second values.
* @param string $hourSeparator Placed between hour and minute values.
* @return string
*/
@danielgwood
danielgwood / gist:940971
Created April 25, 2011 18:36
Holmes.css bookmarklet
<!--
Holmes.css bookmarklet
Adds the holmes tests (see https://github.com/redroot/holmes) to any page at a click of a button
Usage instructions:
1. Install the latest version of holmes on your local/personal web server
2. Create a new HTML page containing the contents of this Gist
3. Edit the href to holmes in the source, if your holmes stylesheet is not located at http://localhost/tools/holmes.min.css
4. Open the HTML page in your browser, and drag the bookmarklet to your bookmarks bar