Git tips

Staging the removal of all missing files

git diff —diff-filter=D —name-only | xargs git rm

best guide i’ve found to delete a file from git history

Remove a file permanently from git

You use filter-branch to replay the whole history with a filter applied (git filter-branch —tree-filter ‘rm -f file_to_immolate’). Then you remove the original refspec saved by filter-branch (rm -rf .git/refs/original). Then you run garbage colleciton to remove the objects that are no longer referenced. (git gc)

And suddenly you’re clean.

Also useful if you’ve been mucking about:¬†Repack/Unpack/Prune/etc…

Trouble adding a foreign key relation to your MySQL table?

Getting weird errors about 1005 and/or 150, “can’t create table #blahblahblah”? Perhaps MySQL can’t find the index on the column in your target table:

http://bugs.mysql.com/bug.php?id=16290

I needed to create an additional index even though my referenced column was the primary key. No idea why yet, but I figured I’d record this.

Learning Python

Amazed to report that, having never created a Python program longer than “hello world” and within an hour of starting, I was able to research and implement a Python script that imports arbitrary CSV files into a sqlite database for more sane analysis. Go Python!

Writing

I’ve been starting to think I should be writing a bit more, and things like this (http://www.copyblogger.com/bad-writing-habits/)¬†keep popping up for me and sparking this feeling even more. I think I’ll use it to help structure my workweek better as well.

Lady Gaga iOKi is currently featured on the app store front page, awesome!

Lady Gaga iOKi is currently featured on the app store front page, awesome!

I know you’ve been wondering for months. (I certainly have.)

PHP’s boolean literals (true and false) are completely case-insensitive. Cool!

easy peasy find big files on linux

du -xakm /|sort -rn|head -500 > bigfiles.txt

This saves (quickly!) a list of the 500 biggest files on your Linux / Unix / Mac OSX system, along with their size in megabytes, and organizes them with the largest at the top. Cool!

It’s saving me this evening - thanks go out to a commenter named georges at http://www.cyberciti.biz/faq/find-large-files-linux/

Drinking Tropicana Orange Juice

And the box says “Contains Orange Juice from the U.S. and Brazil.”

WHAT?

Why is it that food safety rules are so focused on points of failure rather than systemic problems?

What if we mashed the Brazillian oranges _separately_ from the U.S. oranges? Perhaps the inevitable lapses in food safety would be identified and quashed faster than the absurdly broad contaminations we have now that result in the wholesale destruction of tons and tons of food.

Just a thought. One glass of orange juice simultaneously from the U.S. and Brazil, harumph.

Apache RewriteRule weirdness

Phenomenally useful post by a guy named Max Dunn in his blog “Eschew Obfuscation”.

The gist of the usefulness for me:

I thought it was pretty weird behavior until I realized: the .htaccess rules will only be applied to requests for things within the site.com document root, (making the leading slash irrelevant information) whereas the the conf files are potentially server-wide.

Here’s what you’d probably use in each case:

Apache conf file:

RewriteRule ^/(.*)$ index.php?/$1 [L]

.htacess file:

RewriteRule ^(.*)$ index.php?/$1 [L]