Skip to content

Instantly share code, notes, and snippets.

View MikSDigital's full-sized avatar
🎯
Focusing

Mikhail MikSDigital

🎯
Focusing
View GitHub Profile
[[$HTML_START]]
[[$HEADER]]
[[addAsset? &code=`<style>.breadcrumbs{display:none;}</style>`]]
<link href="[[++assets_common_path]]/css/mt4-se/landing/s-e.css" rel="stylesheet" type="text/css"/>
[[addAsset?&beforeBody=`
<script>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
$(document).mouseup(function (e)
{
var container = $("YOUR CONTAINER SELECTOR");
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});
$string = <<<EOD
string with $var \n
EOD;
@MikSDigital
MikSDigital / ternary.php
Created August 23, 2016 19:40
examples of ternary operators
<?php
// #1, Larry Ullman, p.76
$q = 'SELECT UNIX_TIMESTAMP(MAX(date_added)), UNIX_TIMESTAMP(MAX(date_completed)) FROM tasks';
$r = mysqli_query($dbc,$q);
list($max_a,$max_c) = mysqli_fetch_array($r,MYSQLI_NUM);
$max = ($max_a > $max_c) ? $max_a : $max_c;
// #2, Bob Ray, p.285
<?php
/*
[[replaceTags?
* &content=`[[%uk-signup-menutitle-1? &namespace=`main_uk` &topic=`Signupform`]]`
* &tag_start=`[download]`
* &tag_end=`[/download]`
* &replacement=`www.admiralmarkets.com`]]
*/
@MikSDigital
MikSDigital / printDownload.php
Created August 30, 2016 08:09
pdf creation snippet
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$domain = 'http://' . $_SERVER['HTTP_HOST'];
$cache_path = ($_SERVER['DOCUMENT_ROOT']. '/cache/');
$url = $domain . strtok($_SERVER["REQUEST_URI"],'?'); // requested URL w/o params
$full_url = $domain . $_SERVER['REQUEST_URI']; // for example http://devamcomau.int.fxservice.com/trading-platforms/mt4-se/indicator-innovations
$cultureKey = ('_' . $modx->getOption('cultureKey'));
@MikSDigital
MikSDigital / printDownload.php
Created August 30, 2016 08:25
Final version pdf converter
<?php
$pdf_type = (isset($_GET['pdf_type']) ? (strip_tags($_GET['pdf_type'])) : false);
if(!$pdf_type) return;
$domain = 'http://' . $_SERVER['HTTP_HOST'];
$cache_path = ($_SERVER['DOCUMENT_ROOT']. '/cache/');
$url = $domain . strtok($_SERVER["REQUEST_URI"],'?');
$full_url = $domain . $_SERVER['REQUEST_URI'];
$cultureKey = ('_' . $modx->getOption('cultureKey'));
$fileName = ($modx->resource->get('alias')) . $pdf_type . $cultureKey . '.pdf';
@MikSDigital
MikSDigital / replace_tags.php
Created September 3, 2016 14:54
Snippet to replace tags in text strings
<?php
/* replaceTags Snippet
USAGE:
[[replaceTags?
&content=`[[%mt4se-amuk-minipage-1-p-1? &namespace=`main_uk` &topic=`MiniTerminal`]]`
&link2downloadPage=`[[~[[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`2394`]]]]`
&website_link=`[[~[[++site_start]]]]`
]]
@MikSDigital
MikSDigital / get_canonical.php
Created September 9, 2016 13:40
set canonical URL in MODX
<?php
$context = $scriptProperties['context'] ?: 'ukltd';
//$context = (empty($scriptProperties['context'])) ? 'ukltd' : $scriptProperties['context'];
$linkedId = $modx->runSnippet('BabelTranslation', array(
'contextKey' => $context,
'resourceId' => $modx->resource->get('id')
));
@MikSDigital
MikSDigital / push.js
Created September 16, 2016 07:43
object push to array
countryData={
name: 'check_country_id',
value: $("#" + type + "Form").find('select[name=country]').val()
};
formData.push(countryData)