2013-05-14

Set Up Triggers That Program Yourself to Eat More Mindfully


Mindful eating, or paying more attention when you eat, prevents you from overeating and makes meals more enjoyable. To make this a lasting habit, food writer Darya Rose recommends creating triggers that will remind you to pay attention.



For example, starting to stab a bite of food with your fork is a defined action that occurs several times throughout your meal. For me, this action is now a trigger that forces me to ask myself if there’s already food in my mouth. If there is, I am reminded to set my fork down again and focus on chewing instead. It’s amazing how well this works. In this situation, the reward I receive for following through on the habit I’ve scripted (putting down my fork) is getting to appreciate and enjoy the bite of food already in my mouth. This is actually incredibly satisfying.



She also recommends other little tricks you can use to "program" yourself into eating more mindfully. For example, you can use setting the table as a reminder to drink half a glass of water or even set a recurring alarm to remind you to count your chews.


Mindfulness in general takes work to develop, but this practice can have a profound effect on your health and life as a whole.


Mind Over Fatter | Medium


Photo by Ollie Crafoord .






via Lifehacker http://lifehacker.com/set-up-triggers-that-program-yourself-to-eat-more-mindf-505664889

2013-05-06

CodeSOD: The Apex of T-SQL

Thomas has some problems around the office. Specifically, the code he supports has all sorts of different ways to generate HTML. Rarely, it’s WebForms code living in as ASPX. Far more often, it’s hard-coded into the CodeBehind. Sometimes, it’s sitting in a resource file.


And then sometimes, it sits in a stored procedure like this:



ALTER Procedure [dbo].[proc_GetCurrentOrderStatus] @OrderId as Int,@MyVar varchar(2000),@LangId int,
@Groupname varchar(10)
As
Declare @temp0 Table (
historyid int IDENTITY (1, 1) NOT NULL,
historytext nvarchar(1000) )


Declare @temp1 Table (
errid int IDENTITY (1, 1) NOT NULL,
errtext nvarchar(4000) )

Declare err_split Cursor for Select * from dbo.split(@MyVar,',')
open err_split
declare @langText as varchar(2000)
Fetch Next From err_split into @langText
While @@fetch_status=0
Begin
insert into @temp1 values(@langText)
Fetch Next From err_split into @langText
End
close err_split
deallocate err_split

For those following along at home, this first block loads a series of language names from the clearly named @MyVar variable. With that cursor out of the way, we need to open a fresh one. It’s called History-cursor , and it’s populated from a basic SELECT statement. It’s after fetching the first record that things get interesting.



Fetch Next From History_cursor Into /* Snip */ @Lots, @Of, @Variables, @Here
set @tablestr = '<table border = "0" class="texbox" cellspacing= "0" cellpadding = "5">'
insert into @temp0 values(@tablestr)

Yes, that is hard-coded HTML dumped into a string variable and then dumped into a table variable. You’ll see a lot of that.



set @tablestr=''
While @@FETCH_STATUS=0
Begin
If @Groupname='Cust'
Begin
If @Status_Code = 'Cn'
Begin
set @tablestr = @tablestr + '<tr class = "textbox" >'
set @tablestr = @tablestr + '<td nowrap ="nowrap" width = "250px" >Statut actuel de votre commande: </td>'
set @tablestr = @tablestr + '<td nowrap ="nowrap" ><img src = ''' + @Status_Color
+ ''' width = "15px" height="15px" alt="album" />&nbsp; ' +
(select errtext from @temp1 where errid=21) + ' </td>'
set @tablestr = @tablestr + '</tr>'
Break
End

At this point, you might say, "Oh, I see how this works, this If repeats itself, almost identically, and the only variation is the errid used in the sub-query.


But no. Depending on the condition, you might see something like this:



If @Status_Code= 'Cn'
Begin
set @tablestr = @tablestr + '<tr class = "texbox" >'
set @tablestr = @tablestr + '<td nowrap ="nowrap" width = "180px" >Statut actuel de votre commande: </td>'
set @tablestr = @tablestr + '<td nowrap ="nowrap" ><img src = ''' + @Status_Color
+ ''' width = "15px" height="15px" alt="album" />&nbsp; ' + @status_name + ' ' + @Name + ' </td>'
set @tablestr = @tablestr + '</tr>'
End

Or perhaps, this:



If @VoucherID <> 0 And @Status_Code = 'N'
Begin
set @tablestr = @tablestr + '<tr class = "textbox">'
set @tablestr = @tablestr + '<td nowrap ="nowrap" width = "180px" >Statut actuel de votre commande: </td>'
set @tablestr = @tablestr + '<td nowrap ="nowrap" ><img src = ''' + @Status_Color
+ '''width = "15px" height="15px" alt="album" />&nbsp;' + @Status_Name + ' '
+ @OrderNumber + ' ' + @Name + '</td>'
set @tablestr = @tablestr + '</tr>'
End

So similar, yet so different. This block is hundreds of lines long, and each condition does something subtly different from each other block.


Someone read that doing too much concatenation must be bad, so at the bottom of the loop, we have this simple step:



insert into @temp0 values(@tablestr)
set @tablestr=''

After the loop closes and the cursors are deallocated, the rancid icing on this SQL-HTML cake:



set @tablestr = @tablestr + '</table>'
insert into @temp0 values(@tablestr)
set @tablestr=''
Select * from @temp0 order by historyid

At least we can take solace in the fact that this is a small product from Thomas’s company. No one would build a large-scale product completely dedicated to generating HTML from database stored procedures, right?



[Advertisement] Make your team a DevOps team with BuildMaster . Pairing an easy-to-use web UI with a free base platform, BuildMaster gets you started in minutes. See how Allrecipes.com and others use BuildMaster to automate their software delivery.








via The Daily WTF http://thedailywtf.com/Articles/The-Apex-of-TSQL.aspx

2013-05-04

Bad Day? 8 Ways to Feel Better About Yourself



If trying to think yourself into a better mood fails, try doing something instead. Here are eight ideas.


Some people claim the way you talk to yourself is the key to how you feel.


Try it. Pump your first in the air and repeat after me: "I feel great about myself!"


How did that work out for you?


Positive self-talk can be helpful at times, but more often than not those mental conversations veer off course because it's too easy to be your own worst critic.


That's why feeling great about yourself isn't about talking; it's about doing. Try doing one of these eight things:


Ask for help.


I know: You probably don't equate feeling vulnerable with feeling happier with yourself.


Asking for help actually does several things: It shows you respect the person you ask; it shows you trust the person you ask; and it shows you're willing to admit a weakness or lack of knowledge and skill.


Asking for help isn't a sign of weakness. It's a sign of strength, because it shows you're secure enough to admit you need help.


Try it. Ask for help. You'll make other people feel better about themselves--which is reason enough, because that will automatically make you feel better. And you'll also feel better about yourself because you felt strong enough to ask.


Do something nice that no one will notice.


If the true test of character is what you do when no one else is looking, one of the best ways to feel better about yourself is to do something nice when no one else is looking.


Then you're not doing it for praise or recognition but simply because you think it's the right thing to do--and when we do the right thing we always feel better about ourselves. (Even if doing the right thing is really, really hard.)


I like to put grocery items back on the shelf that have fallen on the floor or shopping carts that have escaped the cart corrals and wandered off into the parking lot or clothes that have fallen off a rack. I know it's someone's job to do it, but if I'm standing right there, why not me? It makes me feel like I'm helping someone.


That always feels good.


Fail, so you can keep getting better.


Failing, even at something simple and inconsequential, is demoralizing. So how can you feel better about yourself by doing something when you know you'll fail?


Example: Years ago I could do three sets of 20 dips with (relative) ease. I stopped working out for a long time. Years later I started going to the gym again and tried to do some dips.


I did four. Woo-hoo.


But two weeks later I could do three sets of 8. A few weeks after that I was doing three sets of 12. Within a few months I was doing 20, 16, and 14.


And here's the cool part: Every time I did just one more than the last time, I felt awesome. I was getting stronger. I was improving.


Pick something you can't do well. (Consider picking something physical since you'll get the added bonus of improved fitness and health.) Then do it.


You'll fail. So what. Keep doing it. You'll get better.


And every time--every time--you make an incremental improvement you'll feel better about yourself.


Say you're sorry.


Because not saying you're sorry creates a weight that slowly crushes your self-esteem.


Recapture that "first" feeling.


When something good happens you feel happier.


For a while. Then you adapt. You revise your expectations upwards. And then you're not as happy.


Think about a day when you felt excited and happy. Maybe it's the day you truly fell for your significant other. Or maybe it's the day you started your business. Life was filled with promise and hope and anticipation.


It still is.


Sit at the table, watch your significant other putter around the kitchen, and picture that first day. Or step outside where you work and picture that first day. Remember how you felt. Your significant other is still just as wonderful. Your business is still capable of reaching incredible heights.


Nothing has really changed except maybe you--and your expectations.


What you already have is wonderful. Bask in that thought. You'll feel better about yourself and you'll be inspired to make things even better.


Go out of your way to meet cool people.


I'm lucky enough to get to meet some extremely accomplished people. Sometimes I find myself in a group and it can seem like a game of "Which item doesn't belong in this picture?" and the totally-out-of-place item is me.


That doesn't feel so great.


But when you meet cool people and pay close attention you'll notice something interesting. For the most part, they're just like you: They share some of the same fears, insecurities, failings, etc. They don't live a charmed life.


You realize they're just regular people who have worked really hard to become great at what they do. And you have a lot more in common with them than you think.


Compliment someone who doesn't expect it.


If giving flowers "just because" carries more emotional weight than giving flowers on a holiday, giving a compliment to someone who doesn't expect it carries more emotional weight, too, both for the person you compliment and for you.


Tell a fellow business owner you love how she's decorated her store. Email an author to say you love his book. Walk over and tell your neighbors with whom you never speak (if you're like me you have plenty of neighbor-stranger options) their flowers are beautiful.


Every day the people around you do good things. Compliment them, even if it's not your job or your "place" to do so.


They'll love it--and you will love how that feels.


Step back into the shadows.


It's your time to shine. You're about to receive recognition and praise. Won't that feel awesome? Maybe... for a minute or two.


Try this instead: Shift the spotlight onto someone else. Let an employee take credit. Let someone else lead the project. Let another person take credit for your idea.


When you seek acclaim or affirmation from others, the feeling is fleeting at best. When you can step back, secure in the knowledge of what you've done, that's a sure sign you feel great about yourself--and that those feelings will last.


Share the spotlight. Better yet, avoid the spotlight. Even if people don't know what you did, you will.


And that's all that matters.






via Articles from Inc.com by Jeff Haden http://www.inc.com/jeff-haden/bad-day-8-ways-to-feel-better-about-yourself.html