Half-Elf on Tech

Thoughts From a Professional Lesbian

Author: Ipstenu (Mika Epstein)

  • Git: Combining Your Messy Commits

    Git: Combining Your Messy Commits

    Sometimes I end up making a lot of commits while I’m working on a branch in order to get the code right. It mostly happens when I’m going back and forth between my new branch and the old (live) one to double check some code that I think got lost. It happens when changing theme structures.

    However. This left me with a conundrum. I had about 100 commits and really it was going to be the messiest pull request ever. Which I didn’t want.

    One Branch to Rule Them All

    In order to fix this, finished up all my errant commits, as messy as they were, and then I went back and checked out the clean development branch (named development). Since everything was up to date, I went and made a new branch.

    That gave me three branches:

    1. development – The actual dev branch
    2. messy-dev – My super messy branch
    3. clean-dev – My clean branch

    Of course, nothing of mine was actually in that clean branch.

    One Branch to Find Them

    Once I switched to my new branch ( git checkout clean-dev ) I imported my old branch with this: git merge --squash messy-dev

    Yep, that was it. I then went though all my regular checks, made sure the code was working, did a few more fiddly changes, and then I ran a git commit to run the last pull.

    This gave me a commit message filled with … well … this:

        Merge branch 'development' into messy-dev
    
    commit 6c7534b9f7eabb5db59a85880bbf42ff2b982d84
    Author: Mika Ipstenu Epstein <ipstenu@ipstenu.org>
    Date:   Sat Sep 23 19:47:27 2017 -0700
    
        Cards again
    
    commit 9fe21f380a1befcbbe34a79937399b679c31c06f
    Merge: 0362bb5 14b4fab
    Author: Mika Ipstenu Epstein <ipstenu@ipstenu.org>
    Date:   Sun Sep 24 18:08:18 2017 -0700
    
        I hate Sara Lance so much!
    
    commit 0362bb5a289e2694bd4872137ad470091529021d
    Author: Mika Ipstenu Epstein <ipstenu@ipstenu.org>
    Date:   Sun Sep 24 17:57:33 2017 -0700
    

    One Branch to Bring Them All

    Don’t worry. I didn’t keep that. In fact, I’d been writing a log of the entire work, listing out what was changed, fixed, added, deleted, etc. So I deleted that entire commit message and pasted mine in it’s stead.

    Well written inline documentation is one thing, but a good commit message saves lives. Since I planned to submit this as a pull request, I knew I had to have a good, simple, commit that listed things that had changed.

    But there also had to be more…

    And In The Pull Request Bind Them

    I’m rather pedantic about all that and wrote about 500 words to explain what all the code was in that Pull Request. Since I’m working with other people, and I’m not the lead developer on this project, I know not to commit my changes to the dev server right away.

    Instead, I made a pull request with a repeat of data in my commit, but also a different and more detailed explanation. A pull request has to explain why the work was done and why the pull is needed.

  • LGBT+Allies At WordCamp US – 2017

    LGBT+Allies At WordCamp US – 2017

    Yet again, Tracy and I have gone a little insane and we’re throwing another fabulously big queer party at WordCamp US. This year the venue is Nashville, which made an interesting turn as Tracy’s in Philly and I’m in SoCal. We drafted some local help and, after a series of emails, phone calls, and one text in all caps, we are happy to announce our second ever LGBT+ Party.

    Friday, December 1, at Suzy Wong’s House of Yum.

    Grab your tickets now before they’re gone!

    And we’re still looking for sponsors to cover the cost of the food and drinks, so please contact us if you’d like to chip in.

    Back for the second amazing year is the faaaabulous LGBT+Allies Meetup for WordCamp US!

    WordPress as a community has been welcoming and inclusive to people of all backgrounds, sexual orientations and gender identities. To celebrate our wonderful diversity, we’re bringing the party to Nashville, for an evening of honky tonking at a brothel of epicurean delight.

    This year, the party will be at Suzy Wong’s House of Yum, located in the heart of Nashville’s trendiest alternative night life scene. Suzy Wong’s House of Yum is a creation of Chef Arnold Myint (and his alter-ego Suzy Wong). Prepare yourself for a cornucopia of vegetarian friendly Asian delights, creative cocktails, sleek décor, and of course seriously campy music.

    We will have the entire venue to ourselves with delicious food and drinks!

    But we wouldn’t be able to bring you all this without the help of our amazing sponsors. In 2016, thanks to the help of our sponsors we not only had a private room, but drinks, food, and amazing exclusive t-shirts. The event is fully funded by the community, and all help is welcome.

    Venue Sponsor: DreamHost

    Sponsors

    If you would like to support the community and sponsor this event, please contact us.

    We hope to see you there!

  • Targeting Ads

    Targeting Ads

    Selling things on your website isn’t a strange concept. A lot of people have sites where they want to do that if only to break even. And most people do it with generic ads. When, for whatever reason, Google and such aren’t a viable option, it’s time to consider targeting your advertising a little pragmatically. Or rather, more specifically.

    Take Aim At Your Content

    One of the reasons Google Adsense is so popular is that it claims to target your readers for you. It does the hard work and you can just walk away. But the reality is that it’s targeting your readers based on their search patterns, not necessarily based on your content.

    Now. Google does target ads based on content. However it’s not the way I felt would make the most sense. You see, when I think about content targeted ads, I would think “this post is about bicycles, I should have ads about bicycles.” What actually happens is you get some bicycle ads and then some ads for table wax, because you were shopping for that earlier in the week.

    Advertisers over Content

    The problem arises in prioritizing advertisers over readers. It’s one of those peculiar paradoxes. Ads are made by people to make money. They pay you to put them on your website. But that only works if the people who visit your website click on their ads and buy their things. That means it’s more beneficial for advertisers to aim at the visitor directly than via your website’s content.

    Most people don’t actually go to their ad preferences on Google and fiddle with their personal preferences, so the default ads are always going to be based on everything. Since some people have weird interests, the ads on your site might be geared towards beds instead of bicycles.

    Taking Control

    If your goal is to have fewer generic ads then the only solution is to take charge of what ads are on your site. And that’s work. Not many of us have the time to pick our ads every single day, and even if we did, we’d be set with the ones offered to us. I’ve used Project Wonderful before, and it lets you pick what ads you show. But only from the ones that submit to your site.

    The next choice is cherry picking ads from what’s available on a service like Amazon’s Associate Program. That shows you all of Amazon’s available bounties and promotions, which you can put on your site and leave them alone. Some even last ‘forever’ so you don’t have to worry about expirations.

    More Control?

    Of course, there’s also the work of adding individualized ads on each page, for the product you’re talking about. But that is another post.

  • Make WordPress Gay

    Make WordPress Gay

    In September, WordPress.com changed their admin bar from the normal black or blue to a rainbow color. Why?

    Australia will be holding a national survey on marriage equality over the next two months. To show our support as a company for marriage equality, we’re showing the rainbow bar in the WordPress.com admin bar to all logged-in Australian visitors. You can read more about the marriage equality campaign here: http://www.equalitycampaign.org.au/

    And this was super cool. They’d done it before when Gay Marriage was legalized in the US and it’s much appreciated as a show of solidarity. But… The menu bar only shows if you’re visiting WordPress.com from Australia. This causes two problems for me:

    1) I’m in the US
    2) I self host

    Don’t worry, there’s a solution.

    The ‘Official’ Solution

    The code for what WordPress.com does can be found on the Github repository for Calypso. But that’s all mixed in with a lot of extra ‘stuff’ that has to be there for their services, like geo-location and so on.

    The rest of us don’t need that, and since Gary (the fellow who wrote the ticket) is a friend of mine, I asked him if the code was available. It is.

    Rainbow Bar Code

    <?php
    
    /*
     * Plugin Name: Rainbow Bar!
     */
    
    function rainbow_bar() {
    ?>
    	<style type="text/css">
    		#wpadminbar {
    			background: linear-gradient(
    				to bottom,
    				#e24c3e 0%,
    				#e24c3e 16.66667%,
    				#f47d3b 16.66667%,
    				#f47d3b 33.33333%,
    				#fdb813 33.33333%,
    				#fdb813 50%,
    				#74bb5d 50%,
    				#74bb5d 66.66667%,
    				#38a6d7 66.66667%,
    				#38a6d7 83.33333%,
    				#8c7ab8 83.33333%,
    				#8c7ab8 100% );
    		}
    
    		#wpadminbar,
    		#wpadminbar .quicklinks > ul > li {
    			-webkit-box-shadow: unset;
    			-moz-box-shadow: unset;
    			box-shadow: unset;
    		}
    
    		#wpadminbar .ab-top-menu > li > a {
    			background-color: rgba( 50, 55, 60, .85 );
    		}
    	</style>
    <?php
    }
    add_action( 'wp_before_admin_bar_render', 'rainbow_bar' );
    

    Install that to get this:

    Rainbow Pride WP Admin Bar

    Small Changes

    In order to make it look ‘right’ for me, I changed two things

    I removed this:

    	#wpadminbar .ab-top-menu > li > a {
    		background-color: rgba( 50, 55, 60, .85 );
    	}
    

    And I added this:

    	#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon,
    	#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
    		color: #000;
    	}
    

    Caveats

    Even with my changes, the color for my Jetpack stats looks wrong. It’s too washed out. And that’s because it’s apparently hardcoded into the plugin in a way I can’t overwrite. I can live with that problem.

    The other issue is that this will only show for logged in users (unless you’re using some code to always show the admin bar). That begs the question, of course, of why would you do this if only logged in users?

    If you’re running a queer themed website that happens to use WordPress … like, say, Autostraddle, then this makes perfect sense. For me, it just makes me feel happy to see that pride rainbow all the time.

  • Plex + Roku = TV

    Plex + Roku = TV

    I’m really trying not to add new devices to my life. I picked up a Roku last year so that I could watch CBS’ internet TV on my regular TV. I chose that instead of the Amazon or Apple TV because the Roku also let you add ‘apps’ for regular TV channels (SyFy, Freeform, PBS) and if I missed a TV episode due to travel, I could watch it on the big television.

    Then I wanted to play some shows that I’d saved as MP4s from my laptop to my TV, without a new device like a Chromecast.

    The solution was Plex

    Plex is a media server you can run on your computer that lets you add all your media, even things that don’t exist in iTunes, and organize them sanely. You can manage it in your web browser (or command line) and while you do have to have an account with Plex the service, you don’t have to pay or sign up for any of the services.

    If you have an Apple TV or an Amazon Fire you can use those too, but I used my Roku, added my media, and boom. Watching videos I own from my laptop on my TV.

    A couple caveats:

    1. If you download MP4s from cough torrent cough places, you’ll need to get their subtitles too.
    2. TV show files need to named SHOWNAME - S##E## - EPISODENAME.EXT to work properly.

    It’s not perfect, but it’s better than trying to watch TV on your computer.

  • Admins Are Humans Too

    Admins Are Humans Too

    This conversation happens often enough that I've ceased to be mind boggled by it. A developer will submit code, I review it, and I'll tell them to please sanitize the input. Instead of just using the functions, they'll come back and ask why? Invariably they'll point out that they're using nonces to make sure only authorized actions can happen (no cross site scripting), and they're checking user permissions too, limiting access to only admins. So why am I being pedantic? My default reply:
    Admins are humans. Humans make mistakes. Computers do exactly what they're told to do. 

    Admins Are Humans

    I'm often a broken record, telling people to sanitize, validate, and escape. When people ask me which sanitize function to use in WordPress, I play Socrates and walk them through the logic process. What kind of data are you saving? What will it look like? Okay, now what of these looks the most appropriate based on their descriptions? Sanitizing data is contextual. By this I mean we sanitize for what the saved data should be. If you're saving an email address, make sure you sanitize for email and so on. This has a side benefit of helping validate your data as well. If you check that the email address entry actually is an email, you're both sanitizing and validating. Now you've prevented someone from putting in a domain instead of an email!

    Humans Make Mistakes

    The details of 'best practices' for coding change often, as we learn about how to make code safer and smarter. That said, the ultimate best practices have nothing to do with the language you're writing in, the app you're writing for, or even the platform!
    • Restrict access to only the people who need it
    • Sanitize and validate the data you're given
    • Provide helpful error messages
    • Test your code with good and bad data
    • Document what the code does and what the errors mean
    Those practices transcend every single minutia of programing. If you do those five steps, your code will be robust, sane, and safe. Because you will have taken the steps to ensure that humans can make as few mistakes as possible. You don't save 'Dog' when true/false is the only valid answer.

    Computers Do What We Tell Them To Do

    The real problem is that AI doesn't exist.
    Source: CommitStrip.com
    Computers can't think for themselves, and humans have a tendency to stop thinking at weird moments (or just go on auto-pilot) which means nothing can destroy work faster than a human. And since a computer does what it's told, the most dangerous computer tool is the one that doesn't account for how big a mistake a human can make.

    Sanitize, Validate, Escape

    Especially when it's an admin.