Skip to content

Instantly share code, notes, and snippets.

View johnwbaxter's full-sized avatar

John Baxter johnwbaxter

View GitHub Profile
@aelvan
aelvan / macro.twig
Created September 23, 2015 15:07
Twig macro for creating a srcset string in Craft
{% macro getSrcSet(image, sizes, upscale) %}
{%- spaceless %}
{% set sizesOut = [] %}
{% set allowScaleLarger = upscale | default(false) %}
{# loop over sizes parameter and generate transforms #}
{% for size in sizes %}
{%- spaceless %}
{% set currentTransform = {} %}
@mithra62
mithra62 / apc.ini
Created April 30, 2013 17:15
mithra62 APC Configuration
extension=apc.so
[APC]
apc.enabled=1
apc.shm_segments=1
apc.shm_size=1024M
;Relative to the number of cached files (you may need to watch your stats for a day or two to find out a good number)
apc.num_files_hint=7000
<?php
// get constants defined by the application
// All constants available
$constants = get_defined_constants(TRUE);
// just constants from the app in question
$app_constants = $constants['user'];
echo '<pre>';
@erikreagan
erikreagan / acc.accessory_test.php
Created December 10, 2010 12:28
Sample accessory with ajax method for EE 2.x
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// sample code for thread http://expressionengine.com/forums/viewthread/174318/
class Accessory_test_acc
{
public $name = 'Test Accessory';
public $id = 'accessory_test_acc';
public $version = '1.0.0';
public $description = 'Test bed for accessories';
@erikreagan
erikreagan / template-loader.php
Created October 22, 2010 08:27
EE template to serve as "base" templates which see if a country-specific version is available (multi-lingual site). If not then the "default" version is loaded.
{!--
/**
* This is a template loader for our multi-lingual / multi-regional site
* It takes pieces of parameters and assembles them into template_group/template format
* Then checks the DB to see if such a template exists. If it does then it returns the TRUE stuff
* If the template does NOT exist it returns the FALSE stuff
* It can be run as a single template tag to return "y" or "n" on if it exists OR
* it can be run as a tag pair to return other data based on the result
*
* A small custom plugin was written for this functionality