Skip to content

Instantly share code, notes, and snippets.

/*
* class Timer
*/
class Timer {
static $start;
static $end;
static $marks = [];
static $formats = [1=>''];
@Korol
Korol / seconds-to-hours-minutes-seconds.php
Created January 30, 2024 18:25 — forked from sguerrabSV/seconds-to-hours-minutes-seconds.php
PHP: Convert seconds to hours:minutes:seconds.
<?php
$startTime = time() - 7389;
$diff = microtime(true) - $startTime;
$format = sprintf('%02d:%02d:%02d', ($diff / 3600), ($diff / 60 % 60), $diff % 60);
echo $format;
@Korol
Korol / import_export_gz.sql
Created January 18, 2024 16:11 — forked from rakeshtembhurne/import_export_gz.sql
MySQL: Import and export in gzip form
// Export database in gzip form
mysqldump -u user -p database | gzip > database.sql.gz
// Import database from gzip form
gunzip < database.sql.gz | mysql -u user -p database
@Korol
Korol / iterm2.md
Created January 7, 2024 12:14 — forked from squarism/iterm2.md
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
Cmd + / - Однострочный комментарий
Cmd + F/R - Поиск и замена
Cmd + W - Расширить выделение
Cmd + E - список останніх файлів
Cmd + P - Параметри функції
Cmd + D - Дублювання поточної строки або блока
Cmd + Y - Видалення поточної строки або блока
Cmd + Option + S - Налаштування
Cmd + Option + L - Форматування коду
Cmd + Shift + W - Зменшити виділення
@Korol
Korol / index.html
Created February 23, 2023 08:20
JS load (Почему JS не видит часть HTML разметки?)
<div class="content">
<div class="default">Див, прописанный в разметке</div>
<div class="custom">Див, добавленный скриптом</div>
</div>
<script>
window.addEventListener('load', function() {
let custom = document.querySelector('.custom');
console.log(custom);
-----------------------------------------------------------------------------------------------------
Установка brew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Экспорт пути для доступа к пакетам из любого места в консоли
echo "export PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/Cellar:~/bin:$PATH" >> ~/.zshrc
Список команд для управления службами brew
brew services list - вывести список с информацией доступных служб
brew services start <Название> - запуск службы
@Korol
Korol / 1. Building PHP-MAMP on Apple Silicon M1.md
Created December 18, 2021 20:30 — forked from lennardv2/1. Building PHP-MAMP on Apple Silicon M1.md
Native PHP development / MAMP stack on Apple silicon M1

Building the MAMP stack (php, apache & mysql) on Apple Silicon ARM (native)

In this tutorial, we'll build the the nescessary packages for ARM via homebrew. After that we'll configure apache2 for using virtual hosts. The native php is ofcourse way faster, see the results of this benchmark below.

TEST NAME SECONDS OP/SEC
Rosetta2 191.654 sec 1.96 MOp/s
Intel i7-4790K (imac 2014) 156.791 sec 2.39 MOp/s
Intel i5-8500B (mini 2018) 141.381 sec 2.65 MOp/s
ARM m1 43.745 sec 8.58 MOp/s
@Korol
Korol / delete_git_submodule.md
Created August 11, 2021 05:52 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@Korol
Korol / sketch-never-ending.md
Created January 20, 2021 08:04 — forked from Bhavdip/sketch-never-ending.md
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com