Skip to content

Instantly share code, notes, and snippets.

View notacouch's full-sized avatar

Abed Islam notacouch

View GitHub Profile
@notacouch
notacouch / gist:5154994
Created March 13, 2013 18:53
Compare/contrast ExpressionEngine config bootstraps, gotta catchem all eh?
<?php
/**
* Config A: madebymayo https://github.com/madebymayo/ExpressionEngine-Environment-Config
* Config B: webunder https://bitbucket.org/webunder/ee2_config_template
* Config C: FocusLabLLC https://github.com/focuslabllc/ee-master-config
* Config D: NSM Config Bootstrap http://ee-garage.com/nsm-config-bootstrap
* Config E: https://gist.github.com/adrianmacneil/3862276
*/
define('NSM_SERVER_NAME', 'nsm_server_name');
define('NSM_BASEPATH', '/abc/');
@notacouch
notacouch / gist:3989383
Created October 31, 2012 19:50
ExpressionEngine get/strip "no_results" conditionals
/**
* @author Abed Islam
*
* Use and abuse to your liking.
*
* Needed a solution for "no_results"-like tags.
* (Where "no_results" can be customized to whatever tag you want.)
* Stephen Lewis of Experience Internet talks about it and provides a solution here:
* @link http://experienceinternet.co.uk/blog/ee-gotchas-nested-no-results-tags/
*
@notacouch
notacouch / gist:3954691
Created October 25, 2012 18:56
Count occurrences of needle (substring) in haystack (string)
<?php
// Just thought this was really cool and fast way to count occurrences of a string within a string
// @author Thai
// @link http://stackoverflow.com/a/4736219/781824
$needle = 'AGUXYZ';
$haystack = 'Agriculture ID XYZ-A';
$count = strlen($haystack) - strlen(str_replace(str_split($needle), '', $haystack));
@notacouch
notacouch / http_build_url.php
Created October 17, 2012 20:17 — forked from MattiJarvinen-BA/http_build_url.php
PHP replacement of http_build_url (PHP PECL pecl_http >= 0.21.0)
<?php
// handy script from tycoonmaster at gmail dot com
// http://fi2.php.net/manual/en/function.http-build-url.php#96335
// I didn't make this but I think it is useful so I store / share it here
if (!function_exists('http_build_url'))
{
define('HTTP_URL_REPLACE', 1); // Replace every part of the first URL when there's one of the second URL
define('HTTP_URL_JOIN_PATH', 2); // Join relative paths
define('HTTP_URL_JOIN_QUERY', 4); // Join query strings
@notacouch
notacouch / Mo Variables - get conditions.html
Last active October 11, 2015 07:27
Note on Expression Engine Add-on Mo' Variables and get:* in conditions
Testing how Mo Variables works with conditions
<code>id: {get:id}. {if "{get:id}" == ""}1{/if}{if "{get:id}" != ""}2{/if}{if get:id}3{if:else}4{/if}{if "{get:id}"}got id{/if}{if "{get:id}" == 0}0{/if}</code>
<pre>
{!--
url: /
result: id: . 4
url: /?id=
result: id: . 140
@notacouch
notacouch / sample-foxycart-datafeed.php
Created September 14, 2012 20:05
Sample FoxyCart Datafeed by sparkweb
<?php
// @author sparkweb
// @url http://pastebin.com/fsfF0rdf
//Set Globals and Get Settings
$apikey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
//-----------------------------------------------------
// TRANSACTION DATAFEED
//-----------------------------------------------------
@notacouch
notacouch / foxycart-xml-datafeed-to-mysql.php
Created September 13, 2012 20:48
FoxyCart XML Datafeed to MySQL by cowtan
<?php
// @author cowtan
// @url http://forum.foxycart.com/discussion/4578/xml-datafeed-to-mysql-via-php/p1
// @url http://pastie.org/1868428
// ======================================================================================
// CHANGE THIS DATA:
// Set the key you entered in your FoxyCart.com admin.
// ======================================================================================
$myKey = 'CHANGE THIS TEXT to your own datafeed keyphrase'; // your foxy cart datafeed key