Skip to content

Instantly share code, notes, and snippets.

@ceckoslab
ceckoslab / js-plotly-grafana-time-to-first-byte.js
Created December 26, 2022 21:07
JavaScript - Plotly - Grafana - Time To First Byte
var xValue = [];
var yValue = [];
var dataFound = true;
try {
var xValue = data.series[0].fields[0].values.buffer;
var yValue = data.series[0].fields[1].values.buffer;
}
catch (e) {
@ceckoslab
ceckoslab / layout-plotly-grafana-time-to-first-byte.json
Created December 26, 2022 21:04
Layout - Plotly - Grafana - Time To First Byte
{
"barmode": "stack",
"legend": {
"bgcolor": "#fff",
"orientation": "h"
},
"margin": {
"b": 30,
"l": 45,
"pad": 4,
@ceckoslab
ceckoslab / basic-rum-beacon-transfer-cloudflare-edge-worker.js
Last active December 14, 2021 21:18
A concept of Cloud Flare edge worker that is used for transferring beacons to beacon catcher server.
var beaconCatcherAddress = "https://rum.revampix.com/beacon/catcher.php"
addEventListener('fetch', event => {
event.respondWith(handle(event, event.request))
})
async function asyncFetch(request) {
let response = fetch(request)
.then(
function() {},
@ceckoslab
ceckoslab / tinydump
Last active July 13, 2021 06:44
Simple PHP script, that creates a dump of Magento DB with smaller footprint ... the script just excludes the data some of the log tables, but keep the the schema of these tables.
<?php
define('DS', DIRECTORY_SEPARATOR);
function _getExtractSchemaStatement($sqlFileName, $db)
{
$dumpSchema = 'mysqldump' . ' ';
$dumpSchema .= '--no-data' . ' ';
$dumpSchema .= '-u ' . $db['user'] . ' ';
$dumpSchema .= '-p' . $db['pass'] . ' ';
$dumpSchema .= '-h ' . $db['host'] . ' ';
SELECT table,
formatReadableSize(sum(bytes)) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active
GROUP BY table
@ceckoslab
ceckoslab / psi-automated-monitoring.js
Created May 21, 2019 21:46
Automated Page Speed Insights monitoring Google App Script snippet
var scriptProperties = PropertiesService.getScriptProperties();
var pageSpeedApiKey = '';
var pageSpeedMonitorUrls = [
'https://www.example-url-here.de'
];
function createHeadingIfNoteExist() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName('Sheet1');
@ceckoslab
ceckoslab / sync-catalog-cms-salesrules.php
Created December 24, 2017 14:11
Script that syncs Magento catalog, cms blocks and pages, sales rules
<?php
$mysqlCommandPath = 'mysql';
$mysqldumptCommandPath = 'mysqldump';
$remoteDbUnsername = '';
$remoteDbPassword = '';
$remotePort = '';
$remotHost = '';
$remoteDb = '';
@ceckoslab
ceckoslab / ttfp-and-network-type-and-first-network-hop-to-GA.js
Created May 14, 2017 18:19
This snippet sends Time to First Paint, Connection type and Speed to first network hop if they are supported by browser JS API. The script sends the data to GA custom dimension that is set with Session scope. It also tries to guess if the customer visits the website for first time by setting a cookie for 8 hours. In specific case the cookie life…
(function() {
function createCheckCacheCookie() {
var expireHours = 8;
var date = new Date();
date.setTime(date.getTime() + (expireHours*60*60*1000));
document.cookie = "assumedColdCache=true" + "; expires=" + date.toUTCString() + "; path=/";
}
function cacheCookieExists()
{
@ceckoslab
ceckoslab / dump-subset-of-magento-orders-and-customer-data.php
Created January 9, 2017 22:24
Proof of concept of script that does mysql dump of subset of Magento orders + related sales tables and customer's data of customer that did the orders. The script also attempts to import the data in local database. Currently the script gets last 1000 orders and customers data of customers that created the orders. Data anonymization is not implem…
<?php
$mysqlCommandPath = 'to be filled';
$mysqldumptCommandPath = 'to be filled';
$remoteDbUnsername = 'to be filled';
$remoteDbPassword = 'to be filled';
$remotePort = 'to be filled';
$remotHost = 'to be filled';
$remoteDb = 'to be filled';
@ceckoslab
ceckoslab / example sql query
Created July 28, 2014 15:25
Check if order items are owned by the current customer
SELECT `oi`.`item_id`, `o`.`customer_id` FROM `sales_flat_order_item` AS `oi`
RIGHT JOIN `sales_flat_order` AS `o` ON oi.order_id = o.entity_id and o.customer_id != 8 WHERE (oi.item_id IN(2, 3))