This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create repo named <your-repo-name-here> on Github | |
2. In the chosen folder execute this in your CLI: | |
git init | |
git add . | |
git commit -m "Initial commit" | |
git remote add origin https://github.com/esedic/<your-repo-name-here>.git | |
git branch -M main | |
git push -u origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Clear mods | |
const chkBoxes = document.querySelectorAll('#tab-general .table tbody tr td:first-child input[type="checkbox"]'); | |
chkBoxes.forEach( | |
chkBox => { | |
chkBox.checked = true; | |
} | |
); | |
const clrBtn = document.querySelector('.page-header > .container-fluid > .pull-right > a[data-original-title="Clear"]'); | |
clrBtn.click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Yootheme Pro sliders with lightbox --> | |
<!-- | |
1. For the 'Overlay Slider' or 'Panel Slider' Element: | |
-Add Link to the Image which has to be shown in the Lightbox | |
-Add element Attribute: | |
uk-lightbox="toggle: .uk-slider-items a" | |
2. For the 'SlideShow' Element: | |
-Add Link to the Image which has to be shown in the Lightbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adds a meta box to the post editing screen for changing the post's publication | |
// date and time after it has initially been published. | |
// Only visible to administrators. | |
// Place in functions.php file. | |
function cdap_add_meta_box() { | |
// Check if the current user is an administrator | |
if (current_user_can('administrator')) { | |
add_meta_box( | |
'cdap_meta_box', // ID of the meta box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Find all the elements, that match any of the classes that are specified in the array | |
* and remove all the matching elements from the DOM | |
*/ | |
// Step 1: Define the array of class names | |
const classesToRemove = ['elem1', 'elem2']; | |
// Step 2: Create the selector string | |
// This will create a string like ".class1,.class2,.class3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Download wp-cli.phar using wget or curl: | |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | |
2. Check if it works: | |
php wp-cli.phar --info | |
3. To be able to type just wp, instead of php wp-cli.phar, you need to make the file executable and move it to somewhere in your PATH. For example: | |
chmod +x wp-cli.phar | |
sudo mv wp-cli.phar /usr/local/bin/wp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM mytable WHERE MONTH(created) = MONTH(CURDATE()) AND DAY(created) = DAY(CURDATE())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scenario, wher we need to determine a discount based on a customer's loyalty level | |
// 1. Traditional if-else approach: | |
function calculateDiscount(loyaltyLevel) { | |
console.time('if else time'); | |
if (loyaltyLevel === 'GOLD') { | |
applyGoldDiscount(); | |
} else if (loyaltyLevel === 'SILVER') { | |
applySilverDiscount(); | |
} else if (loyaltyLevel === 'BRONZE') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo mysql | |
// get MySQL user accounts | |
SELECT user,authentication_string,plugin,host FROM mysql.user; | |
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; | |
FLUSH PRIVILEGES; | |
// you should see the change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
To use one hook inside another hook in WordPress, you can simply add the second hook as a callback function to the first hook | |
For example, let's say you want to add a custom function to the init hook, which in turn uses the wp_enqueue_scripts | |
hook to enqueue some scripts. You can do it like this: | |
*/ | |
<?php | |
function my_init_function() { | |
// do some initialization here | |
add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts_function' ); |
NewerOlder