Sunday, October 18, 2015

What would Gunny Say?

In the Army, they are known as "Drill Sergeants".
In the Navy, they are known as "Recruit Division Commanders".
In the Air Force, they are known as "Military Training Instructors".
In the Marines, they are known "Drill Instructors".

Those who have served know what they are like.  Those who have not have properly seen them depicted in movies or television.  Probably the most iconic is Gunnery Sergeant Hartman (R. Lee Ermey) in the 1987 film "Full Metal Jacket".  Ermey was an actual Marine Corps Drill Instructor in 1965-1967.

Having been to Marine Corps boot camp myself, I can attest to the fact that his portrayal of a drill instructor is spot on as is the portrayal of boot camp overall in the movie.  Boot camp serves a very specific purpose.  To train young men and women into Marines.  While every Marine has their own military occupational specialty (or job), they are all considered to be "a rifleman first".  The yelling, screaming, fast pace, and attention to detail are all intended to prepare a Marine for the very real possibility of combat.  They are no longer children, but are now men and women prepared to place themselves in harms way for God and Country.

I have little doubt that Gunny Hartman would agree with the many posts, videos, and memes that have mourned the loss of the resilience of our youth.  I am sure you have seen them.  They denounce the overuse of everything from bicycle helmets to anti-bacterial soap.  They all state the kids growing up in the [insert decade here] were tougher than kids of today.  I am sure Gunny would agree.

As I write this, my son is at Marine Corps boot camp right now.  I have recently learned of another practice that would have Gunny shaking his head in dismay.  Marines graduate on most Fridays.  This means families are on base Wed-Fri taking pictures of any recruit they see.  They then post these pictures to a common Facebook page and parents at home commence to playing "Where's Waldo" as they try to find their young recruit in the sea of look-a-likes (not unlike what happened when many of them were at summer camp when they were much younger).  In addition to Waldo pictures, these pages are filled with parents supporting each other and wondering how they are going to make it until their baby comes home briefly before going out again.  Gone are the days when the recruits shipped off and Mom and Dad got maybe a letter or two before graduation.  Now we have Facebook where Mom can see her little baby marching around the base.  I think it is time some of these parents land the helicopter and let their babies go... just a little bit.  I have to wonder "What would Gunny say?"

Now, if you will excuse me, I have to go find my Waldo.


Tuesday, October 6, 2015

Pursued


The other day I was watching a crime show on tv.  The detective saw the suspect in the park.   He observed him for some time before approaching.  He then approached the suspect and said he would like to speak with him.  The suspect then gave chase and ran into an apartment building nearby.  The detective pursued right behind.  The suspect climbed the stairs and soon found himself trapped on the roof.  Fearful of what might happen if the detective caught him, he decided to try and jump from one roof to the next.  His attempt failed and he wound up hanging for dear life to a pipe near the top of the first building.  He cried for help.  The detective approached and tried to reach out to assist him.  The suspect was wearing a backpack.  The detective told him that the backpack was weighing him down.  He advised him to let the backpack go, but the suspect refused.  The suspect tried to reach up the detective, but restricted by his backpack, he was unable.  He soon lost his grip and fell to his death.

Afterwards, I could not help but think about how this is really of picture of God's desire for relationship with us.  So often, he will approach us in the park and just want to talk to us.  Just to sit on the bench and have a pleasant conversation.  We, however, are afraid of him and start to run.  Like the suspect, we are afraid of what he will ask us to do, afraid of what he will find out, afraid of what sins he will expose, and afraid of being asked to give something up.  So we run.  We run and try to hide from the one who created the entire universe.  The one who sees all and knows all.  Like an elephant hiding behind a bamboo tree we think we can hide from God.  Like the suspect, eventually our burden of sin causes us to stumble.  Were we to let our sin go, we would find it easier to take hold of God's hand and be drawn to safety.  Clinging to the sin will eventually send us to a certain death.  At this point, the analogy begins to break down.  In the story, the detective tried to reach out to the suspect who was crying for help...but he was unable.   In reality, when we cry out to God, he will reach down and grab us and left us ... with our burden of sin still attached.  Once he has set us safely down, he will take the burden and cast it as far as the East is from the West.  If only we would just stop and talk to him...while we are still in the safety of the park.

Monday, September 14, 2015

Word Search




Here is a Word Search application that I wrote.  You can keep it simple and just key in the words you want to use for the Word Search or you can get fancy and control the settings below:

  • Shape - the shape of the puzzle
  • Directions - which way the words should flow
  • Case - uppercase vs lowercase
  • Filler - what characters to place in the gaps
  • Solution - whether to show or hide the solution
  • Order - whether or not to alphabetize to word list
  • List - show the word list beside or below

This is a windows application (an EXE) and is not a website or browser app.

While there are many applications and websites that will already do this for you, I created this one to solve a developer challenge that has bugged me some time.  Programmatically, what is the best way to fit words into a box and not overlay existing words?

The program is really just a series of nested loops.
Make several attempts to find a place for all the words
  For each word
    For each position in the puzzle (until you find a match)
      For each direction (until you find a match)
        For each letter in the current word
          Place the letter in the spot 
            if the spot is not already taken
            (otherwise try the next direction or position)

The code is a C# .NET Windows Application made with Visual Studio 2012.  If you are interested, you can download the source code.

Saturday, January 31, 2015

Plotting Points On A Circle

I once developed a small countdown timer application that used a pie-chart to display the remaining time.  This involved some high school math to be able to plot a line from the center of the circle and plot a radius to specified point on the line.  The same code would also be helpful for developing an application with a compass.

w = width of the space where the circle is bounded
h = height of the space where the circle is bounded
d = diameter (the shorter of w or h)
r = radius = d/2 = SQRT((x2-x1)^2 + (y2-y1)^2)
x1,y1 = circle center
x2,y2 = a point on the circumference
a = angle (from 12:00)
b = modified angle to convert from degrees to radians, reverse direction of unit circle, and start at 12:00 instead of 3:00.
t = total number of segments
s = segment number
a = (360/t) * s = 360 * (s/t)
b = (270 - a) * (Pi / 180)
x2 = x1 + (r * cos(b))
y2 = y1 + (r * sin(b))
x1 = w/2
y1 = h/2

For a space that  has a height of 400 and a width of 648
h = 400, w = 648
d = 400
r = 400/2 = 200
x1 = 648/2 = 324
y1 = 400/2 = 200

In the case of a clock, there are 60 seconds and thus 60 total segments
t = 60

Each second is 1 segment and thus 20 seconds is segment number 20
s = 20
a = (360/60) * 20 = 120
b =  (270 - 120) * (Pi / 180) = 149.9825

x2 = 324 + (200 * cos(149.9825)) = 324 + (200 * -0.5) = 324 + (-100) = 224
y2 = 200 + (200 * sin(149.9825)) = 200 + (200 * 0.866) = 200 + 173.21 = 373.21

In C#.NET, it looks like this:

  int radius = 0;
  double angle = 0;
  lineShape1.X1 = ClientSize.Width / 2;
  lineShape1.Y1 = ClientSize.Height / 2;
  if (lineShape1.X1 < lineShape1.Y1 ) {
      radius = lineShape1.X1;
  }
  else {
      radius = lineShape1.Y1;
  }
  angle =  Convert.ToDouble(360 *
              (Convert.ToDouble(TotalRemaining)
             / Convert.ToDouble(TotalStart)));
  angle = (270 - angle) * (Math.PI / 180);
  lineShape1.X2 = Convert.ToInt32(lineShape1.X1 
                   + (radius * Math.Cos(angle)));
  lineShape1.Y2 = Convert.ToInt32(lineShape1.Y1 
                   + (radius * Math.Sin(angle)));

download exe

download source code



Sunday, January 18, 2015

Step Away From The Ledge

Today I saw a video online where Cenk Uygur was responding to the recent attacks in Paris at the offices of the Charlie Hebdo (Jan 2015).  Cenk described himself as agnostic and he made some good points I would like to recap and respond to.

He asks if God rules the universe, then how likely is he to look down at Earth and respond "Oh no, someone has drawn a negative cartoon about me and my prophets.  I don't know what to do about that.  I sure hope someone defends my honor and gets revenge."

Cenk went on to say that Islam (and other religions) teach that disrespect and/or denial of God and his prophets can lead to eternal pain, suffering, and damnation.  If that is true, then why do offenders need to be killed or punished now?  Isn't it enough that they will suffer for all of eternity?   Compared to that, torture or murder is a walk in the park.

He said that his god is science.  One of the prophets of science is gravity.  The prophet Gravity is not tolerant of disobedience.  If someone where to disrespect Gravity and step off the ledge of a great cliff, there would would be no need to for anyone to defend the honor of Gravity.  No one would need to seek revenge for Gravity.  Upon stepping off the ledge, Gravity would serve his justice swiftly and severely.

Although Cenk may be agnostic, I could not agree with him more.  God does not need me to defend him.  If you deny or dishonor him, that is between you and him.  Those who do not wish to spend eternity with him can spend eternity without him.  In my view, those that reject, ignore, or insult God (however you choose to define that) are indeed headed for a ledge.  I am not injured by such actions.  There is no harm I could do that would be greater than what happens once they leave the ledge.  On the contrary, my compassion for them would lead me to draw them away from the ledge.  I would hope to convince them to stay on solid ground.  I would tell them in caring and compassionate terms about the dangers of the ledge, the wisdom of keeping their distance from it, and the safety and peace that could be found if they would just turn and walk the other way.  The decision would be theirs to make.  I would not (could not) force them to choose the way that I have chosen.  

In short, I would lovingly plead with them to please step away from the ledge.

Saturday, January 10, 2015

Franklin's Whistle

I recently finished listening to Frank Woodworth Pine's edition of Franklin's Autobiography.  I thoroughly enjoyed this book. Franklin seems to have something to say about just about everything.  His "up by his own boot straps" account of his life is fascinating.  The book covers his involvement with writing, printing, politics, government, military campaigns, and science...just to name a few.  I highly recommend it to anyone.  Here are just two sources for the book:
https://librivox.org/the-autobigraphy-of-benjamin-franklin-ed-by-frank-woodworth-pine/
https://books.google.com/books?id=bJIEAAAAYAAJ

At the end of the book, Pine included one of Franklin's letters to Madame Brillon.  An extract from this letter is below which is a good reminder on judgement, financially and otherwise.

Enjoy.

The Whistle
by Benjamin Franklin

When I was a child of seven years old, my friends, on a holiday, filled my pocket with coppers. I went directly to a shop where they sold toys for children; and being charmed with the sound of a whistle, that I met by the way in the hands of another boy, I voluntarily offered and gave all my money for one. I then came home, and went whistling all over the house, much pleased with my whistle, but disturbing all the family. My brothers, and sisters, and cousins, understanding the bargain I had made, told me I had given four times as much for it as it was worth; put me in mind what good things I might have bought with the rest of the money; and laughed at me so much for my folly, that I cried with vexation; and the reflection gave me more chagrin than the whistle gave me pleasure.

This, however, was afterwards of use to me, the impression continuing on my mind; so that often, when I was tempted to buy some unnecessary thing, I said to myself, Don’t give too much for the whistle; and I saved my money.

As I grew up, came into the world, and observed the actions of men, I thought I met with many, very many, who gave too much for the whistle.

When I saw one too ambitious of court favor, sacrificing his time in attendance on levees, his repose, his liberty, his virtue, and perhaps his friends, to attain it, I have said to myself, This man gives too much for his whistle.  

When I saw another fond of popularity, constantly employing himself in political bustles, neglecting his own affairs, and ruining them by that neglect, He pays, indeed, said I, too much for his whistle.  

If I knew a miser, who gave up every kind of comfortable living, all the pleasure of doing good to others, all the esteem of his fellow-citizens, and the joys of benevolent friendship, for the sake of accumulating wealth, Poor man, said I, you pay too much for your whistle.  

When I met with a man of pleasure, sacrificing every laudable improvement of the mind, or of his fortune, to mere corporeal sensations, and ruining his health in their pursuit, Mistaken man, said I, you are providing pain for yourself, instead of pleasure; you give too much for your whistle.  

If I see one fond of appearance, or fine clothes, fine houses, fine furniture, fine equipages, all above his fortune, for which he contracts debts, and ends his career in a prison, Alas! say I, he has paid dear, very dear, for his whistle.

When I see a beautiful sweet-tempered girl married to an ill-natured brute of a husband, What a pity, say I, that she should pay so much for a whistle!  

In short, I conceive that great part of the miseries of mankind are brought upon them by the false estimates they have made of the value of things, and by their giving too much for their whistles.  

Yet I ought to have charity for these unhappy people, when I consider that, with all this wisdom of which I am boasting, there are certain things in the world so tempting, for example, the apples of King John, which happily are not to be bought; for if they were put to sale by auction, I might very easily be led to ruin myself in the purchase, and find that I had once more given too much for the whistle.