Skip to content

Instantly share code, notes, and snippets.

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

Kirill Korveld

🏠
Working from home
View GitHub Profile
@Korveld
Korveld / Ternary operator multiple conditions
Created July 24, 2024 09:29
Ternary operator multiple conditions
var foo = (
bar === 'a' ? 1 : // if
bar === 'b' ? 2 : // else if
bar === 'c' ? 3 : // else if
null // else
);
@Korveld
Korveld / MySql cheat sheet
Last active July 22, 2024 11:54
MySql cheat sheet
SELECT * FROM `wp_posts` ORDER BY `wp_posts`.`post_date` DESC
Drop column
ALTER TABLE wp_posts DROP COLUMN Created;
Add column
ALTER TABLE wp_posts ADD COLUMN post_author INT DEFAULT 1 AFTER ID;
Rename column
ALTER TABLE wp_posts CHANGE COLUMN LastEdited post_date DATETIME;
@Korveld
Korveld / "fatal: unable to create threaded lstat" error when run "git status" command
Created July 8, 2024 12:55
"fatal: unable to create threaded lstat" error when run "git status" command
If the resource limit can't be removed by the hosting provider, you could consider using git config to disable preloading of the index (threaded lstat).
git config core.preloadIndex false
If you need that setting when cloning the initial repository, then you will need to set it globally.
git config --global core.preloadIndex false
@Korveld
Korveld / Remove a folder from git tracking
Created June 3, 2024 18:55
Remove a folder from git tracking
Step 1. Add the folder path to your repo's root .gitignore file.
path_to_your_folder/
Step 2. Remove the folder from your local git tracking, but keep it on your disk.
git rm -r --cached path_to_your_folder/
Step 3. Push your changes to your git repo.
@Korveld
Korveld / Mac usb boot create commands
Created May 9, 2024 16:05
Mac usb boot create commands
sudo /Applications/Install\ macOS\ Ventura.app/Contents/Resources/createinstallmedia --volume /Volumes/123
sudo killall Finder
sudo lsof +D "/Volumes/123”
mdutil -i off -d /Volumes/123/
rm -r /Volumes/123/.Spotlight-V100/Store-V2/
@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;