There are several ways via command line to check memory: $ free -m $ free -t -m $ vmstat $ top
Command Line - check memory usage
- By Heather Mello
- Apr 5, 2016
There are several ways via command line to check memory: $ free -m $ free -t -m $ vmstat $ top
To add xdebug to mac using MAMP PRO, you have to do change permissions to a folder for it to copy the file: $ sudo chmod 777 /usr/lib/php/extensions/no-debug-non-zts-20090626/ Then you can do the command line install: $ pecl install xdebug You need to edit the php.ini file and you HAVE to uncomment:
[xdebug] zend_extension="/Applications/MAMP/bin/php/php5.2.17/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
Now you need to add these below:
xdebug.remote_enable = On xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_handler=dbgp xdebug.profiler_enable = off xdebug.profiler_enable_trigger = off xdebug.profiler_output_name = cachegrind.out.%t.%p xdebug.profiler_output_dir = "/Library/Application\ Support/appsolute/MAMP\ PRO/tmp/" xdebug.collect_vars = On
Magento has a built in feature to write to a log file. In your code, you can use Mage::log(''). In the quotes, you can put in anything you want, in my example, i am adding some text and then the dynamic customer email address. Mage::log('Email sent to ' . $customer_email); This should end up in the /var/log/system.log Viewing that file, via command line, you can use: $ tail /var/log/system.log and that will show you the last 10 results. Make sure you remove this at some point or that log file will continue to grow and grow
With this command, you can clear, clean out a log file $ > logfilename.log So whats happening here is the > tells it to remove ( i think ) and the logfilename.log is the file you want to clear out.
This example is used to send out a reminder email to customers 21 days after a purchase, if they have not reviewed their products. This also is using email templates, which makes it a bit more complicated, otherwise you can just use the good ole php mail function instead. I am using a site called Bloom so all my notes will reflect that file structure.
This is just a list of commands I know I wont remember, so I am putting them here for reference
grep "status=sent" /var/log/maillog | grep "Aug 5" | awk '{print }' | awk -F "=" '{print }' | awk -F "<" '{print }' | awk -F ">" '{print }' | sort | uniq -c | sort -n
grep "status=sent" /var/log/maillog | grep "Aug 5" | grep "to=<*>" grep "status=sent" /var/log/maillog | grep "Aug 5" | wc -l
grep "ralbin@abcompany.com" /var/log/maillog | wc -l less /var/log/maillog grep "abc@hotmail.com" /var/log/maillog
You can easily get controller name, action name, router name and module name in template file or in any class file. IN TEMPLATE FILES $this->getRequest()can be used in template (phtml) files. Here is the code:
/** * get Controller name */ $this ->getRequest()->getControllerName(); /** Extract email address from a mail log file
Here is an example on how I extracted email address from a mail log file: $subject = "1 Aug 5 13:26:20 269701-web1 postfix/smtp[20033]: E730B10582C3: to=, relay=gmail-smtp-in.l.google.com[74.125.91.27]:25, delay=1.4, delays=0.02/0.01/0.13/1.3, dsn=2.0.0, status=sent (250 2.0.0 OK 1312568780 fp10si6690298qab.63) 1 Aug 5 13:30:49 269701-web1 postfix/smtp[20753]: F06EF10582C3: to= , relay=mx4.hotmail.com[65.55.92.136]:25, delay=0.28, delays=0.02/0/0.1/0.15, dsn=2.0.0, status=sent (250 <20110805183048.F06EF10582C3@269701-web1.www.bloom.com> Queued mail for delivery) 1 Aug 5 13:34:13 269701-web1 postfix/smtp[20822]: 5121410582C3: to=, relay=mx1.labcorp.iphmx.com[68.232.129.161]:25, delay=0.91, delays=0.01/0/0.42/0.47, dsn=2.0.0, status=sent (250 ok: Message 21101182 accepted) 1 Aug 5 13:34:14 269701-web1 postfix/smtp[20822]: 75C8610582C3: to=, relay=mx2.labcorp.iphmx.com[68.232.129.150]:25, delay=1, delays=0.02/0/0.49/0.54, dsn=2.0.0, status=sent (250 ok: Message 22975937 accepted) 1 Aug 5 13:44:53 269701-web1 postfix/smtp[21625]: 84B5B10582C3: to=, relay=gmail-smtp-in.l.google.com[74.125.91.27]:25, delay=1.7, delays=0.01/0/0.27/1.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1312569893 ef1si6693357qab.35) "; function extract_emails_from($string){ preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches); return $matches[0]; } Command Line - Delete all contents in a folder
Make sure you cd into the folder you want to delete all the contents $rm -rf * ( hit enter ) That should remove any contents in that folder you are currently in Sorting PHP Objects
// sort an object by key function sort_object_by_key( $obj, $order='' ) { $tmp = array(); // deconstruct the object into an array foreach( $obj as $key => $val ) { $tmp[$key] = ''; } // sort the array if($order == 'DESC') { krsort( $tmp ); } else { ksort( $tmp ); } |