Skip to content

Instantly share code, notes, and snippets.

@dennisfrank
dennisfrank / get_remote_db.sh
Created May 23, 2014 16:49
Shell script to import a remote database into local environment
#!/bin/sh
# Import a remote database into a local database
# ----------------------------------------------
#
# Based on http://danherd.net/quick-script-synchronise-from-a-remote-expressionengine-database/
#
# Don’t forget chmod +x to make the script executable.
#
# Change the extension to .command to run the script directly from OS X Finder.
@paulirish
paulirish / gist:616412
Created October 8, 2010 05:38
"iframe" sitedown fallback via <object>
<!-- so it turns out that the object tag can act like an iframe
but the cool thing is you can nest object tags inside eachother for a fallback path.
what this means is you can "objectframe" a site.. and if it fails.. (site down, offline, whatever).. it'll use the next one.
so you can objectframe the live site and fallback to a screenshot.
or something.
demo at : http://jsfiddle.net/paul/CY2FQ/1/
-->
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@low
low / gist:1391783
Created November 24, 2011 16:49
Simple EE conditionals turning advanced -- an example
// This will execute the exp:tag if first segment is empty
{if segment_1 != ''}
{exp:class:method}
{if var == "foo"}
Lorem
{if:else}
Ipsum
{/if}
{/exp:class:method}
@rsanchez
rsanchez / gist:3207641
Created July 30, 2012 15:07
add new form validation rules in safecracker_submit_entry_start
<?php
public function safecracker_submit_entry_start()
{
$my_custom_rules = array(
'my_field_1' => 'max_length[5]',
'my_field_2' => 'required|max_length[10]',
);
foreach ($my_custom_rules as $field_name => $field_rules)
@ckimrie
ckimrie / gist:3312619
Created August 10, 2012 08:32
Example extension that allows you to modify the final ExpressionEngine CP output
<?php
/**
* Modifying the final CP Output
*
* This extension demonstrates how you can access and modify the final ExpressionEngine
* CP output. It is not a hack, but it is a new technique that to my knowledge has not
* been used before in an EE addon.
*
* This has not been road tested and its side effects are unknown, so use this at your own risk.
@iainurquhart
iainurquhart / gist:3792249
Created September 27, 2012 05:02
#eecms API privelages
// this used to work:
function login_temporary_user()
{
if( $this->EE->session->userdata['member_id'] == 0)
{
$this->EE->session->create_new_session(1, TRUE);
$this->EE->session->userdata['group_id'] = 1;
}
}
@Meroje
Meroje / 1-Entity-Repository-Controller-Pattern.md
Created November 18, 2012 20:53
Entity Repository in Laravel4

Some Key points

[21:35:16] 1. Controllers call out to a repository to answer questions (like give me comments for a post, or are there any active users)
[21:35:27] so the repositories contain those business rules
[21:35:37] the entities (orm models) contain the application agnostic business rules
[21:35:42] like what makes a valid person
[21:36:09] 2. The repository interacts with the ORM to get the entities
[21:36:42] 3. The controller is merely responsible for processing the request, calling out to the appropriate repositories, and constructing the response
[21:36:52] All of the interactions are injected of course

@rossriley
rossriley / bootstrap.php
Created September 9, 2015 18:25
Add a contenttype / id prefix to an image upload path
<?php
// Appears in your bootstrap file, before the call to $app->run()
$app['upload'] = $app->extend('upload', function ($handler, $app) {
if ($app['request']->get('contenttype') == 'pages') {
if ($app['request']->get('contenttypeslug') && $app['request']->get('id')) {
$handler->setPrefix("/".$app['request']->get('contenttypeslug')."/".$app['request']->get('id'));
}
}
return $handler;
@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