Skip to content

Instantly share code, notes, and snippets.

View PhilKershaw's full-sized avatar

Phil Kershaw PhilKershaw

View GitHub Profile
### Keybase proof
I hereby claim:
* I am philkershaw on github.
* I am philkershaw (https://keybase.io/philkershaw) on keybase.
* I have a public key ASAuiFSnxj0tQ5m06aa4W1LveaSzv7yOxMcn3aGXDLhPtgo
To claim this, I am signing this object:
@PhilKershaw
PhilKershaw / deleteSalesRules.php
Last active August 29, 2015 14:06
Simple tool for deleting Sales Rules in Magento
<?php
/**
* Simple tool for deleting Sales Rules
*
* @TODO add function to delete by ID
*
* @author Phil Kershaw
*/
require_once '../app/Mage.php';
@PhilKershaw
PhilKershaw / gist:f8e995e6b7d749e30740
Last active November 2, 2020 05:45
Simple script to export a CSV from Magento for consumption by eKomi
<?php
require_once ("app/Mage.php");
class TradeOrders
{
private static $headers = array('ORDER_ID', 'EMAIL', 'LAST_NAME', 'FIRST_NAME', 'PRODUCT_ID', 'PRODUCT_NAME');
public static function get($from, $to) {
// Fetch all UK Trade orders within specified date range
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
@PhilKershaw
PhilKershaw / StringInterleaving.js
Created April 1, 2014 21:20
Simple string interleaving. The resultant string will be as long as the shortest stringx2 and as an added bonus the penultimate character of the first string is appended to the end. All in raw JavaScript.
var string1 = 'ARNFH-U-5728';
var string2 = 'SO06DNV';
var array1 = string1.split('');
var array2 = string2.split('').reverse();
var obfuscated = '';
array1.every(function(e, i, a) {
if (typeof array2[i] === 'undefined') {
@PhilKershaw
PhilKershaw / Status.php
Last active January 3, 2016 05:39
Twitter status class - Provides the ability to fetch status' for a Twitter account using Zend Service (1.12)
<?php
/**
* Twitter status class
*
* Provides the ability to fetch status' for a Twitter account.
*
* @package Twitter
* @subpackage Twitter_Status
* @author Phil Kershaw
*/
@PhilKershaw
PhilKershaw / fetch_tweets.php
Last active December 30, 2015 18:49
A helper class which uses Zend Service to fetch Twitter status' - can be used in any project. See comments for Zend Framework dependencies.
<?php
/**
* Twitter status class
*
* Helper Class to fetch status' for a Twitter account via Zend Service.
*
* @package PKLib
* @subpackage Twitter
* @author Phil Kershaw
*/
@PhilKershaw
PhilKershaw / available_times.php
Last active December 30, 2015 05:58
Showing call-back times for the whole week: Mon - Fri: 9am - 6pm Sat: 9am -5:30pm Sun: 11am - 5pm ...and breathe!
<?php
$available_times = array(
"09:00:00" => '<option value="%s 09:00:00">%s 9.00am - 10.00am</option>',
"10:00:00" => '<option value="%s 10:00:00">%s 10.00am - 11.00am</option>',
"11:00:00" => '<option value="%s 11:00:00">%s 11.00am - 12.00pm</option>',
"12:00:00" => '<option value="%s 12:00:00">%s 12.00pm - 1.00pm</option>',
"13:00:00" => '<option value="%s 13:00:00">%s 1.00pm - 2.00pm</option>',
"14:00:00" => '<option value="%s 14:00:00">%s 2.00pm - 3.00pm</option>',
"15:00:00" => '<option value="%s 15:00:00">%s 3.00pm - 4.00pm</option>',
"16:00:00" => '<option value="%s 16:00:00">%s 4.00pm - 5.00pm</option>',
@PhilKershaw
PhilKershaw / _applyEntities.php
Last active December 29, 2015 00:19
Wrap URLs in tweets in a tags.
<?php
private static function _applyEntities(&$feed)
{
if (null !== $feed) {
foreach($feed as &$item) {
if (null !== $item['entities']['urls']) {
$urls = array_reverse($item['entities']['urls']);
$content = &$item['text'];
foreach ($urls as $url) {
$content = substr_replace($content, '</a>', $url['indices'][1], 0);
@PhilKershaw
PhilKershaw / xhr-POST-with-file.js
Created October 8, 2013 11:35
Rought example of an xhr POST request with a file
var str_title = document.querySelector('#category_box_title').value;
var str_url = document.querySelector('#category_box_url').value;
var arr_image = document.querySelector('#category_box_image').files[0];
var int_id = document.querySelector('#category_box_id').value;
var formData = new FormData();
formData.append('title', str_title);
formData.append('url', str_url);
formData.append('image', arr_image);
formData.append('web_page_content_widget_id', int_selected_content_widget_id);