Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View alihalabyah's full-sized avatar
🎯
Focusing

Ali Halabyah alihalabyah

🎯
Focusing
View GitHub Profile
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].
sudo iptables -L -n -v
sudo netstat -plutn
sudo ufw status
sudo ufw disable
sudo ufw default deny incoming
sudo ufw default allow outgoing
nc -u -w 2 -v 159.89.213.212 13543
@alihalabyah
alihalabyah / gist:e9d5cd077efb4b62cdd40bf4cf75c8ac
Created February 19, 2017 13:35
Magento 2 Reset Directories and Files Permissions
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 *
@alihalabyah
alihalabyah / gist:8a7ac8054ad706094cd7d0e0bed25c18
Created February 19, 2017 13:33
Magento2 Get Product Image URL
$store = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore();
$imageUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();
@alihalabyah
alihalabyah / gist:284c7be1419568b350e2
Created November 6, 2015 11:28
Read & Write Access to Group
# 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
@alihalabyah
alihalabyah / gist:51d4a9372dcaf31ae474
Created July 10, 2015 11:17
Git remove .DS_Store files
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!'
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);
@alihalabyah
alihalabyah / gist:b981ae29b0c948ff26d1
Created April 8, 2015 12:07
How to reset git remote changes
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