tech Archives - Schimmy's Thoughts http://colinschimmelfing.com/blog Tue, 22 Oct 2013 05:54:07 +0000 en-US hourly 1 https://wordpress.org/?v=5.9.4 65375801 Git’s empty tree /blog/gits-empty-tree/ /blog/gits-empty-tree/#comments Sun, 06 Oct 2013 18:15:17 +0000 /blog/?p=19 It’s late. You’ve been coding up a greenfield project and it needs to be done by tomorrow. Yes, the team could have gone with a similar tool that has some of the necessary features, but damn, that thing written in PHP! This is your chance to write a totally new project and to show the company that python/ruby/go is the future. I mean, PHP, really? No, didn’t think so. Ok, ready for reviewboard. diff --full-index --oh-crap-you-forgot-to-make-an-initial-commit Oops. This is dumb....

Read More Read More

The post Git’s empty tree appeared first on Schimmy's Thoughts.

]]>
It’s late. You’ve been coding up a greenfield project and it needs to be done by tomorrow. Yes, the team could have gone with a similar tool that has some of the necessary features, but damn, that thing written in PHP! This is your chance to write a totally new project and to show the company that python/ruby/go is the future. I mean, PHP, really? No, didn’t think so.

Ok, ready for reviewboard.
diff --full-index --oh-crap-you-forgot-to-make-an-initial-commit

Oops. This is dumb. You can’t believe you forgot to do an initial commit, and your first commit was only after 2 hours of work- totally useless to your coworkers… Damn it, why didn’t you create an alias for git init?

Here’s my stream-of-consciousness from solving this one:

Hmm- if only there was a way to diff against a totally empty commit, a magic empty git repository…

Well, how about we check out the first commit in the internals of git:

> cat .git/logs/refs/heads/master
0000000000000000000000000000000000000000 a7726d5201b0e56bf6e15e9ed72ea42192013d09 Colin P. Schimmelfing <theboss@colinschimmelfing.com> 1369722239 -0700 commit (initial): adds money-printing functionality to our app. biz-dev should be happy

those zeros look good as some sort of magic original empty commit… lets try that:

> git diff 0000000000000000000000000000000000000000
fatal: bad object 0000000000000000000000000000000000000000

Nope, no go.

What if we init a new repo and see what a blank repo is like:
> git init test2
Initialized empty Git repository in /Users/cschimmelfing/code/blog/empty_git/test2/.git/
> cd test2
> git show
fatal: bad default revision 'HEAD'
> git log
fatal: bad default revision 'HEAD'
> cat .git/logs/refs/heads/master
cat: .git/logs/refs/heads/master: No such file or directory

Damn, no commits means normal ways I’d look at the repo are pretty useless. Looking elsewhere in the .git directory gives just as little insight.

At this point, you hit up stackoverflow, and when I ran into this problem I was able to find a few items mentioning the magic commit I was looking for. (From this thread or this Stack Overflow post)

drum rolllllllll:

4b825dc642cb6eb9a060e54bf8d69288fbee4904

Huh. Well that’s random.

> git show 4b825dc642cb6eb9a060e54bf8d69288fbee4904
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
(END)

Well, let’s try it out:
diff --git a/test1.txt b/test1.txt
new file mode 100644
index 0000000..95f29d0
--- /dev/null
+++ b/test1.txt
@@ -0,0 +1 @@
+hi HN
(END)

So now you are thinking: “Colin, that looks good, but where does this magic hash come from?”

Well, we can see that it’s a tree, so let’s try:

> git init test2
Initialized empty Git repository in /tmp/test3/.git/
> cd test3
> git write-tree
4b825dc642cb6eb9a060e54bf8d69288fbee4904

Aha! there it is, the hash is simply the value git creates when you ask for the hash of an empty directory. For more on this, check out this breakdown on the internals of git .

In both of the links that mentioned the special hash, it looks like there is another way to find the magic value, a little faster:

> git hash-object -t tree --stdin < /dev/null
4b825dc642cb6eb9a060e54bf8d69288fbee4904

So there we go! A little window into the internals of git, and a useful trick. If you don’t use review board (or always remember to touch an empty README, etc), you may also find it useful in other contexts, for instance creating a patch that can recreate the whole repo. Yes, you could tar the whole repo up, but maybe there are some embarrassing commits you’d like your colleague not to see, or a FUBAR-ed history that you might want to totally nuke before starting to collaborate.

Of course, this is git, so there are probably three other ways to do the same thing. Please comment, internet points will be awarded to the best answer!

The post Git’s empty tree appeared first on Schimmy's Thoughts.

]]>
/blog/gits-empty-tree/feed/ 2 19
Youth, State Overreach, and Golden Handcuffs /blog/youth-state-overreach-and-golden-handcuffs/ /blog/youth-state-overreach-and-golden-handcuffs/#comments Wed, 12 Jun 2013 07:19:33 +0000 /blog/?p=39 Uninvested As the tech community digests the news related to state surveillance and its overreach in protecting its secrets, many comparisons will be made between Edward Snowden’s situation and those before him. The most obvious is with Bradley Manning, locked up and tortured (as considered by the Geneva Conventions) by his own government for revealing its secrets. Mr. Snowden is rightly concerned that, by staying within the jurisdiction of the U.S., he would be tortured and denied both due process...

Read More Read More

The post Youth, State Overreach, and Golden Handcuffs appeared first on Schimmy's Thoughts.

]]>
Uninvested

As the tech community digests the news related to state surveillance and its overreach in protecting its secrets, many comparisons will be made between Edward Snowden’s situation and those before him. The most obvious is with Bradley Manning, locked up and tortured (as considered by the Geneva Conventions) by his own government for revealing its secrets. Mr. Snowden is rightly concerned that, by staying within the jurisdiction of the U.S., he would be tortured and denied both due process and a jury by his peers. Similar injustice has visited Aaron Schwartz for attempting to ‘liberate’ academic research to the community- threats of decades in prison or a total capitulation to the authority of the state.

Why is it that the most powerful entity on earth currently endures comparison to North Korea, the Stasi, and 1984 over disclosure of an already legal process? Why did the government hound to death an otherwise straight-laced idealist over a non-violent property crime? For what purpose?

Many news outlets have commented on how young both Bradley Manning and Snowden are. From a Washington Post article:

“Legal experts closely following both cases said they were shocked to find out young, low-ranking people had such access to powerful government secrets. Manning was 22 when he turned over the military and diplomatic cables about three years ago; Snowden is 29.”

Other pundits ruminate on how it was that the NSA and the DOD could entrust so many secrets, so much power, into the hands of people like that?

Of course, what they really mean is: “How could they place so much institutional power into someone so unfettered by and uninvested in the system?

Why can’t they find someone who has steadily worked his way up the ladder, owes a hefty mortgage every month and worries about getting his kids into and paying for Princeton? Someone who has repeatedly and consistently demonstrated that, when confronted by uncomfortable information, all he does is take a long weekend to a bed and breakfast with his wife in rural Maryland?

(Granted, even some of the other recent whistleblowers have had this more ‘traditional’ profile, but in this post I am trying to explain why the three-letter-agencies (TLAs) have had to branch out from that more ‘safe’ profile of agent)

Don’t think the TLAs haven’t been trying. Unfortunately for them, skills in the technologies they need to master to keep up simply are in very short supply compared to the demand created in all sectors of the government for technical talent. The effects of this skills shortage are clear in Silicon Valley, but can also be seen in the areas in and around D.C., with similar complaints and concerns.

The bottom line is this: the TLAs need the capabilities offered by new technology to keep a handle on the (to them) terrifying unstructured and unaccountable realm of the internet. They must then accept that individuals providing these capabilities are going to be less vetted and less traditionally (aka financially, reputationally, and culturally) beholden to the organization than is normal. Therefore, new means of compelling silence are required. The TLAs have chosen physical fear (prison and torture) as this means, as they lack the financial and reputational pressure they are used to.

Until the TLAs can start ignoring young, un-beholden technical agents, we should expect unyielding, physical punishment of any whistleblower matching that profile. Edward Snowden was smart enough to understand this- there is a reason he is halfway around the world from Fort Meade right now.

So what does this mean for me?

One interesting difference about Snowden is that he seemed invested in the system. $200k a year salary, living in Hawaii with a girlfriend – sounds like he wouldn’t do anything to jeopardize that. However, from this New Yorker article it sounds like Snowden was actively conscious of the golden handcuffs that were tightening around his wrists:

“Snowden seems to have worried about being too content: he was, after all, a young man with a G.E.D. earning two hundred thousands dollars a year in Hawaii.”

It is interesting to wonder if, another few years down the line he would have been too content with his easy life to throw it away for our benefit.

The same golden handcuff strategy applies to the financial industry, where firms will even extend loans to their employees to help increase the employee’s dependence on that steady paycheck.

One could argue that the practice of granting stock options as part of your salary, instead of just paying cash, is another way that organizations coax individual interests into alignment with the institution’s interests. This is a little more complex, as there is true benefit to both parties. Most people who do have options, however, probably discount the gravitational strength of those options in swaying their convictions. How many Apple employees after receiving stock have transitioned from thinking that “tax dodging is shameful, but I suppose Apple must keep up with everyone else” to “we are great at finding loopholes- the tax rate should be lower anyway. If others can’t do the same, they are just not smart enough”?

Again, this is more complex, and in full disclosure I often trade salary for options. However, I don’t think that many understand the pernicious, subtle effect these golden handcuffs have on an individual’s worldview. In any case, to truly address this issue would require another entire blog post.

The ‘take-away’ lessons for individuals here are simple:

  1. Always be indispensable to the TLAs of the world, and never let any one organization (or even industry) become indispensable to you.
  2. Institutions always try to align individuals’ mores and interests with their own. Golden handcuffs are a very effective way of doing this
  3. If you want to maintain your independence from organizations, beware golden handcuffs. At the very least, understand the transaction you are entering when accepting them and ensure that you don’t leverage your way into violating #1.

The lessons for the TLAs of the world are a little harder, but there’s at least one clear lesson: Don’t base your power on a secret. Secrets have a terribly short half-life.

Last thoughts

I think there is a lot of hope to be found in this whole affair. The most relevant to this post relates to the Upton Sinclair insight that “It is difficult to get a man to understand something when his salary depends upon his not understanding it”. Edward Snowden has proved that ‘difficult’ does not mean ‘impossible’, as much as the NSA wishes otherwise.

The post Youth, State Overreach, and Golden Handcuffs appeared first on Schimmy's Thoughts.

]]>
/blog/youth-state-overreach-and-golden-handcuffs/feed/ 1 39