Time Magazine: All that’s fit for garbage cans

Some might be repulsed if he were to find the mailman just left a huge pile of shit in your mailbox. But I like to think the mailman is ignorant for the better in such cases.

Time magazine began showing up in my mailbox, uninvited and unpaid for about a month ago. Today, I found a nice lump of shit, in my mailbox, with the word “Time” at the top followed by an image of the Constitution, shreded, with the headline “Does It Still Matter?” on the cover.

Imagine my horror when I find the article du jour is a poorly researched, wretchedly long diatribe lacking both substance or merit. Rather than take the honest approach, it is generally a personal interpretation of what the document, and selective historical events, mean to the author. Rather than approach the topic from a journalistic perspective, it meanders through many of the greatest factually-challenged arguments about the Constitution up to and including how it is/should be interpreted.

Here’s a snippet:

Yes, they gave us, and the world, a blueprint for the protection of democratic freedoms — freedom of speech, assembly, religion — but they also gave us the idea that a black person was three-fifths of a human being, that women were not allowed to vote and that South Dakota should have the same number of Senators as California, which is kind of crazy. And I’m not even going to mention the Electoral College.

Read more: Time

We’ll skip over the assertion that the Constitution gave us the idea that a black person was 3/5ths of a human being – it doesn’t (the 3/5ths part comes from how votes are apportioned – Non slave holders didn’t want slave holders having more power simply because they owned slaves), or that women were not allowed to vote (oddly, wouldn’t that make them 0/5ths of a person? – but he can’t just say that can he!).

The completely inane part that just blows my mind is the part about South Dakota having the same number of Senators as California.

Here’s the relevant portion of the Constitution itself:

The Senate of the United States shall be composed of two Senators from each State, chosen by the Legislature thereof, for six Years; and each Senator shall have one Vote.

I don’t understand why Stengal can’t understand why this is NOT crazy. But you should have at least a rudimentary understanding of why the Senate was created in the manner it was: It gave each STATE equal representation in the Federal government. How do we know this? Senators were originally nominated by STATE legislatures – not the people.

RTFC

The House represents the people, the Senate represented the states. It is also a key piece of the checks and balances that Stengal goes on to mention several times throughout the article. By placing strict limits on the number of senators, it creates a body where states are evenly represented. How can you believe it insanity that the Senate have equal representation, when it is the House that is to represent the people en-masse.

The insane part is where the Senate elections were given to the people and not the states – effectively trimming a part of the checks and balances that were put in place to check the power of an unrestrained majority.

How can the former CEO of the National Constitution Center not know this or spout that it is somehow “crazy” that the Senate is a check against mob rule?!

But the hits keep on coming throughout the piece. I can barely even stomach it when Stengal says things like:

If the Constitution was intended to limit the federal government, it sure doesn’t say so. Article I, Section 8, the longest section of the longest article of the Constitution, is a drumroll of congressional power.

RTFC – the entire document is a limit on the extent of the Federal Government. They’re called enumerated powers for a precise reason: It is the extent of the Federal government’s power. The 10th Amendment is the final nail in the coffin of Stengal’s ignorant argument. All those powers the Federal government claims that don’t exist in the Constitution: they’re ours (the states and the people).

It Will Snow In Hell Before The Wire: Season 6

David Simon Agrees to Make Sixth Season of ‘The Wire’ If U.S. Agrees to End War on Drugs | /Film.

I think the slashFilm title says just about all it needs to say about the liklihood of The Wire: Season 6.

What I find most interesting is that our Attorney General Eric Holder is a fan. While Holder doesn’t write the laws he is enforcing, it is ironic that he represents one aspect of the many things the HBO series was critical of.

If you have not already watched the series, start with Season 1 and go all the way through Season 6. I would not suggest starting in on a different season – you will miss a lot of connections and back-story into the police and gangs.

(spoiler alert)I’d be interested to see what Simon would do with a 6th season, but my favorite characters (Bodie and Omar) are both pushing daisies. (/spoiler alert)

 

Apocalypse Now Tomorrow

Kyle Smith’s column, Profits of doom – NYPOST.com, is a bit refreshing.  I thought New Yorkers long ago abandoned common sense.

Smith gets it right and points out one of the more frustrating things that happens when we mix science with fantasy – lofty doomspeak of very little substance.

This doomspeak always reminds me of a friend who thinks in analogous terms: We’re on the brink of “something” huge and we’re all going to be wiped off the face the the earth. She can’t ever manage to put her finger on what the catalyst is, but it seems to run the gamut of whatever doomsday scenario is popular.

In our discussions, we have been through the environmental aspects which always begets some new-agey spiritualism (mother nature is pissed), to how horrible humanity is. I’m often needling her to provide details or examples which are often scant and short of any historical perspective.

But when the topic inevitably turns to oil running out, deforestation, or any other resources on the verge of extinction, I like to point out the argument of prices. Funny little things that often get in the way. People like to avoid paying them if at all and if the prices rise, they often will find other ways to go about a specific task.

I’ve pointed my friend to Russ Robert’s book, “The Invisible Heart: An Economic Romance” in which his main protagonist, Sam, offers a salient point to his economics class:

Years before the last drop of oil is found and extracted, we’ll walk away from oil as an energy source. It will be too hard to find new reserves. Or too expensive to extract the reserves we know about. Long before we run out of oil, we’ll switch to cheaper alternatives.

Keith Rabois’ Big Square Pants

GigaOm has this piece up with Square’s COO talking big about the little company. So big in fact, he sees it being bigger, and more valuable, than PayPal.

I can see the possibility. The product is interesting, the software is just about right, but the markets are completely different. If PayPal ventures into mobile payments, it comes with a foot on firm ground in another market that Square doesn’t serve.

But for Square to get bigger than PayPal, it is going to have to move a lot of merchants over and it is going to have to capture more than just mobile transactions.

Few Choices, But Choices Nonetheless

The way this campaign season is starting up, I’m almost sure we can expect four more years of Our Dear Leader Obama. So here’s a quick rundown of our candidate list for Team Pepsi (Republicans):

  • Herman Cain
  • Newt Gingrich
  • Gary Johnson
  • Fred Karger
  • Tom Miller
  • Ron Paul
  • Tim Pawlenty
  • Mitt Romney
  • Rick Santorum
  • Vern Weunsch

And soon we might add a couple more:

  • Sarah Palin
  • Michele Bachmann

I don’t even really know where to begin. I’m not thrilled with the list. The two high points are Gary Johnson and Ron Paul. While I’m not on the same page about everything with Paul or Johnson, their interests/positions reside closest to mine on the political map from Team Pepsi. Both will be underdogs in the fight.

 

Got Hacked. But I’m Back

It looks like a couple of my sites got hacked. This one appears to have been fine but I didn’t want to waste the time trying to weed through all of the files to figure out what was done. So I axed bunch of databases, a bunch of sites and stripped everything else down. It should have been done a while ago but I’ve been tied up with a new job and life.

So it goes.

If you are looking for particular content, I’m hoping to parse through what I had and import it over time.

Lithium Framework: Blog Tutorial Extended (MongoDB)

I’ve recently been toying with the Lithium framework, a fork of some code produced by some of the CakePHP devs that was spawned into its own being. I have few grievances with CakePHP and used it for a couple of smaller projects a couple years ago. Yet, as PHP has matured, so has the language and there are a ton of features in PHP5 that make it difficult to fully appreciate a framework dedicated to backward compatibility as in the case of CakePHP.

This isn’t a slight on CakePHP at all. It is just a difference between where I want to be programming and where CakePHP is as a framework. If anything, CakePHP is right where it needs to be – catering towards the strength of a giant PHP4 and PHP5 installed-base with a strong and stable code base.

Lithium is bleeding edge, a little rough and presents PHP5 in near-full-glory. Being familiar with CakePHP, it makes it nice to find some familiar concepts in Lithium while I have the opportunity flex some of PHP5′s new features. But enough about me and Lithium, let’s get on with extending the tutorial.

Note: I’m still feeling around Lithium and many of the concepts so there may be some inefficiencies or redundancies in the code. Also, this is an extension of the demo, as such, there is virtually nothing in the way of security implemented. Remember, always wear protection!

The current (as of this writing) blog tutorial ends right where the fun begins. The original tutorial shows you how to set up the index and add methods in the PostsController. In each part, you have the opportunity to do some basic interfacing with MongoDb by doing a basic find and insert query respectively.

But we want to do more. How about we create the ability to see the post all by its lonesome and add a view ( as in view-a-single-post, not view as in MVC) method to the PostsController.php.

public function view($id=null) {
   // we are going to view a page.
   if(!is_null($id)) {
       $post = Post::find('first', array('_id'=>$id));
       return compact('post');
   }
 }

Basically, when an id is passed on the URL, we pass the id into the database query and look for the matching post in the database. In this case, we want to pass the MongoDB object ID ‘_id’ in the URL. (Note: this can be changed to some other field or combination but you’ll need to devise a method to parse the query parameter to find the right post). We end the method by returning the results as an array to make them available in the View.

Next, we’re going to create a new file in /views/posts/ folder called view.html.php

 

 

<article>
        <h1><?=$this->html->link($post->title,'/posts/view/'.$post->_id); ?></h1>
        <p><?=$post->body; ?></p>
    </article>

 

 

 

This is just a simple view that shows us the title and body of the post. Alright! Now we have a method and a view associated with the new method. Did we forget something?… How about: how are we going to get to the individual post if we don’t really know what the unique ID is?

Easy peasy. Now open up /views/posts/index.html.php and change

<h1><?=$post->title ?></h1>

To:

<h1><?=$this->html->link($post->title,'/posts/view/'.$post->_id); ?></h1>

When you loaded the index page, you ran a foreach to display each post. Although present, you didn’t use all of the available variables passed to your template. All we are doing is creating a link to our new method, view, passing the unique MongoId on the end of the URL.

Go ahead and save your changes. We should be in business! Go to your post controller at http://mysite.com/posts/ to view the index page. You should see that each title you see is a link. If you mouse-over the link you’ll see a URL like

http://mysite.com/posts/view/4d01a6cc5096344818020000

The long string on the end will be different of course. But each blog post will show a unique id. Click on the link and it will take you to view your post.

Now we’re going to get a little crazy. We want to add some comments to our blog posts. Notice that when we has the add method that there weren’t any comment fields in the document we sent to the database. That’s fine. we’re ok – MongoDb is essentially schema-less and we need to think of a blog post as a document, not as some octopus-like series of relationships. Remember, KISS – “keep it simple, stupid”.

Let’s go back to our whiz-bang PostsController.php file. Plug the following code into your class:

public function comment($id=null) {
        // check to make sure the request is set
        if(!is_null($this->request->data)) {
            $data = &$this->request->data;
            //we'll set up our query
            $query = array(
                 '$push'=> array('comment'=>array(
                     'title'=>$data['title'],
                     'contact'=>$data['contact'],
                     'body'=>$data['body']
                    )
                 )
            );
		//set up the conditions
            $conditions = array('_id'=>$id);
		// execute the qeury
            $result = Post::update($query, $conditions, array('atomic' => false));
        } 

        // you'll want to add checks, but for simplicity, we'll just send them back to the individual post
            $this->redirect("/posts/view/$id/");
        } 

    }

Now this is a little bit more complicated. In the code above, we define the query as an array of keys and values. Be very careful here. ‘$push’ is a native MongoDb command. Make sure you are using single quotes (a literal string) around it so PHP doesn’t look for a variable named $push. The MongoDb command $push essentially helps us do two things: if ‘comment’ is a defined field in our database, it updates the field by appending the new information to the old information. If the field is not defined, it defines the field and adds the data. If we don’t use the ‘$push’ command and just pass the query, shortened to the data being added, it will just overwrite what is already there after each comment.

As we move down through the code, you see that we set up the conditions to look for a matching MongoId. We then invoke the update. Notice that the query comes first, the conditions second, and we have a third item there that is extremely important. We set ‘atomic’ to false. If we do not do this, Mongo will treat our query as a raw update; that $push command will become a key added to the document rather than the command telling Mongo how to deal with the rest of the array. And we’re finally finished in the controller. But we don’t need to show a view specific to this method. We can just send them back to view the post they commented on.

Go ahead and go back to /views/posts/view.html.php in your editor. We’re going to do a couple quick edits. We are going to add a loop to view the comments after the blog post. The second thing we’ll do is add the form to post a new comment. After the closing article tag, paste in the following.

        <div class="comments">
            <h2>Comments</h2>
           <?php if(isset($post->comment)): ?>
               <?php foreach($post->comment as $comment): ?>
                <div class="comment">
                   <h3><?= $comment->title; ?></h3>
                   <p><?= $comment->contact; ?></p>
                   <p><?= $comment->body; ?></p>
                </div>
               <?php endforeach; ?>
           <?php endif; ?>
        </div>
        <div class="commentform">
            <h2>Add a Comment</h2>
            <?=$this->form->create(null, array('action'=>'comment/'.$post->_id)); ?>
                <?=$this->form->field('title');?>
                <?=$this->form->field('contact');?>
                <?=$this->form->field('body', array('type' => 'textarea'));?>
                <?=$this->form->submit('Add Comment'); ?>
            <?=$this->form->end(); ?>
        </div>

This form and display is pretty straight forward. Because our view model already grabs a document by the MongoId, we have the full document and all of the comments. We use the HTML helper to help us create a quick and dirty form. On the back side, we grab all of the form fields from $this->request->data.

At this point, you should be able to go to your site and see your posts. You can click on the title of a post and view the post. The post page should show you the post, comments and a form field to add comments. When you add a comment, you should be returned back to view the post and see your new comment added.

Not bad for quick and dirty. Sure, it needs some work, but it should get you along a little further in your study of Lithium.