Skip to content

Instantly share code, notes, and snippets.

View amjedomar's full-sized avatar
🎯
Focusing

Amjed Omar amjedomar

🎯
Focusing
View GitHub Profile
@amjedomar
amjedomar / gist:053e36d34d3ff2205c9ed9f8834590e0
Created December 4, 2024 21:43 — forked from kirilkirkov/gist:b13baec4b5142a527399693f8829547d
Difference between png-Interlaced, jpg-progressive AND png-non-Interlaced, jpg-baseline
Interlaced image loads an early degraded version of the whole image as soon as possible and then progressively renders the image to clear state.
Non-interlaced image will load up in tiles showing clear image in each tile as it progresses to load in the image.
For .jpg the interlaced = progressive and not interlaced = baseline.
@amjedomar
amjedomar / woo-no-live-badge.php
Created October 29, 2024 13:47 — forked from blogtutor/woo-no-live-badge.php
Remove WooCommerce 9.3 "Live" badge from Admin Bar. This code goes in theme's functions.php file.
<?php // Do not copy opening php tag
/**
* Remove WooCommerce site visibility "Live" badge from the admin bar.
*
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance, passed by reference.
*/
add_action( 'admin_bar_menu', 'khp_remove_woocommerce_site_visibility_badge', 999 );
function khp_remove_woocommerce_site_visibility_badge( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'woocommerce-site-visibility-badge' );
@amjedomar
amjedomar / Convert .mov or .MP4 to .gif.md
Created August 17, 2024 12:34 — forked from SheldonWangRJT/Convert .mov or .MP4 to .gif.md
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@amjedomar
amjedomar / ko.utils.signatures.js
Created August 4, 2024 23:17 — forked from hyle/ko.utils.signatures.js
KnockoutJS utils (ko.utils) signatures
// knockout 2.2.1
ko.utils.arrayFilter = function (array, predicate) { /* .. */ }
ko.utils.arrayFirst = function (array, predicate, predicateOwner) { /* .. */ }
ko.utils.arrayForEach = function (array, action) { /* .. */ }
ko.utils.arrayGetDistinctValues = function (array) { /* .. */ }
@amjedomar
amjedomar / checkout_index_index.xml
Created August 2, 2024 21:43 — forked from markshust/checkout_index_index.xml
app/code/Macademy/CheckoutMessages/view/frontend/layout/checkout_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
@amjedomar
amjedomar / mysql-docker.sh
Created July 15, 2024 11:54 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@amjedomar
amjedomar / what-forces-layout.md
Created December 25, 2023 22:12 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@amjedomar
amjedomar / decreasingSum.js
Last active May 18, 2023 20:33
Sort Algorithms implementation in JavaScript
// source: https://www.khanacademy.org/computing/computer-science/algorithms/sorting-algorithms/a/analysis-of-selection-sort
const range = (start, end) => [...new Array(end - start + 1)].map((_, idx) => start + idx);
const sum = (arr) => arr.reduce((acc, cur) => acc + cur, 0);
const decreasingSum = (num) => {
if (num < 1) throw new Error('value should be >= 1')
return num/2 * (num + 1)
}
class Cat {
static count = 0;
constructor(public name: string) {
Cat.count++;
}
getName() {
return this.name;
}