Skip to content

Instantly share code, notes, and snippets.

@enru
enru / copyext2mage.sh
Created February 25, 2011 19:28
copies a magento aheadworks or mageworx extension into magento
# first cd into aheadworks or mageworx extension dir
# (this assumes it's been unzipped into magento's root dir)
for x in `find step_*`; do
y=`echo $x | awk '{ sub("step_[0-9]+/", ""); print "../"$0; }'`;
if [ -d "$x" ] && ! [ -e "$y" ] ; then mkdir -p $y; fi;
if [ -f "$x" ]; then cp $x $y; fi;
done
@enru
enru / OpenLayers.Touch.Handler.js
Created April 6, 2011 10:51
touch handler for openlayers maps
/*
* touch handler for openlayers maps on mobile
* see: http://www.openlayers.org/
*/
var map = {} // dummy object -> create & init an openlayers map
Touch = (function() { return {
startX: 0,
startY: 0,
@enru
enru / escape_mysql_charset_hell.py
Created September 7, 2011 16:49
escape mysql characterset hell (converts text to sanitised utf8)
#!/usr/bin/env python
# inspired by this post:
# http://www.bluebox.net/news/2009/07/mysql_encoding
import MySQLdb
DB_NAME="example"
DB_USER="root"
DB_HOST="locahost"
@enru
enru / .vimrc
Last active September 27, 2015 07:57
a .vimrc file
set expandtab
set nocompatible
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set showmatch
set guioptions-=T
set vb t_vb=
set ruler
@enru
enru / gist:1337686
Created November 3, 2011 20:27
An example of how to give a WordPress plugin it's own URL/route
<?php
/*
Plugin Name: redirect/routes test
Plugin URI: http://blog.enru.co.uk/2011-11-04-wordpress-plugin-with-own-url.html
Description: An example of how to give a WordPress plugin it's own URL/route
Version: 0.1
Author: Neill Russell
Author URI: http://www.enru.co.uk
License: Beerware
*/
@enru
enru / ffmpeg_encode_jpegs.sh
Created November 12, 2011 15:04
ffmpeg encode jpgs stop motion
#!/bin/bash
c=0; for i in *.JPG; do mv "$i" "`printf %05d $c`.jpg"; c=$((c+1));done
ffmpeg -r 6 -b 2000 -i %05d.jpg -vcodec libx264 -vpre hq -vpre ipod640 -an -threads 0 -b 5000k video.mp4
@enru
enru / phonegapcopy.xml
Created November 19, 2011 21:11
copies files & sets up phonegap in a new android app
<project name="PhoneGapCopy" default="init" basedir=".">
<description>
sets up phonegap in a new android app
usage: ant -f phonegapcopy.xml -DPHONEGAP_HOME=/home/enru/phonegap-9f0856d
</description>
<property name="PHONEGAP_HOME" value=""/>
<target name="init">
<copy todir="./libs/">
<fileset dir="${PHONEGAP_HOME}/Android/">
<include name="phonegap-*.jar"/>
@enru
enru / insert_category_attribute.sql
Last active March 28, 2016 18:23
insert Magento category attribute
INSERT INTO `eav_attribute` (`entity_type_id`,
`attribute_code`,
`attribute_model`,
`backend_model`,
`backend_type`,
`backend_table`,
`frontend_model`,
`frontend_input`,
`frontend_input_renderer`,
`frontend_label`,
@enru
enru / mage_table_rates_creator.php
Created December 8, 2011 15:52
auto-creates (kinda) a CSV suitable for Magento's table rates shipping method
<?php
/*
* Created on Sep 28, 2009
* @author Neill Russell <n@enru.co.uk>
*/
if($argc < 2) die(sprintf("Usage: %s <MAGENTO_ROOT>\n", $_SERVER['SCRIPT_FILENAME']));
define('MAGENTO_DIR', realpath($argv[1]));
@enru
enru / gist:3872197
Created October 11, 2012 13:15
woocommerce top level product cats
select * from wp_term_taxonomy tt
left join wp_terms t on tt.term_id = t.term_id
where tt.taxonomy = 'product_cat' and tt.parent = 0;