One Liner: Cleaning Up Old Git Branches

I am very lazy about deleting local git branches. I just checked and I have 100+ branches! WTF. That makes it a real pain to find the one I was working on yesterday. So first, let me get rid of the ones that I’ve already merged into master.

git branch --merged | egrep -v '(master|develop)' | xargs git branch 

But I still have 58 branches left! Lets try sorting by committer date:

$ git for-each-ref --sort=committerdate refs/heads/ --format='%(refname:short) "%(committerdate:relative)"'

This command gives me a list of branches sorted by commit date. The output looks something like:

BL-1302567-dnp-global-dns "10 months ago"
BL-1311324-scheduled-scale-down "8 months ago"
hackweek-dnp-deploy "4 months ago"
BL-1305305-dnp-secretsmanager "3 months ago"
BL-1311060-dnp-deploy-v2.6.1 "3 months ago"
dnp-breakfix "3 months ago"
BL-1307167-sas-api-elb "2 months ago"
BL-1307165-patch "9 weeks ago"
BL-1307166-sas-dns "8 weeks ago"
BL-1307441-product-project "8 weeks ago"
sas-deploy-fix "8 weeks ago"

Now I can use this to find branches where the top commit is older than a few months

git for-each-ref --sort=committerdate refs/heads/ --format='%(refname:short) "%(committerdate:relative)"' | egrep -v "(master|develop)" | egrep "([4-9]|[1][0-2]) months ago" | xargs -n2 bash -c 'git branch -D $0'

Here I used egrep to remove the master and develop branches as a precaution, then again to select only branches that are 4 “months ago” or older. Then just pass the output to xargs and you’re all set.

WordPress Signal/Noise Ratio

I’ve decided to air some grievances about trends in the WordPress community that have me annoyed. Yesterday, I raised the issue of “freemium” plugins in the WordPress Repository. Today I want to bitch about the #wordpress twitter stream. There was a time when you could follow #wordpress and find real people exchanging ideas or asking questions or linking tutorials. It seems now though the community is a victim of it’s own success. To demonstrate my point yesterday I went through the first 50 tweets and broke them down by function:

34 tweets were directly selling something. And example might be

Visual Themify #Builder #WordPress #Plugin True #Drag #Drop #ThemeBuilder Design. Front- and Backend Design https://link/link

The link in the tweet above actually takes you to a hosting company website which is a bit misleading.

23 tweets were soft-selling. By this I mean they were tweets by a company to a blog post that was indirectly promoting their business or products. This is obviously preferable to the direct sell, but it still has some issues. For one thing, the quality of the content leaves much to be desired. I don’t find an article on “building an ecommerce site” that just lists a bunch of super-obvious steps, “First you need a domain, here’s a link to the domain affiliate that I profit from,” to be particularly valuable.

Only 3 articles had no obvious sales angle. This is a pathetic number. What’s worse is that many of the direct-sell tweets are just repeats of each other. At least 8 tweets ultimately linked back to one theme on the Envato Marketplace.

To be fair some of the issue here is without a doubt an issue with Twitter, not WordPress. And It’s hardly reasonable to expect WordPress to somehow curate the hashtag.

My concern though is that it is somewhat indicative of a trend in the WordPress ecosystem: it’s getting increasingly difficult to separate the cream from the crap.

Idea’s on this would be welcome.

Bash Tips: find your server’s IP address

So in an effort to completely exploit everything I do in my life I’ve decided to start posting simple bash tricks. This has the added benefit of helping me catalog these so I can forget them and always make it back.

Ever need to very quickly find the IP address of the server you are working on???

ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'

Keep in mind that the ‘eth1’ argument may vary depending on your server platform. In most cases eth0 is your private IP and eth1 is your public. But this may not always hold true.

MySQL inspect table sizes

Discovered a database was stupid big? Need a quick break down of where all the junk is? Here’s a quick mysql example to help:

| pt_called_function    |      22428 |     2637824 |            117 |
| pt_file               |          1 |       16384 |          16384 |
| pt_function           |      25295 |     3686400 |            145 |
| wp_commentmeta        |     127659 |   137674752 |           1078 |
| wp_comments           |      35662 |   106528768 |           2987 |
| wp_links              |         24 |     2179072 |          90794 |
| wp_options            |        721 |     7880704 |          10930 |
| wp_postmeta           |     965198 |   112885760 |            116 |
| wp_posts              |     159491 |   444596224 |           2787 |
| wp_term_relationships |     232723 |    13156352 |             56 |
| wp_term_taxonomy      |        753 |       81920 |            108 |
| wp_terms              |        791 |       81920 |            103 |
| wp_usermeta           |      21783 |     1589248 |             72 |
| wp_users              |       2237 |      475136 |            212 |
| wp_w3tc_cdn_queue     |          0 |           0 |              0 |

WordPress freemiums getting a little out of control

I’ve spent the last two 2 – 1/2 years working for WP Engine and Pantheon, both managed hosting solutions for WordPress. And it’s been nearly that long since I’ve actually built a site using it.

Weird I know. But I generally just do straight PHP these days and lately I’ve been playing around with Drupal some. 

This weekend I taught a short workshop in Petaluma about building sites with WordPress. Needless to say, I spent time last week building a couple of different test sites and experimenting with some newer plugins I had not used before.

Biggest takeaway? The whole “freemium” plugin marketing explosian might be getting a little out of hand. I totally get why people do it ( heck I did it for a while ),  but it’s an awful user experience to have every single plugin you install try to sell you an upgrade. 

If WordPress is going to continue to allow freemium marketing in their repository I think there should be some agreed about conventions about where those ads should be. For instance, a ‘nag’ on the settings page is ok, but on every admin page not much.

Is it me ?

Stuck in time

<p>It happened imperceptibly. I just started listening to old 80’s and 90’s tracks. Some Pixies here, a smattering of Depeche Mode and The Cure there. Then it was deep dives into all the old albums. Doolittle, Psychocandy, Disintegration, Bleach. On Spotify I built a playlist of hundreds of songs from the before 1996. Then I found it was all I was listening to. I started wearing baggy jeans again. No Doc Martins, but the clunkiest shoes I own. I spotted a flannel at the local consignment, bought it. Combed my hair down in my eyes. Complained about corporate rock. Bought a 3-foot metal chain for my wallet. Pierced only my ear … left ear … or right, can’t remember.</p>

Tech companies paying you to have kids … later

This kinda creeps me out a litttle: Apple and Facebook Pay for Female Employees to Freeze Eggs I’m not really sure why exactly. I suppose any “benefit” a company provides is a good thing, so I’m all for it. But it just kinda stinks of “Hey, why have kids now when you can put it off indefinitely?”. And since shareholder corporations generally act in their financial best interest, I’m curious what the angle is. Have they done the math and decided this will lead to fewer pregnancies on company time and so it’s worth the expense? Not that anyone should be having children mind you. They’re disgusting little germ traps!