Skip to content

Instantly share code, notes, and snippets.

View danlamanna's full-sized avatar
🏠
Working from home

Dan LaManna danlamanna

🏠
Working from home
View GitHub Profile
@danlamanna
danlamanna / gist:1323994
Created October 29, 2011 02:06
Adding specific pods to the admin bar menu
add_filter('show_admin_bar', 'pods_admin_bar_displaying');
/**
* Checks if the admin bar is being displayed for current user.
*
* @global bool $podsAdminBarEnabled
* @param bool $currentStatus
* @return bool
*/
function pods_admin_bar_displaying($currentStatus) {
@danlamanna
danlamanna / gist:1325012
Created October 29, 2011 20:07
Making a custom pod widget
<?php
add_action('widgets_init', 'pods_register_widgets');
/**
* Register any/all pods widgets with wordpress.
*/
function pods_register_widgets() {
register_widget('Pods_Custom_Widget');
}
@danlamanna
danlamanna / gist:1325185
Created October 29, 2011 22:34
Pods Caching Examples
<?php
define('CACHE_DURATION', 1800); // 30 mins
define('PODS_CACHE_GROUP', 'pods_plugin');
// Example of pods->find() method with database caching
public function find ($params, $limit = 15, $where = null, $sql = null) {
// Cache key is combo of current pod id, and query string of arguments
// May want to prefix with pods_plugin?
$findPodCacheKey = $this->id . http_build_query(array($params, $limit, $where, $sql));
@danlamanna
danlamanna / SVN.py
Created November 19, 2011 22:45
Sublime Text 2 - SVN Plugin
import sublime, sublime_plugin
import os, commands
import json, re
import pprint
""" TODO:
- have settings file with username/password/additional flags?
- options menu, per file/folder commands
@danlamanna
danlamanna / Default (Linux).sublime-keymap
Created November 21, 2011 14:12
Keymap for SVN Plugin
[
{ "keys": ["shift+alt+a"],
"command": "subversion",
"args": {
"svn_command": "add",
"on_file": "False"
}
},
{ "keys": ["shift+alt+c"],
@danlamanna
danlamanna / Grid.php
Created January 26, 2012 03:44
Adding customer attributes to Magento Adminhtml Order Grid.
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->joinLeft(array('sfoa'=>'sales_flat_order_address'),'sfoa.entity_id=main_table.entity_id',array('sfoa.postcode'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
@danlamanna
danlamanna / gist:1696532
Created January 29, 2012 01:05
Example pull database script
#!/bin/bash
SLAVE_DB_USER="foo"
SLAVE_DB_PASS="bar"
SLAVE_DB_NAME="foobar"
SLAVE_DB_HOST="127.0.0.1"
MASTER_DB_USER="production_foo"
MASTER_DB_PASS="foobarbaz"
MASTER_DB_NAME="production"
@danlamanna
danlamanna / gist:1865613
Created February 19, 2012 20:29
Removing a specific node from a linked list.
protected void _removeNodeFromLinkedList(Node toBeRemoved) {
Node previousNode = null;
Node nextNode = this.pFirst.pNext;
for (Node currentNode = this.pFirst; currentNode != null; currentNode = currentNode.pNext) {
if (currentNode == toBeRemoved) {
// We need to remove the first from the linked list
if (currentNode == this.pFirst) {
// Set the next node (second) to be pFirst
this.pFirst = nextNode;
@danlamanna
danlamanna / gist:2589535
Created May 3, 2012 21:10
Programatically Re-indexing Magento Indexes
<?php
// Specifically getting catalog_url indexer, returns Mage_Index_Model_Process
$catalog_url_rewrite_process = Mage::getSingleton('index/indexer')->getProcessesCollection()
->addFieldToFilter('indexer_code', 'catalog_url')
->getFirstItem();
// Can use reindexAll(), or reindexEverything which checks dependencies, and returns reindexAll()
@danlamanna
danlamanna / fabfile.py
Created May 11, 2012 10:50
Fabric Pull Database
from fabric.api import *
from fabric.context_managers import hide
from fabric.operations import local, put, prompt, get
from time import time
import json
import os
import re
import sys
from string import strip