PHP XDEBUG’ing in Brackets

XDEBUG enables you to walk through the execution of PHP source code and debug the code as it is executed in real-time. It is one of the most important tools that a PHP developer's toolbox and is well worth the time it takes to learn how to use it.

The following instructions will guide you to setting up Xdebug in the Backets editor. It is actually pretty straight forward once you know how.

It is assumed that you have already installed Brackets text editor and XAMPP (64-bit is faster) web server in C:\XAMPP. For this article, we will be doing this on Windows. If you have not already done so, set these up first. Initially, you will need to set-up your development environment :

  • Install PHP Debugger in Brackets
  • Enable XDEBUG in php.ini
  • Install the XDEBUG Helper browser extension

Once you have your environment installed, you will be ready to start debugging PHP code anytime you need it.

Installing PHP Debugger in Brackets

The Brackets PHP Debugger extension is available for free and is easily installed from the Brackets extension library.

1. Install the PHP Debugger extension in Brackets.

2. Click DEBUG > Open Preference Files

3. In brackets.json, add the following text (only the lines in bold):

    {
     :    :    :
    "wordWrap": false,
    "php-debugger.idekey": "xdebug",
    "php": {
        "enablePhpTooling": true,
        "executablePath": "C:\\XAMPP\\php\\php.exe",
        "memoryLimit": "4095M",
        "validateOnType": "false"

    }

Don't forget the commas after "false" on the first line.

4. Save.

5. Restart Brackets.

Enabling XDEBUG in php.ini

XDEBUG actually comes bundled with XAMPP. You need just activate it though the php.ini configuration file.

1. Start XAMPP

2. Click on the "Config" button for Apache and select php.ini.

3. Add the following lines at the bottom of the file. If you already had an [XDebug] section, update the values for each of the settings:

[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug.dll"
xdebug.default_enable = 1
xdebug.idekey="xdebug" ; (note: use the same key in your web browser extension)
xdebug.remote_autostart = 0
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "c:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_connect_back = 0
xdebug.remote_enable = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_mode=req
xdebug.remote_connect_back=0
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "c:\xampp\tmp"
xdebug.remote_cookie_expire_time = -9999
xdebug.show_local_vars = 0
xdebug.max_nesting_level = 1000

4. Save.

5. Stop Apache in XAMPP.

6. Start Apache in XAMPP.

Installing the Xdebug Helper browser extension

Install the Xdebug Helper extension in Chrome or Firefox. Note that you should go into the extension's settings to ensure that the IDEKEY is set to Other and xdebug

Note: If you change editor, you may also need to change the IDE Key in Xdebug Helper.

Debugging PHP code in Brackets

Although not a requirement, two screens is highly recommended when debugging code, one for the editor and the other for the web browser.

1. In Brackets, open the PHP file that you want to start debugging.

2. Click on the PHP Debugger icon on the right side of the editor. This will open the debugger at the bottom of the screen.

3. Set a breakpoint in your code by clicking on the empty space to the left of the line number. Note that you can only set breakpoints for lines that actually contain executable code.

4. Back in your web browser, click the Xdebug Helper icon and select Debug.

5. (re)Load the page which makes use of the code you want to start debugging.

Note that your page may only appear partially or not at all in your browser. Do not panic. This is perfectly normal since the execution of PHP has been paused.

6. Now switch back to Brackets. You will find that it has interrupted your code at the breakpoint and is waiting for you to take action.

Here you can inspect the value of PHP variables in the right-hand column of PHP Debugger or click on Step Into, Step Over, Step Out, Run or Stop execution of your code. You can also type PHP commands at the command prompt or just type the name of a variable there to see its value.

If you don't see the variables, use the scroll bar on the right edge of the PHP Debugger window to scroll down.

Forcing Links to Open in a New Tab or Window

Have you ever found yourself browsing the web on a smartphone and clicked on something that opened in a new tab? It is almost impossible to tell when this happens. In fact, many people don't even realize that browsers on SmartPhones can have the equivalent of multiple tabs or windows.

Now imagine someone using a screen magnifier. They click on a link somewhere in the middle of the screen. If the link opened in a new tab in the background, they would never notice it and just think something is broken. However, if it opened in the foreground, one might think everything is good. Except that they will not realize that they are now looking at content in a new tab. So when they click BACK to return to the previous page, it simply won't work since there is no previous page in that tab.

As you can tell, these are good reasons to avoid opening content in a new browser tab. However, if you really want to open content in a new tab, you can make it accessible and friendly by simply indicating that the link will open in a new tab. Example: Google (will open in a new tab). Do make the words part of the link so that screen readers will pick it up too as users tab through the links on a page.

Reminder: Most links can be manually opened in a new tab by the user in several ways. If they are aware of how to use tabs, why not leave it in their control? If they don't know how to use tabs, why impose it on them, lead them into confusion and leave them disorientated?

Best regards,

Michael Milette

Creating a Multilingual Moodle Site

I have built many multilingual Moodle sites over the years. Unfortunately you cannot make a course appear or not appear based on the user's current language. But you can create a multilingual Moodle site and multi-language Moodle course.

First you will need to install the Moodle language packs for each of the languages you want to support. Depending on the theme used, this should display a language selection menu in the Moodle navigation. If it doesn't display a language selection menu, contact the theme's author to have him or her fix it. When a user switches language, Moodle will display it's menus in that language. Don't forget to apply these tags to your site name (front page settings), category name and course names. Note that it does not do the translation for you.

Note that if you use a particular localization of a language such as French Canadian, you will need to install both the French language pack AND the French Canadian language pack. To avoid having them both appear in the menus, you will need to specify the list of languages you want to have appear in the menu.

Next, install and enable the Multi-Language Content (v2) filter Moodle plugin. Be sure to enable it for both Content and Headings. What this will do is give you the ability to tag text using a a plain text {mlang xx} tag so that only the current language text appears. You do not need to know any HTML for this to work.

For example: {mlang XX}content in language XX{mlang}{mlang YY}content in language YY{mlang}{mlang ZZ}content in language ZZ{mlang}

Your {mlang} tags will also need to specify the localized language code if you are using such a language pack. For example: So where French would normally be {mlang fr}Your text in French{mlang}, it would be {mlang fr-ca}Your text in French Canadian{mlang} for French Canadian. {mlang fr_ca}, with an underscore instead of a dash, works too.

As I mentioned, you can't really hide courses in Moodle. However you can create multi-language courses by also wrapping each piece of content (don't forget the course names) in an {mlang} set of tags. Not only will the user see the course in their current language, they will be able to switch language at any time as they make their way through the course.

Another option with Moodle native courses is to make use of the activity restriction option. You can display or hide activities within a course by telling Moodle to only display if the user interface is in a specific language. So you would need to create 4 activities, one in each language, and then restrict which of the 4 displays when the users is viewing the site in English for example. To make this work, you will need to install and activate the Moodle Restriction by Language availability plugin. Note the challenge you may have with this approach is in assessing course completion status since all learners will not end up completing the same activities.

If you are dealing with SCORM packages, it gets much more complex and will be a little different. You can still do it however you will need to build the language selection menu into the SCORM package as well as all of the languages. You may be able to have the default language controlled by Moodle but this may require some additional customization.

Applying these strategies, you end up with a single course that works in any of the languages it supports.

Side note: Using WordPress? You can find information on getting started with WordPress multi-language sites by taking a look at the 9 best translation plugins for WordPress websites and qTranslate-XT

Hope you find this information useful.

Best regards,

Michael Milette

Surviving Canadian Winters

The key to surviving Canadian winters is to dress appropriately warm and get involved in winter activities like skiing, winter camping, skating, snowshoeing, hiking and our many Winter festivals.

If you start off with the mindset that it is a miserable 4-6 months each year, you will never find a way to enjoy it.

We are very fortunately to have the opportunity to experience a diverse climate. Every season here has something special and beautiful to offer if you are open to it.

How do I know that she loves me?

Every relationship is different because we all have different values. What is meaningful sign of love to you can be completely different for another -- even between you and the person you love. Assuming that you are in a relationship with a woman, talk with her about your feelings, really listen to how she feels and take that into consideration. Have you told her that you love her? Did she tell you that she loves you?

If you are not even dating yet, you will never know if she loves you if you never ask her out on a date. Both of you need the opportunity to get to know each other.

Answer these questions

Honestly answer the following questions to help you start to figure out the stage of your relationship.

  • How long have you been dating?
  • How well does she know you?
  • Have you given her good reasons to trust you?
  • Are you best friends?
  • Have you met her family yet?
  • Have you met her friends yet?
  • How does she act towards you when you are around her friends and family?
  • How do you know you love the woman?
  • Do you feel that you can be totally and openly honest about your feelings with her?

Some of questions will be different for someone who has been in an established relationship for a while.

Get to know yourself

This is probably even more important than knowing whether she loves you or not.

What would it look like if you knew without a doubt that she loves you?

What would it look like for you to believe that a person really loves you? What would she need to do or say in order for you to feel loved? Different people have different values. If you don’t know the answer to this question, how can the woman you love ever fulfill the role of being the person who loves you? That would be like having a book of “love” rules with no rule on how to feel loved.

You will never know if a woman really loves you if you don't love yourself first. You will always doubt whether any other person does or even can love you – even if they really do.

What you are looking for in a person who would love you? Make a list of musts and nice-to-haves. Would you feel comfortable sharing that list with her?

When people are important to us, we do things like speak kindly of them and resent people who speak poorly of them. We want to spend time with them, protect them and take care of them. We trust them because we know they are always honest with us. They are worth the effort and we respect them ALL THE TIME. Are these things that you feel or do you just want to have sex with her? Do you feel that she feels this way towards you?

Communicate with her

If you want to know if she loves you, talk WITH HER about how you feel. Start by having a conversation with her about what you really want. You may be hoping that she will do or say something that is important and meaningful to you yet she has no clue. Is it really fair to keep hoping that she will guess it right? Or would it make more sense to share that with her, let her know how important it is to you and see if she is willing to do some of it for you – only if she is comfortable with it of course.

Stop trying to guess what she wants and feels. In many ways, would that not be like playing the lottery with your love life? Wouldn't your chances of success improve if you gave her the opportunity to tell you the winning moves? Support each other in the relationship.

Treat her with the same respect and share with her.
Don't live a double standard.

Listen to how she is feeling and what she wants. It is important to stop what you are doing and thinking of and be in the moment with her. If you are nervous about talking with her about such things, know that this is perfectly normal at first. Part of loving someone is trusting them enough to put yourself in a vulnerable position and knowing in your heart that she won't use it to hurt you. The first time can be a big leap of faith but can be well worth it.

If she doesn’t respond in kind, and you are a great guy, perhaps you need to let her get to know you better. Don’t jump to any conclusions. You can’t make someone love you. You can only be the best version of yourself and hope that you are what she is looking for.

Hope this helps. Take only what makes sense to you and forget the rest.

Best regards,

Michael Milette

WCAG 2.0 – Closed Caption, Describe Video and Transcripts

Adding (or burning) captions into raw videos will not satisfy WCAG 2.0 criteria because the text then becomes part of the image which will not be narrated by screen readers or displayed on braille device. Real Closed Caption (CC) / Describe video is actually text overlaying the video for those who are visually impaired.

Moodle does not currently offer a way to include subtitles for a video. The standard compliant and best practice approach to inserting video captions requires using the HTML5 <track> element. The various attributes of the is element allow you to specify the type of content, the language it is in and a reference to text file that contain the actual information. A good file format to use for this is Web Video Text Tracks (WebVTT). SubRip Text (SRT) format files would need to be converted to WebVTT using a tool like srt2vtt. You could even specify the .VTT file for several languages all in one shot. I believe that there is even an inline technique so that you don't need to upload a separate file but I would need to double check that.

How do you create the WebVTT file in the first place? You could code it all by hand but this would be quite tedious. An easier approach would be to use an online tool like Subtitle Horse or Subtitle Edit for Windows.

While not a problem in most LMS' and CMS' like WordPress, there is currently no way to include CC with videos in Moodle yet. The alternative is to include a transcript of the video.

Normally you should put this first on your page but that would push the video way down. People may not even realize that there is a video until they are almost finished reading the text. In most LMS' that don't use YUI, this would be a simple matter of placing a link above the video pointing to the transcript, followed by the video and finally the transcript which could even be collapsed (activated by the link of course). This would require adding an id attribute to an HTML tag. Unfortunately all tags in Moodle get an id, automatically generated by YUI. This leaves you with no way to create in-page links. You could create the link but the id in <h3 id="your_id">Transcript</h3> would be overwritten by Moodle's YUI.

How do you get around this? I created a small piece of JavaScript code that you can add to Moodle. This JavaScript returns to you the power of creating in-page links that work in a similar way to the way native HTML works except that you can link to tags with classes instead of tags with ID's. You'll find my scroll-to-class-id-using-jquery-for-yui snippet (gist) on GitHub. It includes instructions on how to use it. For a smooth effect, you can combine this with my Smooth scrolling for in-page links snippet.

This technique could also address accessibility issues with audio files.

More Information -- WCAG 2.0 Techiques

I know it sounds complicated and maybe even overwhelming but, once you decide on an approach that meets the intent of the WCAG 2.0 principle and guideline, it will become a lot easier.

Hope this helps. Let me know if you want an explanation of the difference between Closed Caption and Describe Video.

Michael Milette

Camtasia alternatives and other media tools for screencasting

Camtasia is one of the best and most complete set of tools out there for capturing a recording of your screen (called screencasting) but comes at a cost of $313.99 per person (as of this writing). While you might be able to afford it for a few licenses, if you want to give access to this tool to your whole staff, the cost can really add up.

Here are some recommendations for (mostly) free media related tools -- for those on a limited budget:

  • Greenshot -- Simple to use, comes with an editor to annotate still screenshot (no video). Kind of like a free version of Snaggit. Why is a screenshot only tool included here? Because sometimes you may want to include screenshots in your presentation.
  • ShareX -- Does almost everything that Greenshot does and also includes full web page screenshots from browsers and screencast videos in both MPEG and animated GIF format. MPEG4 is great when you want to include sound while animated GIFs are great for short demonstration clips but does not support sound but result in much smaller files.
  • ScreenToGif -- Enables you to capture screencasts, webcam, whiteboard in animated GIF format. Includes an editor which is great for fixing your mistakes or removing long pauses in the video.
  • Open Broadcaster Software (OBS) -- This open source software is professional quality and offers the most flexibility through it doesn't do animated GIFs. You can do overlays, transitions, include video from multiple sources, includes a video editor and much more. The down side is that it has a higher learning curve than the others due to its extended feature set. I've done screencasts of up to 2 hours in a single take using this software.

The rest of the tools mentioned below enhance your screencast presentations or make it possible to edit your videos.

  • PenAttention PointerFocus ($) -- Wish you could help students follow your screencast by highlighting you mouse in a yellow circle like the pros do on YouTube? You can find all kinds of complicated tutorials on YouTube but PenAttention and PointerFocus makes it a snap. PenAttention is free but I found that it is not compatible with some computers. If you decide to go with PenAttention but want to also display keystrokes like PointerFocus, you can add this feature using PxKeystrokesForScreencasts. PointerFocus is a commercial product that you can try for an unlimited amount of time however, only when active, it will periodically nag you until you to pay for it ($12.50 USD). It does come with a number of extras to make your course or presentation easier to follow.
  • ZoomIt -- This free screen zoom and annotation tool makes screencasts even better by allowing you to zoom in to parts of the screen you are working on. It even includes a break timer should you use it for presentations.
  • Audacity -- One of the most powerful audio editors is available for free.
  • Pixlr / GIMP -- The cost of the Adobe Photoshop graphics/photo editor can really add up, especially when you have a team who only needs to use it occasionally. While GIMP is probably the most feature rich alternative to Photoshop, I personally find that it does not always produce the best results. Give Pixlr a try. It is an online tool so there is nothing to install.
  • Kdenlive -- There are several great free standalone video editing applications out there these days like Shotcut and VSDC however, if you find your computer is too slow or doesn't meet the minimum system requirements, take a look at Kdenlive. I've used this on 10 year old computers with just 2 GB of memory and it worked great.

TROUBLESHOOTING TIP: If you are trying to capture a screenshot or video of Chrome and are just seeing a black screen, you can fix this by disabling Hardware Acceleration. In Chrome, go to Settings Show Advanced Settings. Scroll all the way down to System and uncheck Use hardware acceleration when available.

Have any media tools you use that you recommend? Feel free to share your experience!

Best regards,

Michael Milette

Multi-language content in Moodle

So, you are have a Moodle website that runs in multiple languages. To date, you've been doubling up all you text doing things like "This content is in English. / Ce contenu est en français." As a result, the site looks a mess no matter in what language you use Moodle. In addition, this results in an accessibility issue because users of screen readers get really confused when the alternate language comes through their speaker… and not even pronounced correctly. What can you do?

If you haven't come across it yet, take a look at the Multi-Language Content (v2) Moodle plugin available for free on Moodle.org. It allows you to create multi-language content that only displays in the currently selected language of Moodle. Be sure to follow the installation instructions as you need to enable it in order for it to have any effect. Here is how you would use it in your content:

Inline example:

{mlang en}This content is in English.{mlang}{mlang fr}Ce contenu est en français.{mlang}

Block example:

{mlang en}
This content is in English. 
You can have multiple paragraphs.
{mlang}{mlang fr}
Ce contenu est en français.
Vous pouvez avoir plusieurs paragraphes.
{mlang}

The cool thing is that you do not need to know any HTML or programming in order to use this. Just type the {mlang} tags around your content just like you would any other content.

As a result, when your user chooses to view Moodle in English, you will only see the English text. When viewing Moodle in French, you will only see the French text. You can actually have as many languages as you want by repeating the series of {mlang} sections.

If you were working with Portuguese, you would use (the order of the languages is not important):

{mlang pt}Este conteúdo está em Português.{mlang}{mlang en}This content is in English.{mlang}

But what if you actually want text to appear in multiple languages on the same page? Take a look at the Moodle FilterCodes plugin. One of the many supported tags is the {langx xx}Your text{/langx}. For example:

{langx pt}Este conteúdo está em Português.{/langx} / {langx en}This content is in English.{/langx}

As a result, the text for both languages will appear on the page however the {langx} codes will be replaced by HTML that correctly tags the text in the appropriate language so that screen readers read it correctly.

Another important use would be if you needed to mention the name of a company. For example, if I had a Spanish Moodle website but wanted to mention the name "General Motors", you would wrap it in {langx} tags so that gets pronounced correctly by a screen reader regardless of Moodle's language:

{langx en}General motors{/langx}

Note that these special tags are not available on learn.moodle.net or moodlecloud.com. You can only install this plugin on your Moodle site.  While most of Moodle supports this, support can vary depending on the theme and plugins you use. If your theme or plugin doesn't support this, contact the developer and ask them to fix this problem by making use of the Moodle "format_text()" or "format_string()" functions. You don't need to know the technical details. The developer will hopefully fix the problem and publish an updated version of their plugin or theme.

Let me know if you have any questions.

Best regards,

Michael Milette

Choosing a Moodle theme

While you may simply choose a theme based on the way it looks, smart people know that themes are more than skin deep. Here are a few things to consider when choosing a Moodle theme:

  • Make sure that the theme is compatible with the version of Moodle you want to implement. If it is not, contact the developer/vendor to find out if that was an oversight, or if they are imminently planning on releasing an update in the near future.
  • Choose a layout that you like. Changing the layout usually means changing the theme source code which makes it hard to upgrade down the road without always having to re-apply your customizations each time. For example, although Essential is a nice theme with lots of options, it is really a 3 column design (content + 2 columns of menus) which severely limits the space available for your course content.
  • Make sure that the theme is highly customizable (lots of options -- like Adaptable) -- unless the theme is perfect as is.
  • Make sure the theme has no HTML errors.
  • Keep in mind that colours can be customized through CSS. Be weary of nice looking themes like Enlightlite that have "Predefined color schemes" unless you absolutely love one of them.
  • Is RTL (right to left text direction) important? Keep it in mind.
  • Are Moodle custom menus supported? It is always surprising to me when one doesn't.
  • Make sure the theme is responsive -- works on Mobile and Desktop devices without having to zoom in.
  • Make sure the theme is as compliant with WCAG 2.0 accessibility guidelines as possible. Note that I have yet to find a free or commercial theme that meets accessibility guidelines.
  • Make sure the theme includes multilingual support -- important if you have a multilingual or non-English website.
  • Can make the theme look like your organizations main website -- branding is important and it will help students feel like Moodle is an extension of the corporate website instead of a completely different and potentially unrelated website.
  • Support -- If it is a commercial theme, is the developer responsive to your inquiries? If they don't respond to your pre-sales inquiries, don't assume it will get any better after you give them your money. For free themes, where do you go in order to get support? Don't get me wrong, there is a healthy Moodle community out there willing to help out. Some free themes. like Adaptable, do have a paid support options.
  • Is the theme currently actively being developed? If it hasn't been updated in a while, that could be a bad sign. Check with the developer though, he/she might be working on a new release.
  • Does the theme try to change how Moodle works? While a noble cause, this can also easily create compatibility issues in the future.
  • Does the theme slow down your Moodle site? Moodle is already pretty resource intensive and the last thing you need is something more slowing it down.
  • Is the theme student oriented? I've used some themes that were definitely created by developers for developers.
  • Is the theme within your budget? Keep in mind that, although it is nice to get things like Moodle, plugins and themes like Academi for free, considering the overall cost of setting up your website, the price commercial theme developers like RemUI and Lambda charge or the support fee some free theme developers charge, it is a relative minor cost… and the money you pay will go towards supporting and encouraging further development so that your theme doesn't end up deprecated. Don't let the price of a theme be a determining factor unless it absolutely needs to be.
  • Does it look professional and clean?

Personally, I have had a lot of success with Adaptable. It is super configurable which is great because it doesn't look so hot out of the box (IMHO). However, tweak the settings and it can look amazing. And if you have multiple sites -- such as for development, staging, etc -- it has the option of exporting settings and importing them into another Moodle site.

Where can you find Moodle themes?

Hope this helps. Best regards,

Michael Milette

How to be Happy

I often talk about finding fulfilment through growth and contribution. Today, we will look at how to actually find happiness.

You can't buy happiness -- this isn't actually true. Scientific studies have shown that you can actually buy happiness. The truth is actually pretty close. You can't buy lasting happiness. The happiness you get from things you buy, whether it is a car, a house, jewellery, a new computer, or anything else will only last a relatively short period of time. Then there are the studies that show people in third world countries living in poverty who are happy all the time… much more than rich North Americans. What gives?

While having money can definitely help, how long could you really be happy if you could buy absolutely anything and as much as you wanted anytime you like. Things can't make you happy in the long run.

So how can you be happy? Give this a try -- it won't even cost you a dollar:

Step 1: Start by watching this video (about 2 minutes). For a more in-depth explanation, see How to solve for happy: Engineer a Path to Joy (just over an hour).

Step 2: Practice trying to see things in a way that allows you to feel grateful for what you have and your life experiences. It isn't always easy to find that perspective, even for the best of us. If you're been unhappy for a long time, it will take practice because you've got yourself into a bad habit. Think of happiness as a muscle that you need to work on each day to make it stronger.

Can't find anything to be grateful for? Be grateful for the journey and the trends in your life.

Step 3: See things as they are now. Are they better than they were a year ago? Notice trends in your life instead of specific situations. Are you heading in a positive direction? If not, it is time to change course and try something new or different.

See things as they really are, not worse than they actually are. When travelling from one place to another, it is always important to know from where you are starting. If you want to make positive changes in your life, it works pretty much the same way. Next get a clear picture of where you want to go and how you could improve specific things in your life. Finally, make a list of what you will need to do to get there. This is seeing things as they really are.

It may seem overwhelming at first. Be patient and consistent.Things rarely change overnight. Even the smallest positive change each day will accumulate over time.

Step 4: Focus on what is good in your world and build on it. If it means being grateful for your next breath, the water that comes out of the faucet when you turn it on, or the light that is at the command of a switch, then focus on that. Once you have found something to be grateful for, don't just acknowledge it -- celebrate it! Have a gratitude party with your friends. Celebrate sunshine, rain, drinking water, friendships, a bed, food, healthy parts of your body, memories, challenges, being able to help someone and opportunities to learn and grow… just to get you started. Reward yourself for making progress. See setbacks as opportunities to learn and grow.

Unhappiness and stress occur when your view of your world is different from your internal blueprint of what you think or wish life should be. This brings me to the next final step:

Step 5: Accept the things you can't change. Keep in mind that, just because you can't change something today doesn't mean that you won't be able to tomorrow. All you really need to acknowledge is that you will not let something in your life bother you anymore for 5 minutes, today… maybe not even tomorrow. It need not be a life long commitment to abandoning your dreams or desires.

Allow yourself time for unhappiness but agree to put a maximum time limit on dis-empowering self-pity parties. Of course you always have the option of opting back into a state of happiness early.