Skip to content

Instantly share code, notes, and snippets.

View Korveld's full-sized avatar

Kirill Titov Korveld

View GitHub Profile
@Korveld
Korveld / MySQL shutdown unexpectedly in XAMPP.
Created March 9, 2023 09:27
MySQL shutdown unexpectedly in XAMPP.
1. Rename the folder xampp/mysql/data to xampp/mysql/data_old (you can use any name)
2. Create a new folder xampp/mysql/data
3. Copy the content that resides in xampp/mysql/backup to the new xampp/mysql/data folder
4. Copy all your database folders that are in mysql/data_old to mysql/data (except mysql, performance_schema, and phpmyadmin folders from data_old)
5. Now copy the ibdata1 file from xampp/mysql/data_old and replace it inside xampp/mysql/data folder
6. You can start MySQL again from control panel now
@Korveld
Korveld / Jquery validate plugin add custom rules
Created March 10, 2023 08:20
Jquery validate plugin add custom rules
$.validator.addMethod('intlTelInput', function (value, element) {
return $(element).intlTelInput("isValidNumber");
}, commonjs_script_env.translate.phone_number);
$.validator.addMethod('emailExt', function(value, element, param) {
return value.match(/^[a-zA-Z0-9_\.%\+\-]+@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,}$/);
}, commonjs_script_env.translate.email);
@Korveld
Korveld / index.html
Created March 31, 2023 18:13 — forked from sivadass/index.html
PHP Mailer - Ajax Submission
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Ping</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<style>
@Korveld
Korveld / Html redirection
Created April 14, 2023 09:13
Html redirection
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url='URL_TO_REDIRECT'" />
<script type="text/javascript">
window.location.href = "URL_TO_REDIRECT"
</script>
</head>
<body>
<p>You will be redirected to URL_TO_REDIRECT soon!</p>
@Korveld
Korveld / Backup MySQL databases using the mysqldump command
Created June 2, 2023 12:40
Backup MySQL databases using the mysqldump command
mysqldump -u root -p sakila > C:\MySQLBackup\sakila_20200424.sql
@Korveld
Korveld / PHP detect WebP image support
Created June 7, 2023 16:08
PHP detect WebP image support
<?php if (strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false) { ?>
<section
class="section"
style="background-image:url(path-to-webp-image);"
>
<?php } else { ?>
<section
class="section"
style="background-image:url(path-to-fallback-image);"
>
@Korveld
Korveld / string.hashcode.js
Created June 19, 2023 07:49 — forked from hyamamoto/ string.hashcode.js
JavaScript Implementation of String.hashCode() .
/**
* Returns a hash code for a string.
* (Compatible to Java's String.hashCode())
*
* The hash code for a string object is computed as
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* using number arithmetic, where s[i] is the i th character
* of the given string, n is the length of the string,
* and ^ indicates exponentiation.
* (The hash value of the empty string is zero.)
@Korveld
Korveld / file-rename-lowercase.md
Created November 28, 2023 12:57 — forked from kabilashgit/file-rename-lowercase.md
rename all files to lower-case in windows

Rename all files in the directory to lowercase

open command line in that direct and run the following command

for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")

replace all subfolder files to lowercase

for /f "Tokens=*" %g in ('dir /b') do (for /f "Tokens=*" %f in ('dir %~fg /l /b /a-d') do (rename "%~fg\%f" "%f"))
@Korveld
Korveld / WP_Query_Args.php
Created January 8, 2024 10:02 — forked from fazlurr/WP_Query_Args.php
WP_Query arguments list
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@Korveld
Korveld / mime.html
Created March 14, 2024 13:35 — forked from ilmoralito/mime.html
How to check real mime type of image in javascript
<html>
<head>
<script type="text/javascript" src="/jquery.min.js"></script>
<title>Mime type checker</title>
<script>
$(function () {
var result = $('div#result');
if (window.FileReader && window.Blob) {
$('span#submit').click(function () {
var files = $('input#file').get(0).files;