Skip to content

Instantly share code, notes, and snippets.

View amacgregor's full-sized avatar
:shipit:
Working on Side Projects

Allan MacGregor amacgregor

:shipit:
Working on Side Projects
View GitHub Profile
@amacgregor
amacgregor / multiple_traits_extend.php
Last active August 29, 2015 13:57
Multiple traits extended example
<?php
class Animal {
public function roar() {
echo "Makes animal sounds";
}
}
trait Feline {
public function roar() {
<?php
function dbfetch() {
$r = mysql_query('SELECT ... ');
if ($r === false || mysql_num_rows($r) ==0){
return null;
}
return new DBData(mysql_fetch_array($r));
<?php
/**
* Simple Magento integration test PHPUnit bootstrap
*/
chdir(__DIR__ . '/../..');
$mageFile = 'htdocs/app/Mage.php';
umask(0);
@amacgregor
amacgregor / custom-options.sh
Created April 18, 2014 12:30
PHPFarm custom options file
configoptions="
--enable-cli \
--enable-debug \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
@amacgregor
amacgregor / custom-php.ini
Created April 18, 2014 12:32
PHPFarm Example custom php.ini file
date.timezone=America/Toronto
memory_limit=1024M
include_path=".:/opt/phpfarm/inst/php-$version/pear/php/"
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName test.mydomain.com
DocumentRoot /srv/www/test.mydomain.com/public_html
<Directory "/srv/www/cgi-bin/php-cgi-5.3.28">
Require all granted
Allow from all
</Directory>
require 'httparty'
require 'nokogiri'
USERNAME = "email-used@in-registration.com"
PASSWORD = "your-password-here"
COOKIE_FILE = 'cookies.txt' # by example
class ElixirsipsDownloader
FEED_URL = "https://elixirsips.dpdcart.com/feed"
LOGIN_URL = "http://elixirsips.dpdcart.com/subscriber/content"
require Record
defrecord :xmlElement, Record.extract(:xmlElement, from_lib: "xmerl/include/xmerl.hrl")
defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl")
defrecord :xmlAttribute, Record.extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl")
defmodule RssParserTest do
use ExUnit.Case
def sample_xml do
var BASE_URL = casper.cli.get('url');
// Go to home
casper.test.comment('Go to home');
casper.start(BASE_URL, function() {
this.test.pass('Home was loaded');
});
// Go to product list
casper.then(function() {
configoptions="
--enable-cli \
--enable-debug \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-pcntl \
--enable-soap \