Pages

Thursday, March 22, 2012

A dog's life, a rough life indeed...



Man I wish he could actually get a job and do some work instead of sleeping all day. Lazy bastard.

Wednesday, February 8, 2012

five from umberto eco 
Schools ought to teach the high art of how to be discriminating.
~~~~~
I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth.
~~~~~
Comedy is the quintessential human reaction to the fear of death.
~~~~~
I always assume that a good book is more intelligent than its author. It can say things that the writer is not aware of. 
~~~~~
If you interact with things in your life, everything is constantly changing. And if nothing changes, you're an idiot.
~~~~~
via form is void

Friday, February 3, 2012

Merging JSON Objects Successfully

If you've been using JavaScript for a while you've probably come across the problem of comparing JSON objects. At first glance it doesn't seem to be very easy since {} !== {} evaluates to true. One solution would be to use JSON.stringify on the objects and you would be able to see equality.

Another problem is doing a merge of objects since $.extend() and $.merge() fall a little short. Merge is used for arrays and will put duplicate objects into the merged array. Extend doesn't do a complete recursive merge merge even with passing the parameter true for deep.

Take a look:

var obj1 = {
    data: [
        {
            id: 1,
            text: "1"
        },
        {
            id: 2,
            text: "2"
        },
        {
            id: 3,
            text: "3"
        }
    ]
};



var obj2 = {
    data: [
        {
            id: 3,
            text: "three"
        },
        {
            id: 4,
            text: "4"
        }
    ]
};

$.extend(true, obj1, obj2) yields:
//Missing {id: 1, text: "1"} and {id: 2, text: "2"}
{
  "data": [
    {
      "id": 3,
      "text": "three"
    },
    {
      "id": 4,
      "text": "4"
    },
    {
      "id": 3,
      "text": "3"
    }
  ]
}

jQuery's extend for the data array seems to be doing a merge based on position instead of comparison with obj1's objects in the same position. The options are slowly dwindling. That's why I made my own recursive function to do a deep merge. You can check out my gist and run mergeDeep(obj1, obj2) to return:

//All the data has been merged properly
{
  "data": [
    {
      "id": 1,
      "text": "1"
    },
    {
      "id": 2,
      "text": "2"
    },
    {
      "id": 3,
      "text": "3"
    },
    {
      "id": 3,
      "text": "three"
    },
    {
      "id": 4,
      "text": "4"
    }
  ]
}

Listen to: Active Child

Do it guys. They're awesome.


Wednesday, February 1, 2012

Donate your marrow!

Hello everyone.

Today I'm urging you to sign up for marrow donation. The process is really easy and what happens is they put you on a marrow registry and they notify you if a match comes up. I did mine a month or so ago. If you are matched you have the opportunity to save a life. Who would turn down saving someone? The medical stuff from what I understand would be paid for by the receiver if that's a concern. Here is where I signed up. They will send you some q-tips to swab the inside of your cheek for a tissue sample and you'll mail them back and be registered.


While you're waiting for your q-tips to arrive check out this video of my good friend Derek Story shreddin' it.


via PostSecret


Sunday, January 29, 2012

strstr (JavaScript)

So I ran across this post and I was curious if I could write my own strstr function without using any library calls, just arrays, but in javascript. 15 minutes later and voila it works! Here it is:
function strstr(haystack, needle) {
    var i = 0,
        tempLength = 0,
        temp = [];
    for (;;) {
        if (haystack[i] === undefined || needle == null) {
            return "No match";
        }
        //if the char doesn't match then reset
        else if (haystack[i] !== needle[tempLength]) {
            temp = [];
            tempLength = 0;
        }
        //the char matches so let's store it.
        else if (haystack[i] === needle[tempLength]) {
            temp[tempLength] = haystack[i];
            if (needle[tempLength + 1] === undefined) {
                return temp;
            }
            tempLength++;
        }
        i++;
    }
};

Wednesday, January 25, 2012

Tuesday, January 24, 2012

Operation Know Who You're Voting For: Mitt Romney

Here is an article detailing the release of Mr. Romney's tax records. Romney is the epitome of what Occupy Wall Street is against, someone who's made all of his money by scouring for failing companies, breaking them up, and then dumping them. There are legitimate tax loopholes for moves like this that put the financial burden for benefits to workers on the government and not the people who bought the company in distress. Alas his effective tax rate for 2010 was 13.4%. I paid more relative tax to my income last year! This guy purports to be a working class man who understands the trials of the middle class, yet he's making off of the demise of the working class. Romney's ability to pay such a low percentage of tax is also through the capital gains tax which maxes out at 15%.

Update: The New York Times has released a nice breakdown of Romney's tax forms here. In his 203 page joint tax return he reports $110,000 out of $20.9 million as employment income. He's actually in the top .006 percent and it's pretty clear that these people have the will and the means to find every tax loophole possible.

Monday, January 16, 2012

SOPA / PIPA

If you guys don't know much about SOPA or PIPA please watch this video. Apparently congress has stopped pushing for SOPA at the moment but be vigilant they will be back. Also this could be a move to be able to pass PIPA without much resistance.


Go here to do something about it.

Monday, January 9, 2012

Beirut - My Night With The Prostitute (transcribed)

Hello people. So I've heard that transcribing songs is one of the best things a person can do to develop their ear. It's also supposed to help a great deal with soloing. Thus here is my first transcription. I chose the main riff of this song because I thought it sounded fun and it was also pretty easy to be able to hear each individual note.

(Click on the image to enlarge it.)

Thursday, January 5, 2012

Operation Know Who You're Voting For: Rick Santorum

"No one has ever died because they didn't have health care." - Rick Santorum (here)

Wednesday, January 4, 2012

Operation Know Who You're Voting For: Rick Santorum


This guy (Rick Santorum) is a total ass. Rick Santorum doesn't even know the argument. Gay people have a choice, really? You (Rick Santorum) also have a choice to educate yourself on the issue at hand instead of spouting off your thoughts like they're fact.