Skip to content

Instantly share code, notes, and snippets.

View leek's full-sized avatar
🔌
Plugged in

Chris Jones leek

🔌
Plugged in
View GitHub Profile
<?php
namespace app\controllers;
use app\models\Downloads;
class DownloadsController extends \lithium\action\Controller {
public function index() {
$this->request->privateKeys = array('id', 'user_id');
@leek
leek / reset_permissions.sh
Created September 30, 2013 15:50
Magento - Simple reset file permissions script
#!/bin/bash
#
# Found on StackOverflow:
# http://stackoverflow.com/a/9304264/3765
#
if [ ! -f ./app/etc/local.xml.template ]; then
echo "-- ERROR"
echo "-- This doesn't look like a Magento install. Please make sure"
echo "-- that you are running this from the Magento main doc root dir"
@leek
leek / magento_urls.sql
Created July 8, 2013 21:53
Magento: Fix Hardcoded URL's in Database
UPDATE cms_block SET content = REPLACE(content, "http://www.example.com/", "{{store url=''}}");
UPDATE cms_page SET content = REPLACE(content, "http://www.example.com/", "{{store url=''}}");
--
-- AW_Blog Only
--
UPDATE aw_blog SET post_content = REPLACE(post_content, 'http://www.example.com/', "{{store url=''}}");
@leek
leek / WritingMagentoModules.md
Created July 8, 2013 21:51
Writing Modules for Magento 1.x

Writing Magento Modules

All custom modules should have a Namespace and Module Name. These are used below as {Namespace} and {Module}.

Caution: The Magento autoloader is known to have problems with CamelCase namespaces and/or modules between Windows and *nix systems. If your module requires more than one word for either of these, it is best to just concatenate them to avoid any issues (Example: {Namespace}_{Examplemodule}).

Index

#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@leek
leek / post-receive-pivotal.rb
Created May 4, 2012 18:14 — forked from pewniak747/post-receive-pivotal
Ruby Git post-receive hook to update Pivotal Tracker
#!/usr/bin/env ruby
# encoding: UTF-8
# file: hooks/post-receive-pivotal
require 'net/http'
require 'nokogiri'
# Ruby 1.8.7
class String
def force_encoding(enc)
@leek
leek / ExampleController.php
Created March 23, 2012 07:44
Symfony2 Event Listener that allows you to set Response parameters and still use the @template annotation from the SensioFrameworkExtraBundle
<?php
namespace Example\AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller,
Symfony\Component\HttpFoundation\Request,
Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class ExampleController extends Controller
{
@leek
leek / migrate.sh
Created March 15, 2012 07:10
Rackspace Cloud Sites Migration Utility Script
#!/bin/bash
#
# @author: Chris Jones <leeked@gmail.com>
# @version: 1.1.0
#
# Rackspace Cloud Sites only allows running scripts via their web-based "cron" tool.
# FTP this script into your Web directory and add it to the scheduled tasks section.
# Set the "Command Language" to: perl
# Set the "Command to Run" to: migrate.sh refreshdb
@leek
leek / gist:1942116
Created February 29, 2012 16:19
INSERT ... ON DUPLICATE KEY UPDATE with Zend Framework (Zend_Db_Table))
<?php

/**
 * @method DbTable_Row_Foo createRow()
 */
class DbTable_Foo extends Zend_Db_Table_Abstract
{
    protected $_primary  = 'foo_id';
    protected $_name     = 'foo';
@leek
leek / pagination.html.twig
Created January 20, 2012 03:00
KnpPaginatorBundle - pagination template
<div class="pager">
{% if first is defined %}
<span class="first">
{% if current != first and first < 0 %}
<a href="{{ path(route, query|merge({'page': first})) }}">first</a>
{% else %}
first
{% endif %}
</span>
{% endif %}