Skip to content

Instantly share code, notes, and snippets.

View GideonBabu's full-sized avatar
💭
Looking for a challenging opportunity

Gideon Babu GideonBabu

💭
Looking for a challenging opportunity
View GitHub Profile
@GideonBabu
GideonBabu / Gideon\Returns\Setup\UpgradeData.php
Last active July 5, 2018 12:37
Magento 2 remove attribute options/values
<?php
namespace Gideon\Returns\Setup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;
use \Magento\Framework\App\ObjectManager;
@GideonBabu
GideonBabu / Gideon\Returns\Setup\UpgradeData.php
Created July 5, 2018 13:23
Magento 2: Update product attribute programmatically
//$eavSetup->updateAttribute(Product::ENTITY, $attributeCode, $attributeField, $value);
$eavSetup->updateAttribute('catalog_product', 'price', 'position', 100);
@GideonBabu
GideonBabu / writemagento2log.php
Created July 6, 2018 10:20
Magento 2 write logs into custom file
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info('Your text message');
@GideonBabu
GideonBabu / magento2_commands_shortcut.txt
Created August 7, 2018 07:40
Magento 2 Commands Shortcuts
php bin/magento s:up - Setup Upgrade
php bin/magento s:up --keep-generated
php bin/magento c:c - Cache Flush
php bin/magento c:f - Cache Flush
php bin/magento c:d - Disable Cache
php bin/magento c:e - Enable Cache
php bin/magento i:rei - Reindexing
php bin/magento i:i - View the list of indexers
php bin/magento i:st - Indexer status
php bin/magento i:res - Indexer Resets
@GideonBabu
GideonBabu / wp.txt
Created August 24, 2018 10:35
wordpress download from ssh
ssh username@domain.com -p 22
cd public_html/blogdemo/
wget http://wordpress.org/latest.tar.gz
tar xfz latest.tar.gz
mv wordpress/* ./
rmdir ./wordpress/
rm -f latest.tar.gz
@GideonBabu
GideonBabu / prevent-cut-copy-text-pwd-field.html
Created September 7, 2018 10:15
To prevent cut copy paste in text field
onselectstart="return false" onpaste="return false;" onCopy="return false" onCut="return false" onDrag="return false" onDrop="return false" autocomplete=off
@GideonBabu
GideonBabu / android-push.php
Created September 28, 2018 07:40
PHP Script to send push notification to android
<?php
define( 'API_ACCESS_KEY', 'AIzaSyA7TJAvFZrD_asZM92xoWM5u5MD-uMyYH0' );
$registrationIds = array(
"cQ8E8TvwQxg:APA91bHGxk5NBPze0_zOTQLif9s5VpOYzCyEvPmFlP3PD5FI6_5LyIVNkTKlfpSS9wy4SpO5iIX7Jdvp3nNLMYvCk6IbNRE_ykplP-Es8ebuJPF_tHhhzVS6TjWS5gDlC0Fp8JIkckNy",
"d5ttcEFtdg8:APA91bGu7QvkTkGKi4l6GviGCYgSQsv0bRLmgxlbJCDmM6iBmcOT5XAtwyQ1vprQCeTIkAvXwxb_IlitoQF335ynDyrvZXRTaN8HgDe8WFf__RI06ahec1yx0EbwkuzUI5h_s5WWP_tl"
);
$msg = array
(
'body' => 'The Chennai Silks',
'title'=> 'Welcome to TCS!',
@GideonBabu
GideonBabu / db-insert.txt
Created September 29, 2018 20:02
Python MySQLDB insert
#!/usr/bin/python
import MySQLdb
import datetime
# Open database connection
db = MySQLdb.connect("localhost","root","","know_your_beat" )
# prepare a cursor object using cursor() method
cursor = db.cursor()
@GideonBabu
GideonBabu / magento2_reset_password.txt
Created October 23, 2018 13:47
Magento 2 Reset Customer Password SQL query
UPDATE `customer_entity`
SET `password_hash` = CONCAT(SHA2('xxxxxxxxYOURPASSWORD', 256), ':xxxxxxxx:1') // change YOURPASSWORD to your password to reset
WHERE `entity_id` = 19975 and `email`="gideon.b@domain.com";
@GideonBabu
GideonBabu / example-app
Created November 22, 2018 13:33
Setup Logrotate on the server
/var/www/html/var/log/*.log {
daily
missingok
rotate 14
compress
notifempty
create 0777 www-data www-data
}
setup cron job