Half-Elf on Tech

Thoughts From a Professional Lesbian

Category: How To

  • ZOMG! You Stole My Code!

    ZOMG! You Stole My Code!

    While the GPL is pretty clear about this, and my personal moral code is as well, the topic today is not about the question of is it right to resell someone else’s work, but what do you do when someone’s reselling yours?

    This happened to my friend not too long ago. Someone else took her theme and was reselling it and you either already know who it is or you don’t, it doesn’t matter for the sake of this story. Now, the issue was not if they could resell it, we all agreed they could. The issue was how they resold it. That is, they took her images, much of her ad copy, and resold it, presenting it as if it was their own code. And that was, we all agreed, wrong. That’s fraud, in my eyes. You’re taking someone else’s work and claiming ownership of it. But. That wasn’t my fight, it was my friend’s, and all I could offer was some moral support and connections.

    But when this happens to you, what do you do?

    The Hulk, right after he punched Thor in First, don’t type angry. It’s okay to type while you’re mad, but if you’re like me, and your skin heats up when you’re angry and you get all green and violent (I type really loudly), it’s probably a good moment to step back and think about why you’re angry. After all, GPL says this is allowed, right? I get mad because of perceived ownership. It’s one of my things. You should never claim to be something you’re not and you shouldn’t sell something that isn’t yours.

    And that’s the angle I’d use to approach the situation. I would find the person, ping them privately if possible (almost everyone has a contact page these days) and ask them if they could change the wording to make it clear that this isn’t their code, it’s mine, and they’re using and providing it without the support of the original author. That’s what my friend did, and that’s also what the other people whose themes were being resold did. They pointed out that the reselling was confusing to the customers, and the customers got an unlicensed product.

    What if that fails? Well. Now it’s messy. Legally if they’re taking my content and putting it up on their site with verbiage that implies it’s theirs, I have a DMCA takedown right. My content is all under copyright (I have not, nor will I any time soon, chose to go copyless) and I use the CC BY-NC-SA 3.0 license, so if you use my content, wholesale, without attribution, you’re stealing. But this isn’t about my content, it’s my code, and all my code is released GPLv2 (unless otherwise noted). That means in order for me to come up and tap your shoulder, you have to take my code and my content.

    Dollar SignBoy this got complicated. But if I ping you and say “Hey, bro, not cool.” and you ignore me, or tell me to sod off, I’ll come back and ping your webhost. “Hi, this guy is stealing my content. I asked him nicely to stop. Here’s a copy of our conversation.” I should note, none of the times I’ve ever had to do this have gotten past this step. The hosts have always stepped in, poked the perpetrator, and that was that. The times I was the bad guy (reprinting news articles), the content owners have only ever had to ask me to take it down. It’s never gotten past me.

    Well okay, so what happens if the host says “Tough luck” or “We agree, but we can’t do anything without a takedown notice.” Now you bring in the law and file a DMCA (Digital Millennium Copyright Act) take down. DMCA is a U.S Copyright Law covering intellectual property. Your blog posts and ad-copy are your intellectual property. This went to a pretty dark place, didn’t it? I mean, I hate the DRM with a passion, and I freely give away my stuff, so let’s stop talking about the legal stuff. You can look it up on your own if you really want to know how to file all that.

    Most of the ‘handling’ of someone who steals your stuff isn’t even the legal hassle, anyway. It’s just the pain of getting in touch with them, explaining the situation, and getting it sorted. And the headaches come from having to explain over and over that you’re not mad (though you probably are) and you just want them to stop making it look like they’re you, please and thank you.

    Okay, so how might I justify selling someone else’s theme or plugin? I would sell a service. It’s really that simple. I would sell the downloading, installing, configuring, and tweaking of the product. I would charge them the raw cost of the product AND give them the license information (it’s their now). I may charge them for some ‘placeholder’ text to import via the WP importer, and to import it. Certainly I would charge for some training on how to do this going forward. But the thing I wouldn’t do is actually say “This is our plugin” or “This is my theme.” Because it’s not.

    I’m just making sure you can have the theme better, faster, and easier. Plus now they can upgrade and I can go to Fiji!

  • Migrating A WordPress Site With wp-cli

    Migrating A WordPress Site With wp-cli

    This is … crazy simple. I wanted to move a site from ipstenu.org to ipstenu.com (yes, I own that too). While ipstenu.org is a Multisite network, ipstenu.com is where I put a ton of add-on domains. I was moving a site over and, as it was WordPress, did it in a matter of minutes.

    Add the domain to the … domain

    Since I don’t care to have multiple hosting accounts, and I’m the only one with SSH/FTP access, it’s safe enough for me to do this. There is a risk when you share multiple domains in one hosting account, that if one gets hacked they’re all vulnerable, but I consider it low in my situation. Every plugin is vetted, every file is checked, and then I went and gave each add-on it’s own FTP account. Neurotic? Thy name is me.

    Anyway, I add the new domain to my hosting where I want it.

    Create the new DB

    I have to make a new database, and generally a new DB user, on the server too.

    Export!

    On existing hosting, I do this:

    wp db export
    

    That gives me my SQL file, thanks to WP-CLI. It’ll be named example_com.sql and will sit in my folder with .htaccess and everything else.

    Copy!

    I do it via SSH. I go to the new location and run this:

    scp -r olduser@example.com:path/to/files/ .
    

    Since I have ssh keys set up, it’s easy. If I don’t, I’ll put in the password, but that’s straightforward.

    Edit wp-config.php

    Now I have to point to the new DB. Sometimes I name it the same, but usually I don’t, so I’ll edit the DB name, DB user, and password.

    Import the old DB

    Ready?

    wp db import example_com.sql
    

    Boom. It’s all dumped in! Only two steps left!

    Search & Replace

    I love this one.

    wp search-replace example.com newexample.com --dry-run
    

    I ALWAYS dryrun test it. This is a serialization safe search, so rarely is it ever going to be an issue to just run, but it lets me make sure I don’t get any wonky results. I never have, so re-run without dry-run.

    Cleanup!

    Delete the SQL file, delete the old files on the old server.

    Drink

    El Chorro Margarita

    I moved code. That’s shipping, right? Or is it margaritas are for migrations?

  • Embedding Videos from TVGuide

    Embedding Videos from TVGuide

    This one goes out to my fellow fansites.

    TV Guide LogoThere are a lot of you guys who use WordPress (probably that’s my fault) and like me, you bash your head in when a news source makes a video embedable, but only if you use their code. Why is this a problem? Most of us like using WP’s visual editor, and that means we have to switch to text mode, paste this in, and then never ever ever visit that page in the visual editor again:

    <script src="http://player.ooyala.com/player.js?width=600&amp;amp;video_pcode=VlajQ6DTdv9-OYPHSJq6w4eU0Bfi&amp;amp;embedCode=NwdzM3aDp4BB3-MEdPemlMJK5XH7ZVdn&amp;amp;height=337&amp;amp;deepLinkEmbedCode=NwdzM3aDp4BB3-MEdPemlMJK5XH7ZVdn"></script>
    

    Augh!

    In part this is because WordPress uses TinyMCE for editing GUI-like, and switching between visual and text mode kills things. But on the other hand, how come we can just paste in a YouTube URL and that works? Well it’s a magical thing called Embeds, and basically WordPress sees that URL for YouTube and knows “OH, I should be a video and YouTube has a special code on it’s sever to tell me how to display it! Yay!”

    Not everyone has that. TV Guide, CBS, etc. I’m looking at you. Where this makes sense is where they do not want you to embed a video because they want the traffic to themselves, which is fine. We can link. But where it’s daft is when they make it embeddable, give you that link, but it’s flipping ugly and can’t be used in the visual editor!

    For TV Guide, at least, there’s a fix. Ooyala Video Browser.

    While the search function doesn’t work ‘great’ right now, probably because I’m searching for their videos with the wrong keywords, but still I was able to embed a video like this:

    [ooyala code="NwdzM3aDp4BB3-MEdPemlMJK5XH7ZVdn" player_id="undefined"]
    

    The ‘code’ is the ’embedCode’ from the embed they gave me before.

    I can also use this:

    [ooyala code="NwdzM3aDp4BB3-MEdPemlMJK5XH7ZVdn" player_id=&"VlajQ6DTdv9-OYPHSJq6w4eU0Bfi"]
    

    Using ‘video_pcode’ for ‘player_id’

    So this wasn’t super obvious, and personally I would love it if Ooyala had an oembed and then a ‘share this on WordPress’ link for things, but seeing as Automattic (and Pete! Hi Pete!) helped with the plugin, this may be as good as it gets for now. Maybe they could marry it into the Media Uploader, below ‘Insert from URL’ – have ‘Insert from Ooyala’. Dreams. I haz them.

    There’s a lot to this plugin that I didn’t need, though. After all, since I don’t have an account, I don’t need all the search stuff, so I stripped it down to just this (which is an mu-plugin):

    /**
     * Ooyala Shortcodes
     * Usually for crap like TV Guide
     * Example: [ooyala video_pcode="VlajQ6DTdv9-OYPHSJq6w4eU0Bfi" width="222" embedCode="NwdzM3aDp4BB3-MEdPemlMJK5XH7ZVdn"]
     */
    add_shortcode( 'ooyala', 'ooyala_shortcode' );
    
    function ooyala_shortcode( $atts ) {
    	extract(shortcode_atts(array(
    		'width' => '500',
    		'video_pcode' => '',
    		'embedcode' => '',
    		), $atts
    	));
    
    	$width = (int) $width;
    	$height = floor( $width*9/16 );
    		
    	if ( !is_feed() ) {
    		$output = '<script src="http://player.ooyala.com/player.js?video_pcode='.$video_pcode.'&amp;width='.$width.'&amp;deepLinkEmbedCode='.$embedcode.'&amp;height='.$height.'&amp;embedCode='.$embedcode.'"></script>';
    	} elseif ( $options['show_in_feed']  ) {
    		$output = __('[There is a video that cannot be displayed in this feed. ', 'ooyalavideo').'<a href="'.get_permalink().'">'.__('Visit the blog entry to see the video.]','ooyalavideo').'</a>';
    	}
    	return $output;
    }
    

    And that is that!

  • Not The Bug I Expected

    Not The Bug I Expected

    “Comments aren’t working,” he said and I winced. I hate when people say ‘broken’ or ‘not working’ because I don’t magically know what they mean by ‘working.’ But this guy was a coworker whom I like and trust so I asked what he meant by not working, and he said “When you enter a comment, the page reloads, but there’s no comment.”

    “Okay,” I muttered to myself. “Touché, Mika.” Because that, indeed, was ‘not working.’ We turned on debugging and got a strange error:

    WordPress database error: [Duplicate entry '0' for key 'PRIMARY']
    INSERT INTO `wp_comments` (`comment_post_ID`,`comment_author`,`comment_author_email`,`comment_author_url`,`comment_author_IP`,`comment_date`,`comment_date_gmt`,`comment_content`,`comment_karma`,`comment_approved`,`comment_agent`,`comment_type`,`comment_parent`,`user_id`) VALUES (507,'lori','admin@example.com','','12.248.40.138','2014-02-07 23:07:08','2014-02-07 23:07:08','test',0,'1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:26.0) Gecko/20100101 Firefox/26.0','',0,1)
    

    And then it was a mess of ‘Trying to get property of a non-object…’ and ‘headers already sent.’

    After some kicking of the usual suspects (reinstall WP, remove plugins, theme, etc) I realized I was stupid and the problem was that the table wasn’t updating the primary entry. It should start at 1 and move up to 2 and so on. Since everything else was working, I compared the table to a working one … and they were not the same. Here’s a good one:

    Example of good wp_comments table

    There’s had comment_id as the name, and the rest of the values were blank. So I restored the values and it worked! Except … I was getting a new error.

    Notice: Undefined property: stdClass::$comment_ID in /home/wp-includes/comment.php on line 155
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/wp-includes/comment.php:155) in /home/wp-includes/pluggable.php on line 896
    

    Ladybug on a leaf

    I stared at that for a moment and after I had given up and proposed we reinstall WP and copy tables over, my brain kicked in and I said “Wait a second, isn’t that comment_ID and not id?” I changed it on a whim and shouted “HOLY **** I AM GOOD!”

    Yes, it was in all caps. Yes, it was said to my coworker, who said I have his vote.

    That was, by far, the weirdest error I’ve seen in months. And the moral of all this? You can’t know everything, but if you read and pay attention and are willing to experiment, you can solve pretty much anything.

  • InBox Insanity

    InBox Insanity

    I get a lot of emails. I’m usually receiving and sending every hour or so. Most of the time they’re email alerts, sometimes conversations. While I’m a massive unsubsciber of email lists, I filter a lot of my emails into folders, where I’ll leave them unread until I have time, and then I delete them. Oh yes, I’m a member of Inbox Zero.

    Cat Face CloseupI started doing the Zero because I wanted to cut down on the stress in my digital life. An unread notification sits there, like a malignant ‘Deal with me!’ eye. And the thing is I do, I will, I always at least read the email. I don’t always reply, but I will read it. But what I don’t need is a five year old kicking my seat asking if we’re there yet.

    I’m not patient. I eat my bagels undercooked because if the dang thing isn’t done in the time it takes me to start the toaster, get my cream cheese, make a coffee, and go to the bathroom, then it’s getting eaten as is. I would never be a good chef because I don’t care if every slice and dice is the same, I care about eating. If it’s time to go and you’re dawdling, I hate you. I get annoyed when people can’t budget their time well and thus are always late. It’s a thing, it’s mine, and it’s what it is.

    Conversely, when it’s not food, or when its not a specific time event (like “I’ll meet you there between 4 and 5”) then I don’t stress about it. And when it’s email or Twitter, I’m seemingly negligent about serious replies because I may take a long time, and reply to other people frivilously, but in reality I’m thinking about the right reply. I have a couple emails in my drafts at any one point in time because I’m thinking.

    It’s funny, I know, that I get upset when people nag me about replying. But I understand that people need processing time, and while I’m terribly impatient when I wait for an email reply from someone (seriously, ask my wife, I’m really annoying), I try as hard as I can NOT to bother them about it! I may send them a little “Hi” note after a week or so, depending on the issue, but I’m usually asking someone for a special favor in the first place, and I try to respect their boundaries.

    Whew. Lots of me me me here!

    Also I like using desktop applications. I like email apps, and Twitter apps, over in their own thing that I can totally close out and ignore if I need to write or whatever. I’m not tempted to open twitter.com in my browser because I never do it. It’s good for me and my sanity, because I don’t get those ‘gotta clicks.’ The only ones I have in my browser are my RSS reader, Facebook, and Google Plus, none of which annoy me with alerts in my browser (well, not once I forcibly turned off all alerts).

    But email and Twitter, being a desktop tool on my Mac, need some settings changes too. Twitter has two places:

    Example of Twitter Settings

    On the first settings page, General, I set my menu bar icon to disabled, so nothing to pester me up there. On the Notifications page, I turn of nearly everything. The exceptions are mentions (which I keep as menu, just in case I change my mind… it’s been a month, I suspect not) and messages. Messages are important. Very few people DM me on Twitter, and when they do, it’s probably important or private, so it needs serious attention.

    Nothing else does.

    Email is weirder. How do you turn off the dock? Surprisingly easy. Go into your System Preferences and click on Notifications (first row, last column). In there, I always turn on “Do Not Disturb” settings from 9pm to 7am. If I’m up and coding at that hour, I’m in a zone and leave me alone. Otherwise I’ve left the laptop open, and either way I’m probably not in a mood to talk to people. The last thing I want is more alerts.

    Next scroll down to your email app (mine is Postbox) and turn off everything. Uncheck the boxes and set the style to ‘None’ and walk away:

    Notifications for PostBox

    Boom. No more red number.

    Don’t worry, I’m still checking mail.

  • Dr. Jekyll and Ms. Hyde

    Dr. Jekyll and Ms. Hyde

    I like WordPress. I like the community and I like the way I can invite other people in on it. But. I wanted to run a site, a small site, with static content for the most part, no comments, and just the basics. So why not Jekyll? After all, I’m big on self-hosting, and while most people I know seem to be running Jekyll on GitHub, you know me. I want to do it myself, I want to have it all here.

    Six drinks later…

    DVD cover of Dr. Jekyll and Ms. HydeMy major issue with Jekyll is that the ‘Simple’ directions aren’t obvious the way everyone seems to think they are. I mean, yes, they’re simple, but they lead you to some pretty crazy misconceptions based on how websites and CMSs work, and have worked, for a long time. And given all the posts I’ve read about how terrible WordPress is, my remark on that is: No, Jekyll is not terrible, but it has an audience.

    Look, of course WordPress can be terrible. So can your car. It’s all in how you use it, what you add on to it, and what you fuel it with. I have a lot of reasons to use WordPress, and I really like it for many reasons (least of which is if you asked me to explain Jekyll to someone who emails me a PDF of a Word Doc to post on WordPress… Well, yeah, no, it’s not simple.)

    Misconception: Where Do I Install Jekyll?

    jackie-chan-memeDaFUQ?

    Okay… you think “Hey, Jekyll’s running my site so it’s all on Jekyll, right?” Nope! Jekyll is installed on my laptop. It’ll be used to create content that I will deploy to my website. Jekyll generates the webpages. Just bear with me. Yes, it also runs the site, but it doesn’t have to. In fact, it generates all of my pages into a subfolder called _site, which you can actually load as a webpage. If I copied all of that over to a folder, it’d work as is. So option one here is that I could just do that. But that’s not what I’d call ‘friendly’ and it means all my code has to be on the server where a sneaky person could go get it. Part of why Jekyll interested me is that it’s more secure by being a flat site.

    Option two is to use a Jekyll ‘front end’ deployer, like Octopress or Prose. Option three was to stop and think “Maybe I just don’t get this and I should start simpler.” It’s very odd to me to have my ‘content’ on a server, but the ‘source’ not there. While if it’s just me running a site, that’s great. But as soon as I have to tell my dad to check code out… Maybe this is a bad idea. I don’t want end-users to have to learn all this. I want to tell them “Write your content. Save it here. Magic.”

    Revise: Needs vs Wants

    When I get really bogged down in thoughts like this, I step back and ask my self “What are my needs?” That’s similar to asking “What problem am I trying to solve?” but it’s a little broader, as I may not have an actual problem, I may just need a small change.

    I’m looking for a product with a small footprint, no comments, a way to subscribe to updates (RSS or email), separate content and design (so my writers don’t mess with the layout), and it needs to have a workflow that does not involve me having to teach svn or git commands to a music major. Oh and it has to be easy for me to upgrade (one click or git pull will do).

    Say what you will that git is easy (it is for me, albeit sometimes confusing). It’s not necessary for everyone to learn. I really feel a journalist shouldn’t have to learn to use it in order to write content! Still, after banging my head on this, I finally decided I was making my life too complicated by trying to self host before I understood the actual workflow of the process. So I went one step further back and decided not to self host right now.

    KISS: GitPages

    Everyone uses GitHub Pages. So fine, so will I. They walk you through the setup, so that’s nice. It was pretty painless to make a repo. But what did that have to do with Jekyll? I can edit everything within GitHub which is nice but I don’t want that. I wanted to learn Jekyll… Scroll to the bottom and there’s a nice graphic saying I can use Jekyll!

    Now that you’re up and running, here are a few things you should know.

    And they link to the Jekyll quickstart. Okay, thank you, I can install Jekyll. How do I hook them up? I had to actually Google to find the link to Using Jekyll with Pages and frankly, after reading it… I don’t want to. Oh I did it, but it’s not “simple.” It’s a total pain in the ass. It reminds me of the old MoveableType when you had to fuss with cgi-bin. It’s all manual. And this is fine for a dev, but I don’t want to have to install this on my Dad’s laptop. Did I mention he was on Windows?

    See? Jekyll running on my laptop

    So using this for a version controllable, static website, is actually far less tolerable than I wanted it to be. I can use it, I kind of understand it (the whole source folder is confusing me a little…) but it’s not something I could easily roll out to a medium-technical person without some serious training. In fact, I need some serious training to get good at just pushing my content, and when I compare that to WordPress…

    I get why people like it, though. The static files alone are pretty cool, but it’s going to be a learning curve.