Skip to content

Instantly share code, notes, and snippets.

@mpaepper
mpaepper / android-ubuntu
Last active December 20, 2023 18:26
How to debug your Android device under Ubuntu
When programming apps for Android, you usually want to test them on real Android devices.
This little gist describes how to do so using Ubuntu 14.
First, you need to download and install the Android development IDE (http://developer.android.com/sdk/index.html) and create an Android project which you want to debug.
Next, you need to setup the debugging mode on your Android device. Starting in Android 4.2 you need to enable the developer options first: 1) Go to settings 2) Go to About Phone 3) Tap the build number 10 times (or more, not sure ;)) and you will get the notification that you enabled it.
Then go to the developer settings and enable the debug mode for your phone.
Now you think you can just plug it into your USB mode? - Nope.
@mpaepper
mpaepper / gist:6168c9617630f96a8bfc
Created June 8, 2015 03:31
What you need to know about debugging Magento cart price rules
Sometimes you have the problem that a Magento cart price rule does not work when you enter a coupon code, although you think it should.
There are certain areas where it could fail and I will illustrate the two most important ones.
First check for the file Mage_SalesRule_Model_Validator and its protected function _canProcessRule($rule, $address).
The rule fails inside that function and this can be for many reasons which I would divide into two main categories:
a) General limitations such as a usage limit (code can only be used 5 times), customer limit (can only be used once per customer)
b) If the general limitations do not apply, the rule will fail at if (!$rule->validate($address)) so at its validate() method.
To debug this, I found that it is most useful to go to the file Mage_Rule_Model_Condition_Combine and in the function validate() enter the following code:

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name