Skip to content

Instantly share code, notes, and snippets.

Andrew Collington amnuts

Block or report user

Report or block amnuts

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
amnuts / jquery.sameheight.js
Created Nov 4, 2013
A jQuery plug-in to make elements the same height (by max height or min height)
View jquery.sameheight.js
* Same Height, jQuery plug-in.
* This plug-in allows you to automatically have all of the elements marked
* with a particular class to be the same height, either by smallest or
* largest.
* By default, 'samemaxheight' and 'sameminheight' will be used.
* Examples of use:
amnuts / crossfade.js
Last active Dec 27, 2015
Quick and easy way to cross-fade between elements in a list. If those elements contained images then you have a very simple slideshow. (Requires jQuery.)
View crossfade.js
if ($('ul.crossfade').length) {
var ul = $(this);
if ($('li', ul).length > 1) {
$('li:gt(0)', ul).hide();
var fadeSpeed = (ul.attr('data-fadespeed') !== undefined ? ul.attr('data-fadespeed') : 1000);
var nextSpeed = (ul.attr('data-nextspeed') !== undefined ? ul.attr('data-nextspeed') : 5000);
$('li:first', ul)
amnuts / scraping.php
Last active Dec 28, 2015
Example of how to scrape multiple pages using Zend\Dom from Zend Framework 2.
View scraping.php
use \Zend\Dom\Query;
use \Zend\Debug\Debug;
* Fetch the page source and cache it, ensuring it's saved as UTF-8
* @param string $url
* @return string
amnuts / merge_urls.php
Last active Dec 29, 2015
Merge two urls using PHP
View merge_urls.php
* Combine two urls.
* The urls can be either a string or url parts that consist of:
* scheme, host, port, user, pass, path, query, fragment
* If passed in as parts in an array, the query parameter can be either
amnuts /
Last active Dec 29, 2015
An example of making a motor spin (by ramping up and then down the speed) and sending a tweet when a button connected to the Raspberry Pi is pushed.
import RPi.GPIO as GPIO
from time import sleep
import os
from twitter import *
from random import choice
from datetime import datetime
op1 = 11
op2 = 13
amnuts / greeting.zep
Last active Jan 4, 2016
Zephir not incrementing correctly?
View greeting.zep
namespace Utils;
class Greeting
protected counter1 = 0;
protected counter2 = 0;
protected counter3 = 0;
protected revcounter1 = 5;
protected revcounter2 = 5;
protected revcounter3 = 5;
amnuts / osort.php
Last active Jul 24, 2018
Sort array of objects by one or more properties of the object.
View osort.php
* Sort an array of objects.
* Requires PHP 5.3+ to be installed.
* Will use the Intl extension to normalize characters if it's
* available.
amnuts / speechSynthesis.js
Created Nov 17, 2014
Add a link to read text aloud including the option of swapping to any available voices.
View speechSynthesis.js
if ('speechSynthesis' in window) {
var createdVoiceList = false;
$('<div/>', {'class':'speechUI'}).append('<a href="#" class="speakContent">read text aloud</a>&nbsp;')
var addVoices = function() {
var select = '';
amnuts / phpstorm.bat
Last active Jul 19, 2019
Add context menu to Windows 7 to open file/folder in PhpStorm
View phpstorm.bat
@echo off
SET PhpStormPath=C:\Program Files (x86)\JetBrains\PhpStorm 8.0.2\bin\PhpStorm64.exe
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in PhpStorm" /t REG_SZ /v "" /d "Open in PhpStorm" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f
echo Adding folder entries
amnuts / aspect-ratio.php
Last active Sep 30, 2016
Aspect ratio from width/height
View aspect-ratio.php
function ratio($a, $b)
$gcd = function($a, $b) use (&$gcd) {
return ($a % $b) ? $gcd($b, $a % $b) : $b;
$g = $gcd($a, $b);
return $a/$g . ':' . $b/$g;
You can’t perform that action at this time.