Skip to content

Instantly share code, notes, and snippets.

View thelebster's full-sized avatar
:octocat:
Do nothing, it is ok.

Anton Lebedev thelebster

:octocat:
Do nothing, it is ok.
View GitHub Profile
@thelebster
thelebster / check_link.py
Created February 25, 2020 05:58 — forked from hackerdem/check_link.py
A simple python script to check broken links of a wesite
@thelebster
thelebster / nginx-tuning.md
Created February 18, 2020 20:06 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@thelebster
thelebster / Python URL Validation.py
Created February 15, 2020 06:16 — forked from Integralist/Python URL Validation.py
[Python URL Validation] #python #urls #validation
import re
ip_middle_octet = u"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5]))"
ip_last_octet = u"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
regex = re.compile(
u"^"
# protocol identifier
u"(?:(?:https?|ftp)://)"
# user:pass authentication

How we incorporate next and cloudfront (2018-04-21)

Feel free to contact me at robert.balicki@gmail.com or tweet at me @statisticsftw

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

use Drupal\node\NodeInterface;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
/**
* Implements hook_preprocess_page() for page.html.twig.
*/
function THEME_preprocess_page(&$vars) {
// Add sitename and slogan to page.
$vars['site_name'] = \Drupal::config('system.site')->get('name');
server
{
listen 80;
server_name _;
location / {
resolver 8.8.8.8;
proxy_pass http://$http_host$request_uri;
}
}
@thelebster
thelebster / mysql-levenshtein.sql
Created August 29, 2019 06:38 — forked from Kovah/mysql-levenshtein.sql
Levenshtein function for MySQL
-- Levenshtein function
-- Source: https://openquery.com.au/blog/levenshtein-mysql-stored-function
-- Levenshtein reference: http://en.wikipedia.org/wiki/Levenshtein_distance
-- Arjen note: because the levenshtein value is encoded in a byte array, distance cannot exceed 255;
-- thus the maximum string length this implementation can handle is also limited to 255 characters.
DELIMITER $$
DROP FUNCTION IF EXISTS LEVENSHTEIN $$
CREATE FUNCTION LEVENSHTEIN(s1 VARCHAR(255) CHARACTER SET utf8, s2 VARCHAR(255) CHARACTER SET utf8)
uuid: b64bbcf2-cdc5-44b4-83ba-06e30147e14a
langcode: en
status: true
dependencies: { }
_core:
default_config_hash: fSI83rg8m1VYFkw66yAv6_J13NxuBWHvke6IGRnXXFs
id: magicana_d7_node_article
class: Drupal\migrate\Plugin\Migration
field_plugin_method: alterFieldWidgetMigration
cck_plugin_method: null
@thelebster
thelebster / jquery-ajax-debug-graphql-request.js
Created March 15, 2019 03:45
Allows to debug GraphQL queries with jQuery AJAX in Crome console.
let query = `
query {
someQuery {
id
title
body
}
}
`;