Windows Batch Code: Determine if a String is in the Path Variable and Execute or Download the Missing Software From A Website

This code section below was very helpful when writing a quick Windows batch file to determine if a piece of software was available at a Windows Command Prompt or Powershell by checking the Path environment variable for a keyword.  In the case below, we check to see if NodeJS is installed, and if it is we execute.  Otherwise, we queue a download of NodeJS MSI installation to Windows Temp Directory and then kick off the installation!

 

Windows Batch Code

SET VWF_DIR=%VWF_DIR%

REM Check to see if Node is installed and accessible from the Path variable

set test=c:\program files (x86)\nodejs

call:inPath test

REM If it is, we start up the NodeJS Server. The NodeJS server accepts command line parameters.
REM C:\> vwf –help will display all of the currently available parameters accepted by Virtual World Framework

IF NOT ERRORLEVEL 1 pushd %VWF_DIR% && cmd.exe /C npm install && popd && cmd.exe /C node “%VWF_DIR%/node-server.js” %*
IF ERRORLEVEL 1 set test=c:\program files\nodejs && call:inPath test
IF ERRORLEVEL 1 bitsadmin.exe /transfer “NodeJS is not installed. We are downloading NodeJS for you.” http://nodejs.org/dist/v0.10.22/x64/node-v0.10.22-x64.msi C:\windows\temp\node-v0.10.22-x64.msi & call C:\windows\temp\node-v0.10.22-x64.msi & echo Node is now installed. You will need to restart your computer and execute VWF again to start your server.
endlocal

:inPath pathVar
::
:: Tests if the path stored within variable pathVar exists within PATH.
::
:: The result is returned as the ERRORLEVEL:
:: 0 if the pathVar path is found in PATH.
:: 1 if the pathVar path is not found in PATH.
:: 2 if pathVar is missing or undefined or if PATH is undefined.
::
:: If the pathVar path is fully qualified, then it is logically compared
:: to each fully qualified path within PATH. The path strings don’t have
:: to match exactly, they just need to be logically equivalent.
::
:: If the pathVar path is relative, then it is strictly compared to each
:: relative path within PATH. Case differences and double quotes are
:: ignored, but otherwise the path strings must match exactly.
::
::————————————————————————
::
:: Error checking
if “%~1″==”” exit /b 2
if not defined %~1 exit /b 2
if not defined path exit /b 2
::
:: Prepare to safely parse PATH into individual paths
setlocal DisableDelayedExpansion
set “var=%path:”=””%”
set “var=%var:^=^^%”
set “var=%var:&=^&%”
set “var=%var:|=^|%”
set “var=%var:<=^<%”
set “var=%var:>=^>%”
set “var=%var:;=^;^;%”
set var=%var:””=”%
set “var=%var:”=””Q%”
set “var=%var:;;=”S”S%”
set “var=%var:^;^;=;%”
set “var=%var:””=”%”
setlocal EnableDelayedExpansion
set “var=!var:”Q=!”
set “var=!var:”S”S=”;”!”
::
:: Remove quotes from pathVar and abort if it becomes empty
set “new=!%~1:”=!”
if not defined new exit /b 2
::
:: Determine if pathVar is fully qualified
echo(“!new!”|findstr /i /r /c:^”^^\”[a-zA-Z]:[\\/][^\\/]” ^
/c:^”^^\”[\\][\\]” >nul ^
&& set “abs=1” || set “abs=0”
::
:: For each path in PATH, check if path is fully qualified and then do
:: proper comparison with pathVar.
:: Exit with ERRORLEVEL 0 if a match is found.
:: Delayed expansion must be disabled when expanding FOR variables
:: just in case the value contains !
for %%A in (“!new!\”) do for %%B in (“!var!”) do (
if “!!”==”” endlocal
for %%C in (“%%~B\”) do (
echo(%%B|findstr /i /r /c:^”^^\”[a-zA-Z]:[\\/][^\\/]” ^
/c:^”^^\”[\\][\\]” >nul ^
&& (if %abs%==1 if /i “%%~sA”==”%%~sC” exit /b 0) ^
|| (if %abs%==0 if /i “%%~A”==”%%~C” exit /b 0)
)
)
:: No match was found so exit with ERRORLEVEL 1
exit /b 1

Using GitHub Branch Names With Forward Slashes and Jenkins Together

One of my pet peeves with Jenkins existed around the use of forward slashes in our branch names on Virtual World Framework.  While the forward slash “/” was accepted by GitHub (ie. branch/branch-name) as an acceptable character, Jenkins would blow up when trying to pull from this branch name structure.

The solution for using forward-slashes branch names in Jenkins was incredible easy however. You simply need to add origin/ to the beginning of your branch name when filling in the “branches to build” Branch Specifier.

Thus:

origin/branch/branch-name 

allows Jenkins to poll and pull changes specific to a branch with a forward slash in its name.  Simple!

2014 New Year’s Resolutions For A Better Life

start_button2

2013 is coming to a close, and this year has had a lot of ups and downs for my personal life.  At Lockheed, we sit down and brainstorm on things to start/stop/continue for our future growth every year.  Sitting back to reflect, I have come up with a list of things to stop from 2013, which should lead to a great start in 2014.  I am not big on setting resolutions, so instead I consider these life lessons to integrate into my psyche for a more positive and successful year!

  1. Stop running from my problems. 
  2. Stop lying to myself.
  3. Stop putting my own needs on the back burner.
  4. Stop trying to hold onto the past.
  5. Stop berating myself for old mistakes.
  6. Stop exclusively looking to others for happiness.
  7. Stop being idle.
  8. Stop thinking I’m not ready.
  9. Stop getting involved in relationships for the wrong reasons.
  10. Stop rejecting new relationships just because old ones didn’t work.
  11. Stop trying to compete against everyone else.
  12. Stop being jealous of others.
  13. Stop complaining and feeling sorry for myself.
  14. Stop holding grudges.
  15. Stop wasting time explaining myself to others.
  16. Stop doing the same things over and over.
  17. Stop overlooking the beauty of small moments.
  18. Stop following the path of least resistance.
  19. Stop acting like everything is fine if it isn’t.
  20. Stop trying to be everything to everyone.
  21. Stop worrying so much.

 

Not all was bad habits though.  Personal growth is a continual challenge, and 2013 gave me some great new habits that I would like to continue including:

  1. Continue being grateful for the life I have built.
  2. Continue owning my mistakes when I make them, and work to correct them.
  3. Continue to realize perfection is an illusion – happiness does not spring from perfection.
  4. Continue to be quietly strong when confronted by people who are trying to bring you down by projecting their own issues on you.
  5. Continue to forgive others, and understand they are usually from a place of internal pain.
  6. Continue to not be scared to make mistakes. Mistakes are the part of life that grow your soul’s strength.
  7. Continue to realize I am not anyone else.
  8. Continue investing energy in people that elevate my life to a higher level.
  9. Continue focusing on my health.
  10. Continue being a change agent for my life, and for my community.

And of course, you need to challenge yourself, otherwise you will stagnate.  So here are some new challenges for 2014 that I want to personally attain and integrate into my being:

  1. Start focusing on participating in activities that make me happy.
  2. Start breaking unhealthy routines in my life.
  3. Start realizing that the moments during a year that seem to be the end are just a new beginning.
  4. Start having fun each and every single day.

WATCH: Photorealistic Morgan Freeman Drawn on an iPad

This just absolutely blows my mind that it was done on an iPad. You can watch the entire image be created from beginning to end.  I still can’t fathom how this was made on an iPad even as I watch it with my very own eyes.  This is why I love to develop software – you never know WHAT an artist can do with the tools you create for them.

How To Let Go Of Your Past To Bring About Your Future

Too often I talk to people that have become complacent, have built up their walls, and have become so jaded that they forget the magic and mystery of the world around them.  They forget that 150 years ago, man did not fly, radios did not exist, television did not exist, and we rubbed radium on our teeth as a way to make them glow for fashion.  We live in such a technologically advanced world today that the magic of how it all works has become mundane.  I challenge everyone that has become complacent in their now to embrace and contemplate the world around them that joins the beauty of the natural night sky above with a weave of information that unites every human being on this planet.  There is so much to be amazed by – embrace that joy your soul feels when you realize how truly astounding it is, and challenge yourself to change your thoughts and your habits today to reach a better, more successful future for yourself and for those around you tomorrow.

I challenge you to change your attitude through small actions:

  1. Compliment one person every day.
  2. Turn off the television.
  3. For every negative thought you have and catch, think a positive thought about how you can affect change to make this negative disappear from your reality.
  4. Meditate for one full minute at least once a day.
  5. Name three things every day you are thankful for.
  6. Do ten pushups every time you feel yourself getting anxious.
  7. Read 5 pages of a novel daily – let your mind take a mental vacation.
  8. Go outside and walk 100 steps.  Observe the world around you, and breathe deeply.
  9. Drink one glass of water in silence of both your voice and your mind.

Once you start on these small things, you will find that the calmness and peace of mind that arises within you will help you challenge your anxiety for the future, reduce your stress for the present, and allow you to let go of the past.  Once you do, you will normally find that today’s mountains are really mole hills.

Virtual World Framework and HAProxy 1.5 How To Setup Configuration

When setting up our operational environment on Amazon Web Services, we had a number of interesting constraints.

  • We were cost constrained to maintain the minimum number of servers possible.
  • We needed to support Jenkins for Continuous Integration and Redmine for Issue Tracking.
  • The VWF demonstrations utilize websockets and secure websockets which required us to support websockets / secure websockets.
  • We needed to support multiple subdomains which point to multiple Ruby Thin web servers/ Node.js web servers on the back-end to host our executing branch configurations from GitHub.
  • We needed to allow an SSL pathway for internal Lockheed network engineers to access.
  • We required compression
  • We required all traffic over port 80
  • We needed to reroute a subdomain to point to an sh script for installation hosted on GitHub

To solve these issues, HAProxy came in to save the day allowing us to achieve all of these goals by serving as our front-end service proxy for our operational environment to handle incoming client requests.  HAProxy 1.5, although still in development, is stable enough and capable of handling reverse proxying of websockets for HTML5 AND handles compression on the fly as well.

Below is our configuration file.  Please leave questions in the comments if you have any!

HAProxy Configuration for Virtual World Framework

————————————————————————————————–

global

log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
#chroot /usr/share/haproxy
user haproxy
group haproxy
daemon
debug
#quiet

defaults

log global
mode http
option httplog
option http-server-close
option dontlognull
retries 3
option redispatch
option contstats
option forwardfor
stats enable
stats refresh 10s
stats uri /stats
compression algo gzip
compression type text/html text/plain text/css model/vnd.collada+xml application/javascript
timeout connect 360s
timeout client 360s
timeout server 180s
timeout http-keep-alive 60s
timeout http-request 60s
timeout queue 60s
timeout tarpit 60s
timeout tunnel 3600s

frontend public

bind *:80
acl is_jenkins hdr_beg(host) -i jenkins.
acl is_redmine hdr_beg(host) -i redmine.
acl is_www hdr_beg(host) -i www.
acl is_integration hdr_beg(host) -i integration.
acl is_development hdr_beg(host) -i development.
acl is_download hdr_beg(host) -i download.
acl is_test hdr_beg(host) -i test.
acl is_get hdr_beg(host) -t get.
use_backend jenkins if is_jenkins
use_backend redmine if is_redmine
use_backend development if is_development
use_backend integration if is_integration
use_backend download if is_download
use_backend www if is_www
use_backend test if is_test
use_backend get if is_get
default_backend www

backend www

timeout server 30s
server www1 127.0.0.1:5000
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend integration

timeout server 30s
server integration1 127.0.0.1:5001
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend development

timeout server 30s
server integration1 127.0.0.1:5002
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend test

timeout server 30s
server integration1 127.0.0.1:5003
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1
acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1
acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1

backend jenkins

timeout server 30s
server jenkins1 127.0.0.1:6001
option http-server-close
cookie JSESSIONID prefix

backend redmine

timeout server 180s
server redmine1 127.0.0.1:6000
option http-server-close
cookie JSESSIONID prefix

backend download

timeout server 180s
server download1 127.0.0.1:8081
option http-server-close
cookie JSESSIONID prefix

backend get

redirect location https://raw.github.com/virtual-world-framework/vwf/branch/vwf-install-scripts/support/build/Scripts/install.sh

 

Making Your Weaknesses Relevant

One on the most misunderstood statements today is this: “Focus on your strengths and make your weaknesses irrelevant.”  Every time I hear or read it, I cringe and think, “What if your weaknesses are relevant?”

Excuses for Weaknesses

Have you ever heard people make excuses for poor performance?  Then they followed it by an explanation like this: “That’s just the way I am; it’s part of my DNA.”  Or, “That is one of my weak points.” Or, “I’m just not good at that.”  Then they blow it off like it’s acceptable.

How much respect would you have for someone who is always late and says… read more

One on the most misunderstood statements today is this: “Focus on your strengths and make your weaknesses irrelevant.”  Every time I hear or read it, I cringe and think, “What if your weaknesses are relevant?”

Excuses for Weaknesses

Have you ever heard people make excuses for poor performance?  Then they followed it by an explanation like this: “That’s just the way I am; it’s part of my DNA.”  Or, “That is one of my weak points.” Or, “I’m just not good at that.”  Then they blow it off like it’s acceptable.

How much respect would you have for someone who is always late and says, “I’m sorry, but it’s awfully hard for me to be on time.”

How successful would a tennis player be who is exceptional at every part of his game, but can’t serve?

How far within your organization would a person get who does his or her job well, but can’t communicate effectively with co-workers?

Or, think about the young father who is a dedicated dad but has a real problem with his temper.  How do you think his relationship would be with his wife and children if he thought, “I’m so good at everything else, I‘m just not going to worry about my temper?  They will have to accept me the way I am”?

For most of us, our weaknesses are relevant and the worst thing we can do is to ignore them or discount their importance.

Deal With Your Weakness

Author Nathaniel S. Summers said, “The strength of a person is often weighed by how they deal with their weaknesses.” 

When I started my entrepreneurial career 31 years ago, my English was awful. (It had been my worst subject in school.)  It quickly became clear to me that if I wanted to be successful, I would have to focus on my written communications and make them a strength.  Today, I proof all my emails and consider the little things I can do to improve my messages, even if they’re casual emails going to my family and friends.

I am an extreme introvert but, because I consciously work on it, no one would ever know if I did not tell them.  I realized if I were going to be successful, I would have to push myself outside my comfort zone and work on my people skills and make them a strength.

How do you feel about your weaknesses?  Are you intentional about working on them or have you fallen into the trap of thinking they don’t matter?  Do you think or say, “That’s just the way I am.  I can’t help it.  Don’t expect me to change”?

If your co-workers sat in a conference room and made a list of your greatest weaknesses, what would be on the list?  As you consider the things they would discuss, how many of those things could you improve tomorrow, if you were intentional?

If your spouse or significant other were to make a list of the things you do that bug him or her, what would be put on the list?  As you think of the most likely answers, how hard would it be to stop doing those things, if you really tried?

Rewards for Turning Weaknesses into Strengths

What many people don’t realize is that their weaknesses are holding them back from enjoying more meaningful relationships, advancing their careers, improving their self-images and confidence, and living happier lives.

I am a firm believer that when you do the little things that you know you should do, without excuses, you feel better about yourself and the person you are becoming.  When you blow them off or discount them, your subconscious knows the truth.  When you repeatedly fail to do the things you know you should do, it’s impossible to feel good about yourself.

The fact is that 95% of the weaknesses I see holding people back are things they could change today, by simply being intentional.

My Three Challenges For You

1.  Change Your Attitude.

Never again allow yourself to think or believe that weaknesses are irrelevant.  You can change weaknesses into strengths.

Michael Jordan said, “My attitude is that if you push me towards something that you think is a weakness, then I will turn that perceived weakness into a strength.”

2.  Acknowledge your weaknesses.

The first step towards improving your weaknesses is to openly acknowledge them.

3. Be Intentional.

Choose one weakness and start today to work on it at home, at work, and in your social circles.

For most people, it’s not the lack of focus on their strengths that holds them back; it’s the lack of focus on their weaknesses!

10 Tips to Help You Achieve Your Goals

How would you like to increase the odds of achieving your goals?  Whether you desire to lose weight, create financial independence, build a healthy marriage, or raise responsible children, the formula for achieving any goal is the same.

Here are 10 tips in sequential order that will help you increase the odds of achieving your goals:  (Each link is one of my related lessons.)

1.  Identify what’s important to you!  The only goals you will succeed in reaching are those that are truly important to you…read more

How would you like to increase the odds of achieving your goals?  Whether you desire to lose weight, create financial independence, build a healthy marriage, or raise responsible children, the formula for achieving any goal is the same.

Here are 10 tips in sequential order that will help you increase the odds of achieving your goals:  (Each link is one of my related lessons.)

1.  Identify what’s important to you!  The only goals you will succeed in reaching are those that are truly important to you. If a goal is not meaningful or significant to you, you will quit when faced with obstacles. Take 30 minutes and make a list of the things that are truly essential in your life; those that you highly value. Then highlight the most important points on that list and set your goals.

2.  Learn from those who have already achieved “your” goals.  Once you are clear on what you truly want to achieve, your next step is to learn what you need to know. The best source of knowledge will come from those who have already reached goals similar to yours. Identify people you respect and admire, who have achieved the goals you desire, and learn as much as you can from them.

3.  Determine the person you need to become.  Far too often people focus on what they need to do to achieve their goals and fail to consider who they must become. To accomplish something you have never accomplished before, you must be willing to do what you’ve never done before; go where you’ve never been before; become someone you’ve never been before.

As you learn from those who have achieved “your” goals, pay as much attention to their personal attributes and characteristics as you do to what they did to realize their goals.

4.  Put together a plan.  After learning from and studying those who have been successful in reaching similar goals, your next step is to put together your plan. You need to clearly outline what you need to do and when, step-by-step, and then reduce those steps into daily activities. Knowing exactly what you need to do every day is critical to achieving any worthwhile goal.

5.  Ask, “Am I willing to pay the price required to achieve my goal?  After you complete your plan, be honest with yourself and determine if your goal is important enough to you that you will discipline yourself to do what’s required each day to achieve your goal. One of the biggest reasons people fail to reach their goals is because they are not willing to do what’s required over a sustained period of time.  How about you.

6.  Allocate the time required.  Your next step is to block out the time necessary each day to work your plan. If you are like most people (and that includes me), you will need to give something up that’s less important so you have the time to achieve what’s more important. Blocking out time each day to work your plan is vital.  Success comes from consistent daily action!

7.  Get started.  Once you have learned what you need to know, divided your plan into daily activities, and blocked out time each day to do the assigned tasks, it’s time to Work Your Plan. Start tomorrow! When the time you’ve blocked out arrives, push yourself to do what you know you should do without any further delay. It’s time for action. You could continue to study dozens of books, listen to CDs, and interview successful people (all helpful), but the greatest, most practical knowledge comes from implementing what you’ve learned.

8.  Make wise decisions.  Your odds of achieving your goals dramatically improve when you follow a logical process of making your decisions, both big and small. With each decision you make, consider all your options; write down the pros and cons of each option.  From there, the right decision is usually obvious.

9.  Refuse to allow excuses.  The No.1 reason people fail to achieve their goals is because they allow themselves to make excuses for not doing what they know they should do. One of the most crucial keys to success is doing what you know you should do, every day, even when you don’t feel like doing it.  This means NEVER allowing yourself to justify not doing what you know you should do. Make a commitment that you will not make excuses under any circumstances!

10.  Strive for excellence.  The No.1 key to my success over the last 31 years is that I have always strived (and I still strive) for excellence in whatever I do. I analyze everything I’ve done and consider how I can do it better. As you work your plan each day, evaluate everything you are doing and consider how you can refine what you are doing so that your results improve. The compounding effect of small daily improvements is powerful. The best of the best are those who strive for constant and never-ending improvement.

If you will take the time to study each of the above tips and the corresponding lesson highlighted in many of them, you will significantly increase your odds of achieving your goals. The reason many people fail to achieve their goals is because they are unwilling to do what is necessary over the required period of time. If you’re like most people (and that includes me), you will go through periods of discouragement and disappointment. That’s normal.

When you get down, remember “Quitters never win and Winners never quit.” Remind yourself that the reason you will achieve your goals is because you are a winner, not a quitter! Step out from the crowd and build a life for yourself that makes you proud!