Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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: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 / ee2.6.1-time-tests.md
Last active December 18, 2015 03:09
EE 2.6.1 Time tests

Server's timezone is in UTC or GMT w/o DST, +1 w/ DST. [server_timezone]

Organization is NYC-based, or EST, or GMT - 5 w/o DST, -4 w/ DST. [default_site_timezone]

DST is currently on.

The database structure of column field_dt_# is of type varchar(8).

Conclusion:

@notacouch
notacouch / PR swap smash
Created February 6, 2015 17:21
Swap NSLIJ news images with another for testing purposes
var whyioughta = window.prompt('Please insert image URL. Plz.', 'ache tt pee, or File, or ...');
jQuery('#feature_info + a img.img-responsive, #secondary_features img.img-responsive, body.node-type-article div.article-image figure img.img-responsive').attr('src', whyioughta);
// bookmarkletify here:
// @link http://mrcoles.com/bookmarklet/
@notacouch
notacouch / loadScript_jQuery-1.11.2.js
Created April 2, 2015 19:27
Load jQuery 1.11.2 asynchronously, e.g. for IE8 in Rendera
// @link http://blog.kevinchisholm.com/asynchronous-javascript/cross-browser-asynchronous-javascript-script-loading/
function loadScript(url,callback){
if(!url || !(typeof url === 'string')){return};
var script = document.createElement('script');
//if this is IE8 and below, handle onload differently
if(typeof document.attachEvent === "object"){
script.onreadystatechange = function(){
//once the script is loaded, run the callback
if (script.readyState === 'loaded'){