Skip to content

Instantly share code, notes, and snippets.

View Korveld's full-sized avatar
🏠
Working from home

Kirill Korveld

🏠
Working from home
  • Ukraine
View GitHub Profile
@Korveld
Korveld / Yarn: unable to verify the first certificate
Created April 19, 2024 14:57
Yarn: unable to verify the first certificate
navigate to C:\Users\\ and open .yarnrc and manually update it as follows:
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
strict-ssl false
@Korveld
Korveld / countdown.tsx
Created April 18, 2024 17:35
Countdown component React.js
import React, { useEffect, useState } from 'react'
import classes from './index.module.scss'
const Countdown = () => {
const [time, setTime] = useState({
days: 0,
hours: 0,
minutes: 0,
seconds: 0,
})
@Korveld
Korveld / dateRangeSort.js
Created April 15, 2024 14:42
Sort and filter an array of objects by date range
// Define the array of objects
const data = [
{ id: 1, date: '2023-05-15' },
{ id: 2, date: '2023-05-10' },
{ id: 3, date: '2023-05-20' },
// Add more objects as needed
];
// Function to sort and filter the array by date range
function sortAndFilterByDateRange(array, startDate, endDate) {
@Korveld
Korveld / Redux Saga callback function
Last active April 2, 2024 13:11
Redux Saga callback function
Reducer file (reducer.ts)
postFiatDepositRequest: (state, { payload }: PayloadAction<IPostFiatDepositWorker>) => {
state.fiatTransactionsLoading = true;
},
Redux Saga file (saga.ts)
function* postFiatDepositWorker({ payload }: PayloadAction<IPostFiatDepositWorker>) {
const { apiParams, onFinally } = payload;
let hasError = false;
try {
@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;
@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 / 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 / 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 / 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 / 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