Skip to content

Instantly share code, notes, and snippets.

@croxton
croxton / cpanel_vps_eecms_config.md
Last active September 5, 2021 23:34
Battle-tested cPanel VPS server configuration for medium traffic ExpressionEngine websites

"Medium traffic" = able to handle around 50 concurrent users on average.

If you want to handle 100+ concurrent users with the same modest hardware see the Varnish section below.

VPS

  • 4096 MB memory
  • 125GB SSD
  • 4 CPUs
  • Cpanel
@brandonkelly
brandonkelly / templating.md
Last active March 11, 2025 21:41
Templating in EE vs. Craft
<?php
class Addon_name {
public function __construct()
{
$this->EE->load->add_package_path(PATH_THIRD . 'channel_data');
$this->EE->load->driver('channeldata', array(
'directories' => array(
PATH_THIRD . 'addon_name/models'
@GDmac
GDmac / database_DB_driver.php
Last active December 29, 2015 15:19
Codeigniter profiler, where are the queries coming from ?
<?php
// from http://php.net/manual/en/function.debug-backtrace.php#111255
// adapted for codeigniter
// database/DB_driver.php method query()
//...
// Save the query for debugging
if ($this->save_queries == TRUE)
{
$this->queries[] = $sql . "\n# ".get_caller_info();
@mklooss
mklooss / Observer.php
Created November 13, 2013 09:09
Magento form_key validation failed in 1.8 after upgrade from 1.7
<?php
class MyCompany_MyModul_Model_Observer
{
/**
*
*
*/
public function addDisableValidatFromKey(Varien_Event_Observer $observer)
{
@derekjones
derekjones / gist:6687318
Last active December 23, 2015 20:09
ExpressionEngine pagination with ellipsis
{paginate}
{pagination_links}
<ul>
{previous_page}
<li><a href="{pagination_url}" class="page-previous">&lt;</a></li>
{/previous_page}
{first_page}
<li><a href="{pagination_url}" class="page-first">1</a> &hellip;</li>
{/first_page}
@croxton
croxton / entries_archive.md
Last active April 8, 2018 01:30
Sort a list of entries by year and then by month
	{exp:stash:set_list name="entries" parse_tags="yes"}
		{exp:channel:entries channel="my_channel" orderby="date" sort="desc" dynamic="no" limit="999"}
		    {stash:title}{title}{/stash:title}
		    {stash:date_day}{entry_date format="%d"}{/stash:date_day}
		    {stash:date_month}{entry_date format="%m"}{/stash:date_month}
		    {stash:date_year}{entry_date format="%Y"}{/stash:date_year}
		    {stash:date_sort}{entry_date format="%Y-%F"}{/stash:date_sort}
		    {stash:date_machine}{entry_date}{/stash:date_machine}
		{/exp:channel:entries}

{/exp:stash:set_list}

@smalot
smalot / PdfParser.php
Last active January 6, 2025 20:04
Use this static class to extract Text from Pdf files. It supports compressed and uncompressed Pdf (version 1.1 to 1.7) : tested It supports octal encoded (eg : \050) content, but not hexadecimal (eg : <005E>). In some cases, it works better than "pdftotext" binary tool.
<?php
/**
* @file
* Class PdfParser
*
* @author : Sebastien MALOT <[email protected]>
* @date : 2013-08-08
*
* References :
@kkirsche
kkirsche / Install Composer to use MAMP's PHP.md
Last active November 30, 2024 11:56
How to install Composer globally using MAMP's PHP

##Create an alias to MAMP's PHP installation

To do this, we can simply create an alias for our bash profile. We'll be doing this is nano, though you can do it in vim or a number of other editors as well.

Within the terminal, run:

nano ~/.bash_profile

This will open nano with the contents, at the top in a blank line add the following line:

@amphibian
amphibian / gist:5414609
Created April 18, 2013 17:29
Quick example of one way to deal with Localize class methods which will be deprecated in ExpressionEngine 2.6
<?php
// Backwards-compatibility with pre-2.6 Localize class
$format_date_fn = (version_compare(APP_VER, '2.6', '>=')) ? 'format_date' : 'decode_date';
echo $this->EE->localize->{$format_date_fn}('%Y-%m-%d', $this->EE->localize->now);
// 2013-04-18