Skip to content

Instantly share code, notes, and snippets.

@litzinger
litzinger / puphpet-config.yml
Last active August 29, 2015 14:17
Config Tricks to speed up Symfony in dev mode.
php:
install: '1'
version: '56'
composer: '1'
composer_home: ''
modules:
php:
- cli
- intl
- mcrypt
{exp:channel:form channel="pages" return="forms/channel-edit/ENTRY_ID" entry_id="{segment_3}"
include_jquery="yes"
include_assets="yes"
error_handling="inline"
use_live_url="yes"
datepicker="no"}
{field_errors}{error}{/field_errors}
<label for="title">Title</label>
@litzinger
litzinger / install-ioncube.sh
Created December 15, 2014 20:24
Install IonCube in PuPHPet
echo "Loading ioncube"
wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
echo "Unzipping ioncube"
tar xvfz ioncube_loaders_lin_x86-64.tar.gz
echo "Move ioncube to usr/local"
mv ioncube /usr/local
echo "Add ioncube to php.ini"
sudo sed -i 1i"zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.4.so" /etc/php5/fpm/conf.d/zzzz_custom.ini
sudo sed -i 1i"zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.4.so" /etc/php5/cli/conf.d/zzzz_custom.ini
echo "Restarting Apache and FPM"
<?php
define('XDEBUG', "xdebug");
define('ZEND_DEBUGGER', "Zend Debugger");
function createXmlHeader()
{
return "<?xml version=\"1.0\"?>";
}
@litzinger
litzinger / cleaner.php
Created December 3, 2014 22:34
htmlpurifier example
<?php
/*
HTMLPurifier settings example
'cleaner_xss_clean' => 'no',
'cleaner_html_clean' => 'no',
'cleaner_allow_tags_in_post' => '',
'cleaner_allow_attr_in_template' => 'href, class, src, rel, width, height',
'cleaner_allow_tags_in_template' => 'img, h1, h2, h3, h4, h5, blockquote, strong, em, p, b, a, i, ul, li, ol, br',
*/
(function () {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
document.body.appendChild(e)
}
function h() {
@litzinger
litzinger / index.sql
Created August 28, 2014 20:33
Speed up EE entries table requests
ALTER TABLE exp_channel_titles ADD INDEX sdi(sticky, entry_date, entry_id)
@litzinger
litzinger / autosave.js
Last active August 29, 2015 14:05
How to add autosave support to 3rd party fieldtype in EE that uses a custom table.
// Add Autosave support
if(typeof EE.publish == "object" && EE.publish.autosave == "object" && EE.publish.autosave.interval > 10)
{
// 3 seconds before the defined interval
interval = (EE.publish.autosave.interval - 3) * 1000;
setInterval({
run: function() {
// Do whatever you need to do here, probably an ajax request, to save data to custom table.
}
@litzinger
litzinger / pill.css
Created June 23, 2014 00:49
Add disabled option to P&T Pill
ul.pt-pill { display: inline-block; margin: 5px 0; padding: 0; list-style-type: none; height: 18px; cursor: default; white-space: nowrap;
-webkit-user-select: none; -moz-user-select: none; }
ul.pt-pill li { float: left; margin: 0 -1px 0 0; padding: 0 7px; border: 1px solid #a8b1b3; line-height: 18px; background: #fff url(../images/option_bg.gif) repeat-x; cursor: pointer; }
ul.pt-pill li:first-child { -webkit-border-top-left-radius: 3px; -webkit-border-bottom-left-radius: 3px; -moz-border-radius: 3px 0 0 3px; }
ul.pt-pill li:last-child { -webkit-border-top-right-radius: 3px; -webkit-border-bottom-right-radius: 3px; -moz-border-radius: 0 3px 3px 0; }
ul.pt-pill li.selected { background: #fff; position: relative; z-index: 1; text-shadow: 0 1px #fff; cursor: default;
background: url(../images/selected_bg.gif) repeat-x;
@litzinger
litzinger / getset-php.sublime-snippet
Created March 3, 2014 21:18
Creates getter and setter in PHP model
<snippet>
<content><![CDATA[
/**
* Get $1
*
* @return ${2:[type]} \$$1
*/
public function get${1/(.*)/\u$1/}()
{
return \$this->${1:$SELECTION};