Skip to content

Instantly share code, notes, and snippets.

View peresmishnyk's full-sized avatar
🇺🇦
Доброго вечора! Ми з України!

Michkire Dmytro peresmishnyk

🇺🇦
Доброго вечора! Ми з України!
View GitHub Profile

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

@peresmishnyk
peresmishnyk / ulid_converter.sql
Created May 31, 2023 11:36 — forked from kenji4569/ulid_converter.sql
ULID (26 characters in Crockford's base32) conversion for MySQL function
# Define ULID_DECODE and ULID_ENCODE which convert a ulid string to a binary and vice versa.
delimiter //
DROP FUNCTION IF EXISTS ULID_DECODE//
CREATE FUNCTION ULID_DECODE (s CHAR(26)) RETURNS BINARY(16) DETERMINISTIC
BEGIN
DECLARE s_base32 CHAR(26);
SET s_base32 = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(s), 'J', 'I'), 'K', 'J'), 'M', 'K'), 'N', 'L'), 'P', 'M'), 'Q', 'N'), 'R', 'O'), 'S', 'P'), 'T', 'Q'), 'V', 'R'), 'W', 'S'), 'X', 'T'), 'Y', 'U'), 'Z', 'V');
RETURN UNHEX(CONCAT(LPAD(CONV(SUBSTRING(s_base32, 1, 2), 32, 16), 2, '0'), LPAD(CONV(SUBSTRING(s_base32, 3, 12), 32, 16), 15, '0'), LPAD(CONV(SUBSTRING(s_base32, 15, 12), 32, 16), 15, '0')));
END//
@peresmishnyk
peresmishnyk / nginx_with_cache.conf
Created September 22, 2022 15:57 — forked from Friz-zy/nginx_with_cache.conf
Nginx cache example config
# Based on articles:
# https://ruhighload.com/%D0%9A%D1%8D%D1%88%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5+%D1%81+nginx
# https://wiki.enchtex.info/practice/nginx/cache
# https://gist.github.com/yanmhlv/5612256
# https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html
# https://blog.runcloud.io/2017/10/28/nginx-caching-tutorial-wordpress.html
# https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps
# https://easyengine.io/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/
@peresmishnyk
peresmishnyk / SpoofHttpMethodMiddleware
Last active July 14, 2020 11:45
Spoof HTTP PUT/PATCH for Laravel & nginx
<?php
namespace App\Http\Middleware;
use Closure;
class SpoofHttpMethodMiddleware
{
/**
* Handle an incoming request.
@peresmishnyk
peresmishnyk / crontab
Last active July 20, 2020 11:21
Rsync incremental backup on crontab
# Comment
30 17 * * * rsync –av --delete /path/to/source /home/mark/rsync/daily
00 18 * * 5 rsync –av --delete /home/mark/rsync/daily /home/mark/rsync/weekly
00 6 1 * * tar -cvjf /home/mark/rsync/monthly/monthly_$(date +%Y%m%d).tar.bz2 /home/rsync/daily/
@peresmishnyk
peresmishnyk / createdbuser.sh
Created February 21, 2020 12:15
CREATE DB USER BASH
#! /bin/bash
newUser='testuser'
newDbPassword='testpwd'
newDb='testdb'
host=localhost
#host='%'
commands="CREATE DATABASE \`${newDb}\`;CREATE USER '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT USAGE ON *.* TO '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT ALL privileges ON \`${newDb}\`.*
TO '${newUser}'@'${host}';FLUSH PRIVILEGES;"
@peresmishnyk
peresmishnyk / schroedinger.html
Created August 23, 2019 10:15
Html Шредингера :)
<html>
<head>
<script src="data:text/javascript;base64,d2luZG93LnN0b3AoKQ=="></script>
</head>
<body>
<p>
Я есть, но меня как бы нет :)
</p>
</body>
</html>
@peresmishnyk
peresmishnyk / encode.js
Created August 23, 2019 10:12
script base64
var
head = document.getElementsByTagName("head")[0],
script = document.createElement("script")
;
head.insertBefore(script, head.lastChild);
@peresmishnyk
peresmishnyk / dbbackup.py
Last active August 8, 2019 09:33
Python Script for MySQL Database Backup
#!/usr/bin/python
###########################################################
#
# This python script is used for mysql database backup
# using mysqldump and tar utility.
#
# Written by : Rahul Kumar
# Website: http://tecadmin.net
# Created date: Dec 03, 2013
@peresmishnyk
peresmishnyk / gist:e53701263adaa424721af563876dd643
Created July 4, 2019 09:20
add/remove css class event jquery
// Create a closure for triggering add/remove css class event
(function(){
// Your base, I'm in it!
var originalAddClassMethod = jQuery.fn.addClass;
var originalRemoveClassMethod = jQuery.fn.removeClass;
jQuery.fn.addClass = function(){
// Execute the original method.
var result = originalAddClassMethod.apply( this, arguments );