David Croushore

A Man in Progress

One Place to Visit

There is one place that I absolutely must visit before I die: New Zealand.

I don’t really know why, but there’s something alluring about New Zealand.  The landscape looks like nothing I’ve ever seen before (at least in Lord of the Rings), and the people sound great, too. I once heard that they consume more ice cream there per capita than any other country in the world (a fact that Google validates quickly).

Of course, getting to New Zealand is no easy task, and in order to make the trip worthwhile, I’ll need to go for a while (and probably stop by Australia along the way). 

My next big international trip will be to China this winter (to kick butt in a business plan competition), but after that, my next jaunt overseas will have to be New Zealand. 


#Trust30 is an online initiative and 30-day writing challenge that encourages you to look within and trust yourself. Use this as an opportunity to reflect on your now, and to create direction for your future. 30 prompts from inspiring thought-leaders will guide you on your writing journey.

Comments

A Fun Fact About Prime Numbers

Take a random integer: let’s say 17783.  Is it a prime number? (yes)

If you had to go about checking whether or not that was a prime number, how many numbers would you have to divide it by before you could be sure it was prime?  That’s a more fun question. 

The first instinct is to say, 17782, since you need to be sure that every number lower than 17783 doesn’t divide it.

Of course, it quickly becomes obvious that you only need to test other prime numbers, since those would necessarily show up in the prime factorization.  Even then, that’s too many.  Why test, for example, 17761 (the next prime below 17783) since it can’t possibly divide a number so close.  It’s tempting to jump to the idea of testing primes below n/2.  Even that turns out to be more than necessary though.

In fact, you only need to test up to the square root of n in order to determine that n is prime. In the case of 17783, that turns out to be only 32 numbers (the 32 primes below 133, which is close to the square root on 17783).

Then again, you could always just look it up here.

Comments

Project Euler is Awesome

Learning to program is hard damn work. Luckily, today I found an awesome site that helps make it more enjoyable.  While I’ve been using lynda.com and w3schools to pick up the basics, today I stumbled upon projecteuler.net, a site that offers hundreds of problems that can be solved with programs that take less than one minute to run. 

The first problem (and the easiest problem) is this: find the sum of all the numbers below 1000 that are divisible by either three or five. 

This is a pretty easy problem from a programming standpoint.  The logic is simple, and there are a few different ways to go about it.  The best part is that once you get the correct answer, you receive access to a forum where other people share their own solutions.  My solution, for example, was rather inefficient (naturally).  Others were able to solve it in one line of code, whereas mine took 9 (different languages are also a factor here).  However, I was able to solve the problem in just a few minutes using PHP, which is something fairly new to me.

While I can’t give you the answer (go solve it yourself), I can tell you that the process of solving a real problem makes learning much easier than simply hearing about the concepts and then trying to invent scenarios where they are used.

Comments

Don’t Forget Your Curly Braces

PHP functions don’t like it when you forget curly braces.

function love($lover, $object){

     if $lover = “I” {

          echo “{$lover} love {$object}”;

     } else {

          echo “{$lover} loves {$object}”;

     }

}

love(“I”,”curly braces”);

<br />

love(“Everyone”,”curly braces”);

Comments

How My Search Box Works

You may not realize this, but there’s a search box hidden under the title of this page.  You can’t see it, because the CSS for the search box has a “display: none;” tag on it. 

There’s also a bit of javascript that makes the search box appear if you click on the “search” link in the navlinks bar. 

Try it out…

The tumblr theme that I have on this blog right now is pretty fancy.  I’m stealing a lot of tricks from it as I build my own design for this site.  Since you could just right-click and select “View Source” and find this out, I feel free to share:

Want to make this fancy search box feature work on your own site?  Here’s the CSS:

     #frmSearch {
        padding-top: 20px; 
        display: none;
     }

     #txtSearch {
        background: url(http://static.tumblr.com/bpryy0m/6lRl6gmys/search.jpg) left no-repeat;
        width: 225px;
        padding: 2px 0 0 20px;
        font: 12px/12px Georgia, "Times New Roman", Times, serif;
        color: #222;
        border: 0px;

}

And here’s the javascript:

<script>
     $(function() {
        var search = $("#txtSearch").val();
        var placeholder = "Search...";
        var fadeToOpacity = 0.4;
        $("#txtSearch").fadeTo("normal", fadeToOpacity);
        if (search == "") {
     $("#txtSearch").val(placeholder);
     }
     $("#txtSearch").blur(function() {
        search = $("#txtSearch").val();
        if (!(search != "" && search != placeholder)) {
        $("#txtSearch").val(placeholder);
     }
     $("#txtSearch").fadeTo("normal", fadeToOpacity);
     });
     $("#txtSearch").focus(function() {
        search = $("#txtSearch").val();
        if (search == placeholder) {
        $("#txtSearch").val("");
     }
     $("#txtSearch").fadeTo("normal", 1);
     });
     $("#btnSearch").click(function() {
     $("#frmSearch").slideToggle("normal");
     $(this).toggleClass("active");
 //  $("#txtSearch").focus();
     });
     });
</script>
Comments

One Strong Belief

It is easy in the world to live after the world’s opinion; it is easy in solitude to live after our own; but the great man is he who in the midst of the crowd keeps with perfect sweetness the independence of solitude. - Ralph Waldo Emerson, Self-Reliance

Security is a kind of death, and perhaps the worst kind there is. 

I do not mean physical security.  As someone living in Washington DC, a city with a high crime rate and a pathetic and corrupt police force, I understand the necessity of physical security.  What I mean is the type of security that stands in the way of personal development.  The security that says “go ahead and watch another episode of your favorite TV show, there’s nothing risky about that.”  The kind that says “you’re tired, forget that event you RSVP’d for.  You never meet anyone interesting at those events anyway.”  Nothing bad can come of these thoughts and actions, and in that way they are secure.  But nothing good can come of them either.

Every day I face a trade-off between the secure path and the risky path.  I do not always make the right choice.  However, I strongly believe that happiness in life will come not from security, but from the growth that comes from shunning security often, and letting the wind blow me wherever it may.


#Trust30 is an online initiative and 30-day writing challenge that encourages you to look within and trust yourself. Use this as an opportunity to reflect on your now, and to create direction for your future. 30 prompts from inspiring thought-leaders will guide you on your writing journey.

Comments

Using Negative Margins in CSS

My first wedding anniversary is coming up in just a couple weeks.  Last year I made a website for the wedding that looked great, but had one tragic flaw.  In some browsers, the content would end up all the way at the bottom of the page, under the sidebar.  I had no idea why this was happening, and ultimately just let those with that browser suffer.

Today I found out the problem.  In CSS, when two floated elements don’t have enough space to fit next to each other, the one that shows up later in the document gets pushed to the bottom.  To get around this issue, it’s possible to add padding to one element (padding is like an internal margin in the CSS box model) and a corresponding negative border value to the other.  This allows the elements to overlap and gets rid of the nastiness. 

At this point, I think I’ve got enough CSS to turn this site into a design of my own.  Now I just need to go about designing the site so that I can create the CSS for it.

Comments

Today

Time is a difficult concept to deal with.  As humans, our life flows at varying speeds.  At times, we reach a state of flow where events happen in quick succession, while at other times events are sparse and we stagnate.  Yet time moves on with cool consistency.  Every second comes, and then is gone. Without fail.

Today is a day like any other.  It begins and ends and it is up to us, individually us and collectively Us, to determine the events that do or do not take place today.  A day with few events of progress is a day that can never be fixed.  When it ends, it is gone, along with the potential progress that was not realized.

So let today’s potential be realized, because when today moves us forward, it moves Us forward.

People like to say that “today is the first day of the rest of your life,” but it is also the last day of your life so far.  It is an opportunity to change the negative as much as it is an opportunity to embrace and enhance the positive.

Whatever today brings or whatever We put into today, it will be, until it is not. 


#Trust30 is an online initiative and 30-day writing challenge that encourages you to look within and trust yourself. Use this as an opportunity to reflect on your now, and to create direction for your future. 30 prompts from inspiring thought-leaders will guide you on your writing journey.

Comments

An Excel Workaround for Conditional Formatting That Shouldn’t Be So Hard

Dear Microsoft,

I use the conditional formatting function in Excel for pretty much only two reasons.  To flag invalid data entry and to identify outliers.  Why is that so damn hard?

I’d like to be able to tell you “if the first digit of the military time is above 2 or the 3rd digit is above 5, flag it as invalid,” but I cannot.  Maybe this is possible, but it’s really hard to figure out.  So here’s how I did it:

First, take the cell in question, then tab over into the margin (or any other blank space, in my case, I needed to do this for two cells on every row).  Next, set up a nested formula that checks for the conditions you want and returns a boolean. In my case that formula was:

=IF(cell<>”“,AND(Value(Left(cell,1))<3,Value(Left(cell,2))<24,Value(Right(Left(cell,3),1))<6,Len(cell)=4),”“)

In other words, if the cell in question (“cell”) is empty, return nothing, otherwise return true if the first digit is less than three, the first two digits are less than 24, the 3rd digit is less than 6, and the length of the string is 4.  That is, only proper military times can be entered. 

Next, having coded all the conditions into that cell, I select the conditional formatting menu on the target cell and set it to have a red background (my preferred flag) if the value of the other cell is “FALSE.” I would prefer to use data validation to reject this entry, but the red flag has to do, because I can’t use validation to check the value of a child cell, this should also be possible.

This workaround is annoying.  Please make this easier to do, either in the data validation menu (the “custom” criteria are not intuitive, and I am fairly certain specifying the value range of digits is not possible) or in the conditional formatting menu (again, the rules are not intuitive with respect to this goal). 

Thank You,

—Dave

Comments

Fifteen Minutes to Live

Muscles burning, lungs straining, stomach cramping.  My head feels loose and heavy as it slumps to the side.  I am unable to hold my body rigid and my military-esque posture fades to a puddle of slop.

Each step I take is painful and seems, on its own, pointless.  The line will never come, and I have already broken down.

But the line always comes.  No matter how painful, how hopeless it feels to strive after that line that sits so far away, the line always comes. 

From the starting horn, caught in a mass of humanity reaching forward in a million directions, I establish a path.  Eventually the chaos subsides and an eery silence falls over us.  In silence we continue on, doing the hard damn work to get to the next junction.

Chaos again as our path must adapt to waves and currents, navigating obstacles to stay on course.  Feet search for solid ground while we all strain to find our balance.  Disoriented and confused, we climb onto the land and set off for the next leg of the journey.

Smooth loneliness now, as our legs churn endlessly into the open expanse ahead.  Always feeling strong, momentum carries forth greater effort, the internal battle begins.  Some energy must be saved for the last leg of the journey, but caught in the moment of incredible power, only short-term thinking can prevail.  Struggling mightily against the urge to struggle too mightily, on and on over the next hilltop and into the next valley.  

Then it begins: the finish line in site on the final leg of the journey.  The body breaks down.  The mind begins to lose hope.  One more step. 

One more step.

When all hope is gone, the line appears.  Re-energized, I find the strength to drag myself across.  On the other side there is only love. 

And the line always comes.

Comments