Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / jquery-capture-css3-transition-end-event.js
Created Jul 9, 2012
jQuery Capture CSS3 Transition End Event
View jquery-capture-css3-transition-end-event.js
$(document).ready(function() {
$('div').on('transitionend MSTransitionEnd webkitTransitionEnd oTransitionEnd', function(event) {
// Do stuff after transition
});
});
@ziadoz
ziadoz / dpkg.sh
Last active Oct 7, 2015
Create List of Installed Packages (Ubuntu/Debian)
View dpkg.sh
# See: http://ubuntuforums.org/showthread.php?t=261366
# Make list of installed software.
dpkg --get-selections > installed-software
# Install software on another machine.
dpkg --set-selections < installed-software
sudo apt-get install dselect
dselect
@ziadoz
ziadoz / gist:3124039
Created Jul 16, 2012
Clone VirtualBox Image
View gist:3124039
# Clear Ubuntu image network rules before cloning.
sudo rm /etc/udev/rules.d/70-persistent-net.rules
# Clone a VirtualBox disk image.
VBoxManage clonehd /path/to/original.vdi /path/to/clone.vdi
@ziadoz
ziadoz / hgrc
Created Jul 16, 2012
Mercurial Remote Deployment
View hgrc
# /path/to/repository/.hg/hgrc
# $ hg push staging
# $ hg push live
[paths]
live = ssh://<username>@<server>//var/www/vhosts/<live-website>
staging = ssh://<username>@<server>//var/www/vhosts/<staging-website>
[hooks]
changegroup = hg update
@ziadoz
ziadoz / meta-programming.php
Created Jul 17, 2012
Basic Meta Programming with PHP 5.4
View meta-programming.php
<?php
trait MetaClass
{
protected $__classMethods = array();
static protected $__staticMethods = array();
public function __call($name, $args)
{
@ziadoz
ziadoz / gist:3130725
Created Jul 17, 2012
Setup XCode, CLI Tools and HomeBrew
View gist:3130725
# Install XCode.
# Install XCode CLI Tools.
# Select XCode.
xcode-select -switch /Applications/Xcode.app/Contents/Developer
# Install Auto Tools.
brew install autoconf automake
# Symlink iOS Simulator.
@ziadoz
ziadoz / compile.sh
Created Jul 17, 2012
Upgrade Ubuntu 10.04 to PHP 5.4.8
View compile.sh
# Install Dependencies
# sudo apt-get install build-essential
# sudo apt-get build-dep php5
sudo apt-get install libmysqlclient-dev mysql-client libcurl4-openssl-dev libgd2-xpm-dev libjpeg-dev libpng3-dev libxpm-dev libfreetype6-dev libt1-dev libmcrypt-dev libxslt1-dev bzip2 libbz2-dev libxml2-dev libevent-dev libltdl-dev libmagickwand-dev libmagickcore-dev imagemagick libreadline-dev libc-client-dev libsnmp-dev snmpd snmp libvpx-dev libxpm-dev libgmp3-dev libicu-dev libpspell-dev libtidy-dev freetds-dev unixodbc-dev librecode-dev libglib2.0-dev libsasl2-dev libgeoip-dev imagemagick libmagickcore-dev libmagickwand-dev
# Stop Apache
sudo service apache2 stop
# Cleanup Packages
sudo apt-get autoremove
@ziadoz
ziadoz / datetime.php
Last active Mar 21, 2018
Using PHP DateTime
View datetime.php
<?php
// Comparison and Formatting
$start = new DateTime('now');
$end = new DateTime('2014-02-01');
echo 'Start: ' . $start->format('d M Y') . "\n";
echo 'End: ' . $end->format('d M Y') . "\n";
$diff = $end->diff($start);
echo 'Comparison: ' . ($start < $end ? 'Start is less than End' : 'End is less than Start') . "\n";
@ziadoz
ziadoz / BCrypt.php
Created Jul 30, 2012
A Lightweight PHP BCrypt Class
View BCrypt.php
<?php
class BCrypt
{
/**
* Work factor cost boundaries and default.
*
* @var const
*/
const COST_MIN = 4;
const COST_MAX = 31;
@ziadoz
ziadoz / scrape.php
Created Aug 13, 2012
Scraping Google using PHP and Goutte:
View scrape.php
<?php
/**
* Todo: Send a random user agent string and sleep a random amount between requests.
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Extract and sanatize input:
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_URL);
$terms = filter_input(INPUT_POST, 'terms', FILTER_SANITIZE_STRING);
// Setup Goutte (which also includes Guzzle):