Skip to content

Instantly share code, notes, and snippets.

@veganista
veganista / file.liquid
Created April 20, 2016 10:56
Debugging Objects in Shopify Templates
<script>console.log({{ product | json }});</script>
@veganista
veganista / destroy-sample-data.php
Created May 10, 2012 14:17 — forked from mgirouard/destroy-sample-data.php
A quick hack to destroy all sample data in an OpenCart catalog.
<?php
$options = getopt('p:');
$prefix = empty($options['p'])
? realpath('.')
: realpath($options['p']);
if (empty($prefix)) {
die("Bad prefix. Try again.\n");
}
@veganista
veganista / arrayToTable.js
Last active October 22, 2021 00:06
jQuery array to HTML table.
var arrayToTable = function (data, options) {
"use strict";
var table = $('<table />'),
thead,
tfoot,
rows = [],
row,
i,
@veganista
veganista / OpenCartValetDriver.php
Created October 3, 2016 08:30
Laravel Valet Driver - OpenCart 2.x
<?php
class OpenCartValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@veganista
veganista / recipe.md
Created July 15, 2016 10:34
WP CLI Commands

Assign all post thumbnail to a specific attachment

wp post list --post_type=post --format=ids | tr ' ' '\n' | xargs -I % wp post meta add % _thumbnail_id {{ATTACHMENT_ID}}

@veganista
veganista / opencart.php
Created June 21, 2016 10:35
Get the path to a category in opencart 1.5.*
<?php
/**
* Returns the path to a category in the format 1_2_3
* @param int $category_id
* @return string the path to the category
*/
public function getCategoryPath($category_id){
$path = '';
@veganista
veganista / functions.php
Created May 9, 2016 09:06
Disable author pages in WordPress
/**
* Disable author pages
*/
add_action( 'template_redirect', function(){
global $wp_query;
if ( is_author() && !is_404() ) {
$wp_query->set_404();
status_header( 404 );
nocache_headers();
}
@veganista
veganista / example.php
Created September 26, 2013 10:28
Getting the URL of category in OpenCart.
<?php echo $this->url->link('product/category', 'path=96'); ?>
// http://example.com/category-three/
<?php echo $this->url->link('product/category', 'path=63_78'); ?>
// http://example.com/category-one/category-two/
<?php echo $this->url->link('product/category', 'path=63_78_96'); ?>
@veganista
veganista / gist:5764323
Created June 12, 2013 10:42
Batch resize images from CLI with image magick
convert *.jpg -resize 236 -set filename:filename '%t-%wx%h' 'resized/%[filename:filename].jpg'
public function beforeSave(Model $model, array $options = array()){
var_dump($model->data['User']);
//array (size=4)
// 'id' => string '66' (length=2)
// 'first_name' => string 'new first name' (length=14)
// 'last_name' => string 'new last name' (length=13)
// 'email' => string 'liam@email.com' (length=14)
$x = $model->find('first', array('conditions' => array($model->alias . '.' .$model->primaryKey => $model->id), 'contain' => 'User'));