Skip to content

Instantly share code, notes, and snippets.

@sutlxwhx
sutlxwhx / extract.js
Last active August 20, 2018 18:15
Copy to the clipborad list of all h1/h2/h3 elements on the page
# Declare tag name that you want to extract
var elements = document.getElementsByTagName("h2");
# Create a temporary element where all the data will be stored
var buffer = document.createElement("buffer");
document.body.appendChild(buffer);
# Declare the string var where all the data from the page will be stored
var names = '';
# Create a foor loop and append all new elements to the string
for(var i=0; i<elements.length; i++) {
names += elements[i].innerText + '\n';;
@sutlxwhx
sutlxwhx / schema.md
Last active August 21, 2018 17:32
Rich snippet with star rating in SERP for your website / article

Introduction

According to Google Introduction to Structured Data either schema.org or JSON-LD markup should be enough for Google to pickup structuted data on your website / article. I used them both. In my experince Google was able to pickup breadcrubs within JSON-LD faster while star rating with schema.org was easily to implement.

Installation

Because most of the code is not visible to visitors and it's ok you you split your breadcrumbs and star rating into different instances on the page I encourage you to set the rating data over the h1 tag. It's better if you use div itemprop="name" and it's bad if you will create 2 isntances of h1 tag just to fit my example.

  • h1 stands for your h1 tag
  • "ratingValue" determines the final rating of your article
@sutlxwhx
sutlxwhx / README.md
Last active August 22, 2018 12:11
Use Nginx as a Reverse Proxy to another Nginx

Instroduction

This tutorial will show how you can setup Nginx as a Reverse Proxy to another Nginx server with a least amount of code.

Installation

Point your A DNS record to the first server that will accept the initial request and then redirect it to second server On that first server use the following setup fo default enabled site:

server {
	listen 80;
@sutlxwhx
sutlxwhx / Copier.php
Last active August 24, 2018 23:13
Copy specified files to the new directory
<?php
/**
* @author https://gist.github.com/sutlxwhx
*
* @version 0.2
*
* @license Apache License 2.0
*
*/
@sutlxwhx
sutlxwhx / Renamer.php
Last active August 24, 2018 23:13
Rename all files in the current folder according to your list of file names
<?php
/**
* @author https://gist.github.com/sutlxwhx
*
* @version 0.2
*
* @license Apache License 2.0
*
*/
@sutlxwhx
sutlxwhx / Checker.php
Last active August 24, 2018 23:14
Check if mysql database exists
<?php
/**
* @author https://gist.github.com/sutlxwhx
*
* @version 0.2
*
* @license Apache License 2.0
*
*/
@sutlxwhx
sutlxwhx / Empt.php
Last active August 24, 2018 23:14
Delete empty lines in the file and save it
<?php
/**
* @author https://gist.github.com/sutlxwhx
*
* @version 0.2
*
* @license Apache License 2.0
*
*/
@sutlxwhx
sutlxwhx / Sizer.php
Last active August 24, 2018 23:15
Sort files in the folder by their file size and retrieve it as an array
<?php
/**
* @author https://gist.github.com/sutlxwhx
*
* @version 0.2
*
* @license Apache License 2.0
*
*/
@sutlxwhx
sutlxwhx / README.md
Last active September 1, 2021 15:23
How to backup your LAMP / LEMP installation the right way

Introduction

This is the LAMP / LEMP environment backup guide in case you want or need to try my highload LEMP installation.

Basic usage

As a first thing we will setup a variable that will store current date and time. We will use year-month-day_hours-minutes-seconds format:

now=$(date +"%Y-%m-%d_%H-%M-%S")
@sutlxwhx
sutlxwhx / README.md
Last active October 28, 2023 07:29
Comparison of different popular VPS providers