Monday, April 9, 2012

How to control your anger effectively

Never make decisions or share opinions when angry.
We are sure you all have heard this or read this many times before. But not all of us can actually put this into practise. We do mess up our friendships, relationships by saying things we shouldn’t have just because we were too angry to watch our words. If you’ve found yourself in a similar soup many times, then it is necessary for you to take steps to control this self-destructive behaviour.

1. Switch off
The moment you find yourself getting too angry and on the verge of blurting out what you know you shouldn’t, we advise you to shut your brain off. Yes, completely switch off from whatever anyone is saying and start ignoring the situation that is the reason behind this uncontrollable anger. The moment you retract into your safety cocoon, and detach yourself from the happenings, you will be able to focus on the larger picture and not impulsively say things you know you shouldn’t.

2. Breathe
Breathe from your gut. Breathe in and breathe out and totally relax your senses. Breathing is an age old, tried and tested technique that will help you to calm down. It may sound silly to you and you may wonder how one can stop being angry and start focusing on one’s breathing. Well, you can combine techniques one and two. Switch off and focus on your breathing. The purpose is to divert your attention and gain control over your anger.

3. Think and react

Once you have taken the time out and relaxed your senses, you can ponder over the situation and get to the crux of what is troubling you. This unbiased evaluation of the situation will help you look at things/issues reasonably. A cool head will help you evaluate what is wrong and what is not and will stop you from messing things up unnecessarily because of anger.

4. Talk calmly, apologise if you must
After you’ve analysed the situation you can continue the argument in a dignified, composed manner. Touch on points of relevance and cut the unnecessary finger-pointing and blame game out. Check your tone and voice levels and apologise if you have gone wrong somewhere.
This is an easy 4 step anger control process. Practise it whenever you get angry, and with time you will find the anger abating and gradually reducing in intensity.

Saturday, April 7, 2012

The 5 Best and Worst Foods for Acidity

Don’t invite pain and discomfort by eating acidity-triggering foods. Check out the 5 best and worst foods for acidity.
If you suffer from acidity, you know how terribly uncomfortable it can be. And one wrong food is all it takes to trigger off a day of heartburn and discomfort.
For those prone to acidity, we have a list of foods you should include and foods you should avoid like the plague.

5 best foods for acidity

Apples and bananas
Amongst fruits, apples and bananas are safe to be consumed and generally do not cause acidity. If you’re in the mood for juice, apple juice is a good option.

Vegetables like cabbage, beans and peas
These vegetables are healthy and do not cause acidity. If you enjoy potato, try baked potato and avoid deep-fried preparations.

Egg white, chicken and fish
Lean white meats and egg white are perfect for acidity-prone individuals.

Low fat cheese

Heavy foods are a no-no for those prone to acidity. So try and go for low-fat dairy items like low-fat cheese or milk.

Whole grains
Avoid refined carbs like white rice and maida and instead opt for whole grains like wheat and brown rice to ward off acidity.

5 worst foods for acidity

Spicy food
This is a no-brainer. Anyone prone to acidity knows what a spicy sabzi or a stray chilli can do to you. In general, it’s best to avoid overly spicy food and go in for something a little milder.

Citrus foods
Bad news for orange lovers! Citrus foods are one of the worst triggers of acidity and if you think you might be prone to it, stay away from citrus fruits, as well as juices.

Coffee
For those with a chronic acidity problem, it’s best to cut out coffee from your diet. Instead try green tea

Fried foods and fatty foods
Biscuits high in fat, or fried snacks have to be banished from the diets of all those prone to acidity. These are instant triggers and can cause days of discomfort.

Alcohol, especially wine
Although wine recommended as one of the healthier alcohols, it’s a no-no for the acidity prone. The tannins in the wine can cause acidity and is best avoided.

Wednesday, March 28, 2012

Flash CS3 - CS5 issues - No Valid HTML Templates are available to complete this operation

It sounds like the user configuration is bad.  Please try removing the user configuration folder.  Please note that after deleting the user configuration, there are user  settings, such as panel position and saved jsapi commands, will be removed or reset so you might want to save the important files you want to reserve in user configuration before removing the  user configuration folder.

1. Quit Flash.
2. Delete the following folder:
Win 7 and Vista: HD:\Users\<username>\AppData\Local\Adobe\Flash CS5

Win XP: HD:\Documents and Settings\<username>\Local Settings\Application  Data\Adobe\Flash CS5

Mac: HD:/Users/<username>/Library/Application Support/\Adobe\Flash CS5

3. Relaunch Flash and see if it fixes the problem.

Monday, March 19, 2012

A Simple jQuery Slideshow

In the interest of following jQuery’s motto of “writing less and doing more,” let’s write a simple slideshow using jQuery, JavaScript and a bit of CSS.


For starters, our main goal should be keeping the markup as clean as possible:

<div id="slideshow">
    <img src="img/img1.jpg" alt="" class="active" />
    <img src="img/img2.jpg" alt="" />
    <img src="img/img3.jpg" alt="" />
</div>
Now let’s use CSS to position the images on top of each other and bring the active image to the top level with z-index:

#slideshow {
    position:relative;
    height:350px;
}

#slideshow IMG {
    position:absolute;
    top:0;
    left:0;
    z-index:8;
}

#slideshow IMG.active {
    z-index:10;
}

#slideshow IMG.last-active {
    z-index:9;
}
Due to absolute positioning, we need to define the height of the slideshow DIV. Also, notice that we defined three different z-indexes—we will manipulate these soon using jQuery.
For the slideshow animation we are going to switch between each photo at a set rate. So let’s start by writing a function that brings in a new photo on top of the last active image:

function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    var $next = $active.next();    

    $next.addClass('active');

    $active.removeClass('active');
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});
Here we set a JavaScript interval to call slideSwitch() every 5 seconds. Then slideSwitch() applies the CSS class ‘active’ to bring the next image to the top of the stack. Since we will select the images more than once within slideSwitch(), we define the variables $active and $next for selector performance.
Next we should incorporate a fade animation. For a gallery like this, fade in and fade out are identical, but let’s not forget to think about what we fade against:

function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    var $next = $active.next();

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});
We start by applying the ‘last-active’ class we defined earlier. Since ‘.last-active’ falls after ‘.active’ in the stylesheet, the z-index of 9 takes priority, and the top image drops back a level. Next, we set the opacity of the new image to 0 so that we can fade it in using the animate() function. Finally, we attach a callback to remove the z-index classes from the previous image when animate() completes.
Although our slideshow is working well, we should make it more robust by building in some default variables. First, let’s define a default active image, in case we need to put less stress on the back-end. Also, we can use defaults to make the gallery animation loop.

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});
We first define a default image for the $active variable, which interestingly enough needs to be the last image on the stack. This is because through absolute positioning, the last image appears on top, and we need to start with it if we want to avoid any flicker.
For the loop it is pretty simple: all we have to do is point the $next variable to the first image once it has gotten to the end of the line.
If you want to improve this function, try setting the animation speed with a variable so the main slideshow function can be thrown into the core and left alone. Also, this slideshow is easily converted to support DIV’s instead of IMG’s—try programming a slideshow with more content.
Now for a challenge: the gallery flickers when the images first load, but it can be fixed without touching the JS or markup at all. Bonus points to whoever figures it out and posts a comment.



Sunday, March 18, 2012

Building an Animated Cartoon Robot with jQuery


Why?

Aside from being a fun exercise, what purpose does something like this have? None that's plainly obvious. Its about as useful as a miniature ship in a bottle. Yet it does have an underlying purpose. It could inspire someone to look beyond the perceived constraints of web designers and developers.


Overview

This project was created by layering several empty divs over each other with transparent PNGs as background images.

The backgrounds were animated at different speeds using a jQuery plug-in by Alexander Farkas. This effect simulates a faux 3-D animated background dubbed the “parallax effect” originating from old-school side scrolling video games.

The robot is comprised similarly to the background animation scene by layering several DIVs together to create the different robot pieces. The final step, was animating the robot with some jQuery.


The Markup

<div id="wrapper">

  <div id="cloud-01">
  <div id="cloud-02">
  <div id="mountains-03">
  <div id="ground">

  <div id="full-robot">
    <div id="branding"><h1>Robot Head.</h1></div>
    <div id="content"><p> Robot Chest.</p></div>
    <div id="sec-content"><p> Robot Pelvis.</p></div>
    <div id="footer"><p> Robot Legs.</p></div>
  </div>

  </div>
  </div>
  </div>
  </div>
</div>

The structure of the divs closely resembles our diagram. None of the DIVs has the width attribute specified so they will expand to fill the size of any browser window they are displayed on. NOTE: All the images that make the background scenery parallax effect are 9999px wide. Well beyond the width of any computer display or television in common use. We’ll use CSS to place the background images exactly where we want within each particular div.

The Style

The CSS for this project is just as simple as the markup.

h1, p { position: absolute; left: -9999px; }

div {position: relative;}

#wrapper { background: #bedfe4 url(../images/sun.png) no-repeat left -30px; border: 5px solid #402309;}

#cloud-01 { background: url(../images/clouds-01.png) no-repeat left -100px; }                                                         

#cloud-02 { background: url(../images/clouds-02.png) no-repeat left top; }

#mountains-03 { background: url(../images/mountain-03.png) no-repeat left bottom; }

#ground { background: url(../images/ground-05.png) no-repeat left bottom; }

#full-robot { width: 271px; }

#branding {
background: url(../images/robot-head.png) no-repeat center top;
width: 271px;
height: 253px;
z-index: 4;
}

#content {
background: url(../images/robot-torso.png) no-repeat center top;
width: 271px;
height: 164px;
z-index: 3;
margin-top: -65px;
}

#sec-content {
background: url(../images/robot-hips.png) no-repeat center top;
width: 271px;
height: 124px;
z-index: 2;
margin-top: -90px;
}

#footer {
background: url('../images/robot-legs.png') no-repeat center top;
width: 271px;
height: 244px;
z-index: 1;
margin-top: -90px;
}
Absolute positioning is used to pull any header or paragraph text 9999px to the left of the screen. Then we declare every DIV in the page position: relative. By making all the DIVs position: relative;, we now have the ability to the use the z-index property to reverse the natural stacking order of the robot DIVs.

The jQuery JavaScript

Disclaimer: The original script to animate the robot was horrid. The good folks at coding cyborg were kind enough to clean it up and re-write it.

$(document).ready(function(){
$('#cloud-01').css({backgroundPosition: '0 -80px'});
$('#cloud-02').css({backgroundPosition: '0 -30px'});
$('#mountains-03').css({backgroundPosition: '0 50px'});
$('#trees-04').css({backgroundPosition: '0 50px'});
$('#ground').css({backgroundPosition: 'left bottom'});
$('#branding').css({backgroundPosition: 'center 0'});
$('#content').css({backgroundPosition: 'center 0'});
$('#sec-content').css({backgroundPosition: 'center 0'});
$('#footer').css({backgroundPosition: 'center 0'});
$('#wrapper').css({overflow: "hidden"});

$('#klicker').click(function(){
$('#cloud-01').animate({backgroundPosition: '(-500px -80px)'}, 20000);
$('#cloud-02').animate({backgroundPosition: '(-625px -30px)'}, 20000);
$('#mountains-03').animate({backgroundPosition: '(-2500px 50px)'}, 20000);
$('#ground').animate({backgroundPosition: '(-5000px bottom)'}, 20000);

startHim();

$("#full-robot").animate({left:"50%",marginLeft:"-150px"}, 2000);
setTimeout("leaveScreen()",15000);
});

});

var num = 1;

function startHim(){
num++;
$("#sec-content").animate({top:"-=5px"},150).animate({top:"+=5px"},150);
$("#content,#branding").animate({top:"-="+num+"px"},150).animate({top:"+="+num+"px"},150);
if(num<4){
setTimeout("startHim()",300);
} else {
setTimeout("bounceHim()",300);
}
}

function bounceHim(){
$("#sec-content,#branding").animate({top:"-=4px"},150).animate({top:"+=4px"},150);
$("#content").animate({top:"-=8px"},150).animate({top:"+=8px"},150);
setTimeout("bounceHim()",300);
}

function leaveScreen(){
$("#full-robot").animate({left:"100%",marginLeft:"0px"}, 2000);
}
We begin by re-affirming the original background position of all the images.

Upon clicking the ‘#klicker’ div, a function tells jQuery to animate the backgrounds from their current position all the way to the coordinates specified for each div. By separating all the different image layers into different DIVs we can animate the background elements at different speeds. Moving the elements at different speeds gives an illusion of a 3rd dimension. We move the elements in the background at a much slower rate than the elements in the foreground. Notice on this animation that the speed of the clouds in the background is slower than the speed of the mountains. And the mountains are slower than the ground which is the fastest of all. Finally after firing off all these commands to get the background moving the ‘#klicker’ function calls on the ‘startHim()’ function.

The ‘startHim()’ function, you guessed it right, starts our robot. It begins his little bounce and gets him moving to the center of the #wrapper div. The ‘startHim()’ function calls on the ‘bounceHim()’ function. And then it keeps looping.

We need to make the robot seem like it was bouncing on a rough desert rode. To achieve that bouncy irregular effect we’ll use the ‘bounceHim()’ function. It targets the separate robot DIVs and ‘bounces’ them 5px up and then 5px down. That wont be enough though, all the different pieces of the robot bouncing at the same rate looks too stiff. We need to make it look a bit more random and interesting. So we’ll take the div that makes the chest portion of the robot and move it at a different rate than the head and pelvis pieces. We’ll ‘bounce’ the chest part at 8px up and 8px down. This gives the robot a nice off-beat bouncy effect.

The ‘leaveScreen()’ function is the last function called. After 15 seconds (15000) it moves the robot 100% percent to the left of the screen which consequently moves the robot off to the right of the screen.