Skip to content

Instantly share code, notes, and snippets.

View kuvinci's full-sized avatar

Olexandr (Alex) Kuzub kuvinci

View GitHub Profile
@kuvinci
kuvinci / clean_code.md
Last active February 20, 2024 13:34 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@kuvinci
kuvinci / WordPress posts by meta date
Last active October 23, 2020 15:57
Get WordPress posts between two meta dates based on unix
// This code will return all of the posts between first and last day of the month of $unix date
// So if $unix will be the 20 of October 2020, then the code will return all of the posts BETWEEN 10/01/2020 AND 10/31/2020
// date('Ym01', $unix) is a first day of the month of the $unix date
// date('Ymt', $unix) is a last day of the month of the $unix date
$unix = 1606089600; // Any date in unix format
$field = 'cmeb_ts_start';
$args = [
'post_type' => 'cmeb_booking',
@kuvinci
kuvinci / Loading bar
Created November 5, 2019 13:40
jQuery site loading bar
/* Loaded Bar*/
var now = new Date().getTime();
var page_load_time = now - performance.timing.navigationStart;
// console.log("User-perceived page loading time: " + page_load_time);
var width = 100, // width of a progress bar in percentage
perfData = window.performance.timing, // The PerformanceTiming interface
EstimatedTime = -(perfData.loadEventEnd - perfData.navigationStart), // Calculated Estimated Time of Page Load which returns negative value.
time = parseInt((EstimatedTime/1000)%60)*100; //Converting EstimatedTime from miliseconds to seconds.
@kuvinci
kuvinci / IE Edge
Created October 17, 2019 09:44
IE, Edge media queries
// IE
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
}
// Edge
@supports (-ms-ime-align:auto) {
}