Skip to content

Instantly share code, notes, and snippets.

View sgelob's full-sized avatar
🐻

Olegs Belousovs sgelob

🐻
View GitHub Profile
{
"exportFormatVersion": 2,
"exportTime": "2018-09-22 17:21:32",
"containerVersion": {
"path": "accounts/4181156699/containers/9983293/versions/1",
"accountId": "4181156699",
"containerId": "9983293",
"containerVersionId": "1",
"name": "Prima versione di RUM",
"container": {
(function() {
/**
* Creates array of timing entries from Resource Timing Interface
*/
function getTimings() {
var entries = [];
var resources = [];
if (window.performance.getEntriesByType !== undefined) {
resources = window.performance.getEntriesByType("resource");
@sgelob
sgelob / user-timing-api-RUM-gtm.js
Last active March 14, 2021 05:03
Real User Monitoring of Web Performance with Navigation Timing API, Google Tag Manager and Google Analytics
/**
* user-timing-api-RUM-gtm.js 1.0.1
* Olegs Belousovs @sgelob
*/
(function() {
"use strict";
// From https://github.com/addyosmani/timing.js/ –––>
var performance = window.performance || window.webkitPerformance || window.msPerformance || window.mozPerformance;
@sgelob
sgelob / measure-crp-gtm.js
Last active July 17, 2018 19:57
Measuring the Critical Rendering Path via GTM an Google Analytics
<script type="text/javascript">
// https://developers.google.com/web/fundamentals/performance/critical-rendering-path/measure-crp
(function() {
var t = window.performance.timing,
interactive = t.domInteractive - t.domLoading,
dcl = t.domContentLoadedEventStart - t.domLoading,
complete = t.domComplete - t.domLoading;
dataLayer.push({
"event": "measuringCRP",
"interactive": interactive,
@sgelob
sgelob / responsive-background-attachment-image-wordpress.txt
Last active October 9, 2015 09:01
Responsive attachment image as background in WordPress. Working example on my photo-blog: http://olegs.be/gallery/turin-italy/
<?php // Get attachment image URLs
$thumb_full = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
$thumb_large = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );
$thumb_medium = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium' );
$thumb_url_full = $thumb_full['0'];
$thumb_url_large = $thumb_large['0'];
$thumb_url_medium = $thumb_medium['0'];
?>
<style>
@sgelob
sgelob / readme.html
Last active September 4, 2015 14:08
Italian WordPress installation file modification suggestions and text corrections (September 4, 2015)
<!DOCTYPE html>
<html lang="it" dir="ltr">
<head>
<title>WordPress › ReadMe</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="wp-admin/css/install.css?ver=20100228" type="text/css" />
</head>
<body>
@sgelob
sgelob / wp-config-sample.php
Last active September 4, 2015 14:08
Italian WordPress installation file modification suggestions and text corrections (September 4, 2015)
<?php
/**
* Il file base di configurazione di WordPress.
*
* Questo file viene utilizzato, durante l’installazione, dallo script
* di creazione di wp-config.php. Non è necessario utilizzarlo solo via
* web, è anche possibile copiare questo file in «wp-config.php» e
* riempire i valori corretti.
*
* Questo file definisce le seguenti configurazioni:
class My_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"sub-menu dropdown-menu\">\n";
}
function start_el(&$output, $item, $depth, $args) {
// назначаем классы li-элементу и выводим его
$class_names = join( ' ', $item->classes );
$class_names = ' class="' .esc_attr( $class_names ). '"';
$output.= '<li id="menu-item-' . $item->ID . '"' .$class_names. '>';
@sgelob
sgelob / wp-next-prev-keyboard-navigation.js
Last active September 22, 2015 10:09
Keyboard navigation on single post between the Next / Previous posts in WordPress
/* Keyboard navigation throu Next/Prev posts
Make sure your previous and next post links have the classes prev and next
Example: <a href="#" class="next">Next Post</a>
<a href="#" class="prev">Previous Post</a>
*/
$(document).ready(function(){