Skip to content

Instantly share code, notes, and snippets.

javascript: var el = document.createElement('div'); el.setAttribute('id', 'is-ee-bookmarklet-msg'); el.setAttribute('style', 'padding:15px;margin:0;font-weight:bold;color:#fff;font-size:20px;top:0;left:0;width:100%;text-align:center;position:fixed;z-index:999999999;background-color:#090;'); if (document.cookie.match(/exp_tracker=([^&]*)/)) { el.innerHTML = 'This site uses ExpressionEngine'; } else { el.style.backgroundColor = '#900'; el.innerHTML = 'This site does not use ExpressionEngine'; } if (typeof jQuery != 'undefined') { var el = jQuery(el); el.hide(); jQuery('body').append(el); jQuery('#is-ee-bookmarklet-msg').slideDown(); setTimeout("jQuery('#is-ee-bookmarklet-msg').slideUp();", 4000); } else { document.getElementsByTagName('body')[0].appendChild(el); setTimeout("document.getElementsByTagName('body')[0].removeChild(document.getElementById('is-ee-bookmarklet-msg'));", 4000); }
@rsanchez
rsanchez / gist:702751
Created November 16, 2010 23:49
Equivalent of JS var a = b || c || d;
//JS: var a = b || c || d;
//PHP: val($a, $b, $c, $d);
function val(&$var)
{
$args = func_get_args();
array_shift($args);
foreach ($args as $arg)
{
@rsanchez
rsanchez / gist:965260
Created May 10, 2011 20:03
EE1: Sync template files from DB
<?php
//turn on templates as files in Global Template Preferences
//change templates to save as file in Template Preferences Manager
require_once PATH_CP.'cp.templates.php';
global $SESS, $LOC, $DB, $DSP;
if (is_null($DSP))
{
require_once PATH_CP.'cp.display.php';
@rsanchez
rsanchez / gist:972363
Created May 14, 2011 16:36
Add git-completion Mac
curl -k https://github.com/git/git/raw/master/contrib/completion/git-completion.bash > ~/git-completion.bash; profile=`cat ~/.profile`; echo "source ~/git-completion.bash" > ~/.profile; echo "$profile" >> ~/.profile;
#!/bin/sh
#change this to your path, this is probably it, though
eepath="/Applications/MAMP/htdocs/system/expressionengine/third_party"
#change this to your ct repository path
ctpath="/Users/myname/Documents/cartthrob_2/trunk/system/expressionengine/third_party"
eethemepath="$eepath/../../../themes/third_party"
@rsanchez
rsanchez / ext.cartthrob_example_extension.php
Created June 21, 2011 14:32
An example extension for CartThrob
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cartthrob_example_extension_ext
{
public $settings = array();
public $name = 'CartThrob Example Extension';
public $version = '1.0.0';
public $description = 'CartThrob Example Extension';
public $settings_exist = 'n';
public $docs_url = 'http://cartthrob.com/';
@rsanchez
rsanchez / GitHub Bookmarks
Created July 27, 2011 20:59
My GitHub Bookmarks
githubBookmarks.bookmarks = ["/michael/multiselect","/neteye/jquery-plugins","/harvesthq/chosen"];
@rsanchez
rsanchez / gist:1189187
Created September 2, 2011 17:11
CartThrob add to cart outside of CT
<?php
$this->EE =& get_instance();
$this->EE->load->add_package_path(PATH_THIRD.'cartthrob/');
$this->EE->load->library('cartthrob_loader');
$params = array(
'product_id' => 37, //your entry_id
'item_options' => array(), //ie, 'product_size' => 'L',
@rsanchez
rsanchez / gist:1198583
Created September 6, 2011 18:46
cp_js_end referer
<?php
class My_ext {
/* blah blah blah */
public function cp_js_end()
{
//be courteous to other users of this hook
$str = $this->EE->extensions->last_call;
@rsanchez
rsanchez / gist:1226640
Created September 19, 2011 14:36
PHP current url ridiculousness
<?php
$url = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on')?'https':'http'.'://'.$_SERVER['HTTP_HOST'].($_SERVER['SERVER_PORT'] != 80)?':'.$_SERVER['SERVER_PORT']:''.$_SERVER['REQUEST_URI'];