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
Problem description: | |
Write a method that takes in 2 parameters: | |
A string containing either "A" or "B" indicating the recipient of a bank transfer. | |
An integer array containing the amount for each of those transfers. So for instance, if the String is BA and the array is [1,2], it means A transfers 1 to B, then B transfers 2 to A. | |
This method should return what the initial balance for each bank account A and B need to be so that they never go into negative balance. | |
In the example above, it should return [1, 1]. | |
Initial balance [1, 1]. | |
A transfers 1 to B [0, 2]. | |
B transfers 2 to A [2, 0]. |
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 iptables -L -n -v | |
sudo netstat -plutn |
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 ufw status | |
sudo ufw disable | |
sudo ufw default deny incoming | |
sudo ufw default allow outgoing | |
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
nc -u -w 2 -v 159.89.213.212 13543 |
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 . -type f -exec chmod 644 {} \; // 644 permission for files | |
find . -type d -exec chmod 755 {} \; // 755 permission for directory | |
find ./var -type d -exec chmod 777 {} \; // 777 permission for var folder | |
find ./pub/media -type d -exec chmod 777 {} \; | |
find ./pub/static -type d -exec chmod 777 {} \; | |
chmod 777 ./app/etc | |
chmod 644 ./app/etc/*.xml | |
chmod -R g+w * |
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
$store = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore(); | |
$imageUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage(); |
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
# First of all make sure that the user is added to the group (the group name here is www-data) | |
sudo usermod -a -G www-data <some_user> | |
# Then change the group of the directory | |
sudo chgrp -R www-data /var/www | |
# Finally, give group write permissions | |
sudo chmod -R g+w /var/www |
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 . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch | |
## add .DS_Store to .gitignore | |
git add .gitignore | |
git commit -m '.DS_Store banished!' |
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
LOAD DATA INFILE 'file.csv' INTO TABLE table_name | |
FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '"' | |
LINES TERMINATED BY '\r\n' | |
IGNORE 1 LINES | |
(col_name); |
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
git checkout master | |
git reset --hard e3f1e37 | |
git push --force origin master | |
# Then to prove it (it won't print any diff) | |
git diff master..origin/master |
NewerOlder