Skip to content

Instantly share code, notes, and snippets.

@litzinger
litzinger / getset-js.sublime-snippet
Created March 3, 2014 21:18
Creates getter and setter in JavaScript model
<snippet>
<content><![CDATA[
/**
* Get $2
*
* @return ${3:[type]} $2
*/
$1.prototye.get${1/(.*)/\u$2/} = function()
{
return this.${2:$SELECTION};
@litzinger
litzinger / ee-route-example.php
Last active August 29, 2015 13:56
How to extend EE's new routes feature in an extension hook.
<?php
public function core_template_route($uri_string)
{
ee()->your_lib_or_model->load_routes();
// Rest of your hook processing, if any.
}
public function load_routes()
#!/bin/bash
set -o errexit
# Author: David Underhill
# http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
# 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
@litzinger
litzinger / gist:8848037
Last active August 29, 2015 13:56
EE - {site_url} vs {path=""} vs relative /
This is a test case based on a discussion with @jacobrussel. He states that all EE sites
should prefix links with a single /, relative to the domain root. I argue that you should
not assume all developers work from the root of a development domain. With MAMP its easy
to setup a vhost, and hard code all your template links such as href="/some/path", but
this completely breaks if someone has to run the site on a server in which they can't
run it at the root of the domain, such as http://dev.server.com/~user/the-site/.
I recommend that links should use {path="some/page"} or more preferablly {site_url}some/page
for maximum portability, but Jacob states that adds extra overhead to parse all the {site_url}
variables. To test this case, I created a blank template in EE, and put in {site_url} 1000 times.
@litzinger
litzinger / mod.navee.php
Created January 26, 2014 22:40
_getSingleNavItem update for NavEE to also use the hook
<?php
function _getSingleNavItem($navee_id)
{
$wrapNav = array();
$count = 0;
$pages = $this->EE->config->item('site_pages');
if (is_array($pages) && sizeof($pages) > 0)
{
$pages = $pages[$this->site_id]["uris"];
@litzinger
litzinger / _phing.config.php
Last active December 30, 2015 09:49
EE config with htaccess that is unique per developer's environment. DB config is saved in an environment type, multiple developers connect to the same development database. Based off of @FocusLab's master config. Credit to @adrienneleigh for initially creating this.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
This is the file unique to each environment type, can be:
config.local.php
config.production.php
config.staging.php
*/
/*
@litzinger
litzinger / publisher.patch
Created November 21, 2013 00:45
Publisher patch for Low Search 3.0
diff --git a/third_party/publisher/libraries/Publisher/Publisher_parser.php b/third_party/publisher/libraries/Publisher/Publisher_parser.php
index fb703a5569cd7dfd85094563159c1dfd31ff5bb8..0d1aa66df547d92315a8f8a68339925e69cda4f9 100644
--- a/third_party/publisher/libraries/Publisher/Publisher_parser.php
+++ b/third_party/publisher/libraries/Publisher/Publisher_parser.php
@@ -321,22 +321,30 @@ class Publisher_parser {
$form_tag_full = str_replace($content_matches[0][$k], $str, $form_tag_full);
}
// Low Search specific, don't like doing this. Abstract it out later.
+ // Ideally there would be a hook in the form method in EE.
elseif ($name == 'params' && array_key_exists('low_search', ee()->addons->get_installed('modules')))
@litzinger
litzinger / screencapture.sh
Last active November 17, 2023 07:30
Take screenshot every 5 minutes
First, create a couple new folders:
cd ~/
mkdir Scripts
mkdir Screenshots
cd Screenshots
mkdir cron
cd ~/Scripts
vim screencapture.sh
@litzinger
litzinger / mod.add-on.php
Last active December 27, 2015 11:39
Custom no_results conditional for EE. Thanks to Low and Stephen. http://experiencehq.net/blog/ee-gotchas-nested-no-results-tags-redux
<?php
public function my_tag()
{
$this->_prep_no_results('prefix:no_results');
...
return $tagdata;
}
@litzinger
litzinger / models-publisher_entry.php
Created November 4, 2013 15:36
Better Publisher install/migration
public function install_move_data()
{
set_time_limit(2400);
$sql = array();
$sql[] = "CREATE TABLE `{$this->EE->db->dbprefix}publisher_titles` LIKE `{$this->EE->db->dbprefix}channel_titles`";
$sql[] = "INSERT INTO `{$this->EE->db->dbprefix}publisher_titles` SELECT * FROM `{$this->EE->db->dbprefix}channel_titles`";
$sql[] = "CREATE TABLE `{$this->EE->db->dbprefix}publisher_data` LIKE `{$this->EE->db->dbprefix}channel_data`";