Thursday, April 16, 2009

GIT Rebase

I've recently become a die-hard git convert. I used to use subversion but branches in subversion and always having to be connected gave way to an interest in git. Branches in git are ridiculously easy and I like the fact that I don't have to be connected to save changes. Then I started using git and discovered rebase.

My typical workflow is to work and commit locally and then push up my changes when I have major chunks of work done. I also like to try and keep groups of commits small and related.

Typically though I'll do lots of commits and rebase lets me group related commits. You typically don't want to do rewrite the history (what rebase lets you do) to commits you've already pushed to the server but if you are the only one working on it or are sure it won't screw anyone up, you can --force a push to get your newly rewritten history up.

Now, how do I use it? If I have local changes I'm not ready to commit yet, I first use the 'git stash' command. This creates a temporary branch and stores your changes there. You could create another branch if you want and then switch back to rewrite history, but I find the stash command handy.

Now we do the rebase, in this example, we'll go back 5 commits. 'git rebase --interactive HEAD~5' Of course change 5 to whatever number you want to go back. (A quick git log should give you a good idea of how far to go back.)

From here, you'll get a list of commits, each with the work 'pick', the commit's short sha and the commit message. What I primarily use is pick and squash. Just move the line you want to merge into something else under the commit you want to merge into. Change pick to squash. Now save.

It will then open up your editor and ask you for a new commit message. It will show you both and let you change it. Saving this will rewrite your history. Now you can push up your newly rewritten history. Now to get back the changes you stashed away, simply type: 'git stash apply'

Git is really fast at what it does, even when pushing changes to the server. The only time I've noticed it taking a while was transferring an entire bare repository over a slow ssh connection. (Not really gits fault) Once I get very comfortable with it, I'll create a workflow chart that documents how I use it in hopes that it helps others.

Sunday, March 22, 2009

Bias in the media

It really bothers me to see blatant bias and ignorance in the news. I just read this short article from reuters:

OAKLAND, California (Reuters) - An Oakland, California man killed three police officers and wounded two others on Saturday in two separate shootings that began with a traffic stop and ended with a gun battle, police said.

Lovelle Mixon, 26, was pulled over during a traffic stop in the early afternoon. Mixon, who was wanted for violating parole on a charge of assault with a deadly weapon, opened fire on two officers, one of whom later died, and fled.

Officers found the suspect later that afternoon in an apartment.

When a Special Weapons and Tactics team forced their way in, he opened fire with an assault rifle, hitting three officers, including two who died from the wounds, according to a statement by police in the San Francisco Bay area city.

Mixon was killed in the gun fight, and the officer wounded in the traffic stop is in critical condition.

(Reporting by Peter Henderson, Editing by Sandra Maler)

Ok, now some may read this and think the best thing to do would be more gun control. While it's not stated, there are many phrases that clue you into this. "Gun battle," "opened fire," "assault with a deadly weapon," "assault rifle." Now if after reading this you think there should be tighter gun laws, let's think again.

First the criminal was "violating parole on charges of assault with a deadly weapon." I don't care what state you are from, it's illegal for him to posses a gun. He shot at two police officers, do you still think at this point he cares about breaking yet another law? Do you really think he got his gun legally?

But let's not forget that he opened fire with a rifle at the Special Weapons and Tactics team. I abhor the term assault rifle because really, if you are shooting at someone, any rifle is an assault rifle. The assault weapons ban was based on meaningless components and really seemed to focus on appearance rather than some sort of increased capacity for violence. And while we're on the subject of words and phrases, let's also look at "assault with a deadly weapon." Ummm... aren't all weapons deadly? I mean I think that's part of the definition of weapon. But it sounds so much more horrific than just assault with a weapon.

So how are more gun laws going to affect people like this man from getting guns? There not, just look at prohibition and the war on drugs. People still get drugs despite them being completely illegal. If something has value to someone, they will find a way to get it. In the case of guns, I really think the best defense is to arm as many "good guys" as possible. Then maybe the bad guys will think twice before using a gun for evil.

Thursday, February 05, 2009

Current economic situation

Things have been busy for me lately which is why there has been an absence of posts. I just want to talk for a minute about our current economic situation. There's a lot of talk about why we are in the mess we are in and what to do about it. Being the geeky type, I like to try and use the scientific method to solve problems rather than just go for a feel good measure. So first we must form a question.

I feel the question should be twofold, first what got us into this mess in the first place because as we all know, "those who cannot remember the past, are condemned to repeat it." Plus if we know what causes the problem, we should be able to prevent it from happening again right?

The second question I'm sure you are thinking is how should we fix it? I feel that is too vague, fix what? Let's first define the problem and then we can try to figure out how to fix it.

The way I see the current problem is that unemployment it up, value of the dollar is down and people aren't spending as much money as they used to giving us a low Gross Domestic Product (GDP). So what caused this?

It's hard to say exactly what caused this as there are a lot of variables to consider but I think there are a few things that stand out. Unemployment is tricky so we'll come back to it after we consider the second point, the value of the dollar.

This is an easy one, why is the value of the dollar so low? Because the government keeps printing money. What you say, the government can't just create money out of thin air? Sure they can, what they do is they set a target interest rate. To make the market converge to this rate, the Federal Reserve buys and sells Treasury Securities. By buying up Treasury Bills, the Federal Reserve puts money back into the system, where does Uncle Sam get the money to buy these? They have 2 options, first Tax us to take it from us, not a very popular option because people can only be taxed so far before they've had enough. Secondly, they can just print money on their printing presses. (Both methods are of course illegal for us to do)

Since we are off the Gold standard, the value of the dollar is based on whatever the markets say it is. If there is a surplus of dollars, the value of them goes down. When we were on the gold standard, it basically meant that the US had gold in it's vaults to back up the money it was printing. (The printed money was basically an IOU for gold or silver because let's face it... it's a lot easier to carry around paper than gold)

Ok, so now the dollar doesn't buy you as much as it used to but unless you are in the government, your salary probably hasn't gone up. So what does that cause you to do? We aren't the Federal Reserve so we can't print money, we aren't the IRS so we can't steal it, that means we have to either find a higher paying job or cut back your spending. By not spending as much the GDP goes down.

Also by not spending as much, businesses do not make as much money because people aren't spending as much. Some businesses do better than others but ultimately as people buy less, business can't afford as many employees and have to lay people off. This makes the unemployment rate increase.

Now the above are the first two steps of the Scientific method, state the question and then doing some background research to find a way to create a hypothesis. If anyone got this far, do you think that the hypothesis they would come up with would be print more money by lowering interest rates or taxing the people? Some people feel (because the media and the Government told them so) that the reason for this mess is because of deregulation. So they call for more regulation, more government spending, a newer new deal of sorts. Some felt the new deal was a great success, others (myself included), felt that all the new deal did was prolong the depression and that it was WWII that created the jobs to get us out of the depression. Who should you trust? No one, do some research for yourself. Just remember, some of the legacy programs from the new deal are FDIC, FHA, TVA, Social Security (nothing but a Ponzi scheme), SEC and Fannie Mae.

And for those of you who say this was unexpected, no one could have predicted what happened... take a look at the Austrian School of Economics. Specifically, take a look at one Congressman who has it right. In fact to make it easy for you, one blogger made a nice collection of his works available for you: http://valuefreedom.blogspot.com/2008/05/ron-paul-told-us-so-economics.html. If you want more info on this, visit mises.org.

And it doesn't matter if you are a republican or a democrat or an independent, this is an issue that affects us all. In fact I seem to remember Obama, McCain and Bush all saying the same things about the banking and auto bailouts that most Americans were against. If you disagree with me then fine, everyone is entitled to an opinion, just don't say no one told you.