Half-Elf on Tech

Thoughts From a Professional Lesbian

Tag: hosting

  • How To Pick Your Webhost

    How To Pick Your Webhost

    This is not a real conversation, except it totally is.

    User: I want hosting.
    Me: What kind of site do you want to host?
    User: A WordPress site!
    Me: What kind of content do you plan on writing?
    User: Oh you know, blog stuff.
    Me: Okay… A food blog, a photo blog, a tech blog…?
    User: ​Why are you asking me all this!?!?!

    I’ve had so many conversations like this, I’m of the opinion that recommending hosting is a mugs game that simply cannot be ‘won’ so I generally don’t play.

    Then why am I presuming I can tell you how to pick a webhost? Because I’m telling you how to pick a webhost, not who the best webhost is.

    Preface

    Someone will hate every single webhost on the planet. I use Liquidweb and DreamHost. People hate both of those. There’s the bevy of EIG companies whom people will detest and lambast and accuse of shady actions to be listed somewhere. There are the millions of small companies. There are good and bad companies, and there are reasons to use them. Whenever someone asks what host to use, I remind them that someone will hate their choice. That’s okay, just don’t take it personally and I recommend you ignore people who simply jump on bandwagons to tell you “X SUCKS!” They’re not being helpful.

    Needs vs Wants

    I repeat this a lot in myriad situations. Your needs are what your website needs, which should be obvious. If you’re running WordPress you need a webserver than runs a modern version of PHP and a MySQL (or MariaDB) database. That’s it. But that isn’t all of what you need for a website, and to understand your needs you need to be very clear about your own abilities, your capabilities, and the time you’re willing to commit to your project. Running a website is very time consuming and stressful. You can’t just set it and forget it.

    Who Are You?

    We should all know who we are, what our skills are, and what we enjoy doing. I’m like playing with servers and code. My wife prefers practical experimentation (she makes cheese and mead). My father is a mathematician. We’re all writers of a sort, but of the three of us I’m the one who runs the website and puts of articles on the regular. This is not because the others can’t, but because they know who they are. My father sends me his articles to post, my wife posts her own, and I both write my own for me but for my company, and I maintain the servers (and email). If you’re not me, and don’t have a me, you need a me. That may be your host, and it may not.

    How Do You Communicate Best?

    Do you get anxiety with phone calls? Look for a company with live chat and email support. Do you hate live chat? Are you dyslexic? Look for phone support. You know how you like to communicate with strangers, so pick a host that has what you need. I personally prefer ticket based systems, unless my server is actually on fire. That hasn’t happened much.

    How Do You Add People?

    Let’s say you decide to hire someone to work on your website. Do they need access to the server? Do they need access to your billing? How do you do that without giving them your passwords? Find out how the host handles this. Can you simply add a technical contact or will there be more complicated steps?

    What Is Your Site About?

    Why does this matter? Well, think of it this way. “I want to make a community site where people from my city can come and post news, events, crimes, etc.” Did you just think about BuddyPress? You will likely need a bigger server than Shared. “I want a photoblog!” Okay you will need to seriously look at diskspace, which means SSDs may be a little tricky for you since most limit space. Check if the host allows easy upgrades. “I’m going to run a multisite network for my school!” You need a private server. Knowing what your site is about will help you predict upcoming hurdles.

    Do You Know Any Metrics?

    Most people, especially people with a brand new site, are going to say “No!” here and that’s okay. But if you do know things like how much traffic you get or how often you post or how much disk space you use, talk to the host about it. Pre-sales questions like “What’s the best hosting plan for a site that gets 2000 visits a day, and then 12k on one day a week?” are the bread and butter of a host. If they can’t answer it, move on.

    Does The Host Make You Feel Good?

    If you get a bad feeling from the host at any step along the way, you feel like they’re dismissive or maybe not a good fit, walk away. Look, you need to be comfortable with your host, and if the advertising practices of a host upset you, don’t use them. It’s that simple. Even if they’re the best for your needs, if they make you uncomfortable, you will be miserable. And remember, for every single host there will be people who hate them. That’s okay too. If it works for you, and you feel good about doing business with them, then that is really all that matters.

  • Chart.js Category Statistics

    Chart.js Category Statistics

    One of the sites I work on is using the Metro Theme by StudioPress Themes for WordPress. And on that site, I have a page dedicated to some odd stats based on the categories and tags and custom taxonomies.

    What I have is a post type ‘shows’ and a custom taxonomy called ‘clichés’ and from that I was easily able to generate a percentage of how many shows use the cliché of queers in law enforcement (38%) or how many have the death of a queer (also 38% right now). But that wasn’t enough. We wanted ‘pretty graphs’ and for that I needed a tool like Chart.js and a little PHP magic.

    How to Chart.js?

    Chart.js is a super cool and super responsive and super flexible way to include a chart. And using it is incredibly easy once I figured out that I could just use inline script tags. A very basic chart that would show you how many days each month has looks like this:

    <script src="Chart.js"></script>
    <canvas id="barDays" width="600" height="400"></canvas>
    
    <script>
    var barDaysData = {
    	labels : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "November", "December"],
    	datasets : [
    		{
    			fillColor : "#7d3255",
    			strokeColor : "#532138",
    			data : ["31","28","31","30","31","30","31","31","30","31","31"]
    		}
    	]
    }
    
    var barDays = document.getElementById("barDays").getContext("2d");
    new Chart(barDays).Bar(barDaysData);
    </script>
    

    If you’re using WordPress, you’ll want to use wp_enqueue_script to call it. Here’s what I did for my theme:

    wp_enqueue_script( 'chart.js', get_bloginfo('stylesheet_directory').'/inc/js/Chart.min.js' , array( 'jquery' ), CHILD_THEME_VERSION );

    But that’s the basics of it. Once I understood that, I was good to go.

    The Code

    Before I can do anything, I need to make sure I have the data I needed. What I wanted was a list of all the shows that were published and a list of all the cliches, ordered in the way I need them. The order is simply comma separated values, enclosed in quotes, enclosed in brackets:

    labels : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "November", "December"],
    

    And the data is similar:

    data : ["31","28","31","30","31","30","31","31","30","31","31"]
    

    Since I’m lazy, I checked that the array worked if it ended in a , and it did! That means my PHP looks like this:

    $count_shows = wp_count_posts( 'post_type_shows' )->publish;
    $cliches = get_terms('cliches');
    
    $barshow_labels = '';
    foreach ( $cliches as $cliche ) {
    		$barshow_labels .= '"'.$cliche->name.'",';
    }
    
    $barshow_data = '';
    foreach ( $cliches as $cliche ) {
    		$barshow_data .= $cliche->count.',';
    }
    

    And my js looks like this:

    <script>
    var barShowsData = {
    	labels : [<?php echo $barshow_labels; ?>],
    	datasets : [
    		{
    			fillColor : "#7d3255",
    			strokeColor : "#532138",
    			data : [<?php echo $barshow_data; ?>]
    		}
    	]
    }
    
    var barShows = document.getElementById("barShows").getContext("2d");
    new Chart(barShows).Bar(barShowsData);
    </script>
    

    You may notice the simple call of <?php echo $barshow_data; ?> in there? That’s where it outputs the data I sorted out in the PHP section. Done. I’m could put it more inline, but I liked to separate them as much as I could.

    Putting it in the theme

    This is a Genesis theme so while I am making use of the Genesis loop, the call to get_template_part can be used by anyone. I’ll explain in a moment. First, here’s the page template:

    <?php
    /**
    * Template Name: Lezbian Stats Template
    * Description: Used as a page template to show page contents, followed by a loop
    * to show the stats of lezbians and what not.
    */
    
    // Show Dead count below the content:
    add_action( 'genesis_entry_footer', 'lez_stats_footer', 9 );
    
    function lez_stats_footer() {
    	get_template_part( 'stats' );
    }
    
    genesis();
    

    This works like any other page template. You make a page, you select the template, and it loads this custom design.

    The magic sauce is in get_template_part( 'stats' ); which calls the file stats.php and that file has all the code you saw above. This means I can edit my post with all the explanations I want, and then it always outputs the stats on the bottom. By calling the Genesis code in the bottom, I retain all of it’s magic while pulling in what I want.

    The Result

    The graph of cliches about queer women on TV

    Looks nice, doesn’t it? I’m quite fond of it.

  • Working with Webhosts

    Working with Webhosts

    Working with a host isn’t just sending in tickets into the abyss and hoping they answer them. Whether you’re communicating on behalf of a client or for your own benefit, it’s not the same as working with fellow developers. You need to approach a host with different expectations and explain situations in different ways in order to get the best results.

    What Is A WebHost? Why Are They Different?

    You’ve had this problem where what works on Host A doesn’t work on Host B, right? All webhosts are different for a really obvious reasons. There’s more than one way to solve the problem of webhosting. Every host has decided, on their own, what works well for THEM. Which means no two of them are the same, nor will they really ever be. This is okay, if it’s a little annoying, because not only are YOU a special snowflake with your customized website, but so is your webhost with their customized server and environments.

    Setting Expectations

    Hosts Are Not Developers

    Your host is not going to generally debug themes and plugins. They’re just not. They don’t have the manpower for it. The host cares first about your servers, THEN about your code. And if they find your code is the problem, that discovery is often the limit. They’re not always going to help you debug exactly why plugin X is causing a specific feature on their servers to grumble. This doesn’t mean they can’t do it. Many hosts, especially ones with WordPress hosting plans, can and do debug code all the time. To be more precise, you shouldn’t expect the host to reverse engineer your code to understand why it does what it does. They are problem identifiers.

    Hosts Will Fix What’s Theirs

    This doesn’t mean that a host will leave you high and dry. A host will fix whatever they can. If their code broke your stuff, you bet they should fix that. Did they run a WordPress upgrade that left your site with bad permissions? Yes. But… If they ran an upgrade and you have a theme incompatible with WordPress 4.2, who’s problem is that? Should they be on the hook for fixing it or should the person who owns the site? This is why I say hosts will fix what’s theirs. It’s a lot of grey areas sometimes. It feels like people are always making exceptions or telling you that you’re an edge case. But at the end of the day, a host is NOT on the hook for upgrading your custom theme to work with the new version of WP.

    All Hosts Are Different

    Telling a host “But it works locally” or on another host doesn’t do them ANY good, nor do they really care. Everyone sets up servers differently, and sometimes the issue will be with PHP or the Linux OS or maybe, help me, Windows. It’s apples and oranges, like trying to compare two similar themes. Now this puts developers in a bad spot. WordPress is incredibly flexible and works, out of the box, in the majority of situations. The same cannot be said of all code. Most people don’t have the resources core does to test in so many iterations. And even WordPress misses things. Not all code will work in all configurations in all circumstances on all hosts. Sometimes you are a special snowflake. You are the edge case.

    Don’t Assume

    So what can we do to make things better? Telling the host the important things, especially if you’re a dev, will help everyone. If you’re not a dev, then start with the basics. The important thing here is, even though you having a bad day, not to freak out. You need to be calm, you need to be clear, but you need to provide a GOOD bug report. Don’t assume the host magically knows everything, since the error MIGHT be their servers, certainly, but it may also be a combination of what the user is doing, how they’re doing it, and the server that causes the problem. Hosts are not psychic. They only know what you’ve told them.

    Give the Right Information

    Who Are We Talking About?

    The most obvious question? “What’s the domain?” Many people will have multiple domains with a host, and if the issue only happens on one, you can speed up their searches just by being up front! Many, many, many times I see people complain that their ‘site’ is down. One user had 107 domains. I stared at it for a moment, tested a couple, and finally emailed back. “I looked at these five domains and they seem alright. Your email didn’t specify which domain was broken or how. Can you please be a little more precise? It’ll help us find out what’s wrong faster.” Start out with exactly what’s wrong and where.

    Are You The Owner?

    The next important thing to tell a host is “Who are YOU?” This is secretly “Who owns the site” because if it’s not you, you may not be able to get all the answers due to security. The host will know who you are, based on the email, so this also means “What kind of person are you?” Are you a user who can’t code? A high end dev? A middle-of-the-road guy caught in the problem? Let the host know what you can do and they can help tailor answers better. It’s okay to say that you’re the new dev taking over and you don’t know everything yet. Just let the host know where you stand. This lets them know what to expect and what they are permitted to tell you.

    Where Does It Hurt?

    With WordPress, sometimes a host has to ask “Can WE log in?” I hate this. I hate asking someone for access to log into their site. It makes me nervous. But sometimes if the error only happens when you do specific things, a host has to log in to reproduce it with debug on in order to track it down faster. If it requires logging in to reproduce the problem, remember to provide them access. I strongly suggest making a second account for the host and deleting it when they’re done.

    Explaining The Problem

    Even If It’s Tricky

    All the information before should have gotten you here already, but it needs repeated. Explain the problem! “This site is broken” is a terrible email and yet I see it daily. A better one is “This site is broken after we upgraded to WordPress 4.2. This is the error, this is what I’ve already tried. I THINK the issue is this other thing. Can you help?” Give the right information. Tell the host what’s wrong. Give them an error. Don’t assume they’re familiar with every single possible error. You’re not, after all, unless you’re Nacin.

    Details Are Important

    I know I said to tell them what you think the problem is. It’s okay not to know, but it’s not okay not to give the details on what you DO know. You know some things. Is the problem happening for logged in or logged out users? How do you reproduce it? Start by assuming the host knows NOTHING about your site and how it works. Even if you’re sure they know how a blog works, take the time to step back. This is really hard. You have to give them enough information without spewing your whole history.

    Walk Them Through It

    Walk them through exactly how to reproduce it. Use screenshots when possible. Videos? Not really as helpful as you might think. If you get an error message, make sure that you give them the WHOLE message as well as the context. I mentioned not assuming before, this goes double here. Don’t assume a host knows how you upload an image. There are multiple ways to do that, so tell them how YOU did it.

    You’re Not The Customer? They May Have To Talk Tech

    When you’re not the one who pays the bills, you may need to play intermediary and have the owner contact the host. Some hosts let you add specific email addresses as secondary contacts. You should always make sure of that early on. If you hate the social engineering that comes with people cracking into other people’s accounts, that’s WHY many hosts won’t just tell you everything. Playing the middle sucks, and when this happens, try to be patient. Everything will take longer. That said, have the customer ask the host if there’s a way to add you on as someone the host is allowed to talk to. Most have a way around it.

    Pick The Host You Like … And It’s Subjective

    Speaking of that … You should find a host you like. Figure out what you can work with, and here’s a big secret. Hosts won’t mind if you tell them that they can’t meet your needs. Okay that’s a lie, they do mind. But if the reason is “You don’t have 24/7 phone support!” well they understand. If the reason is “I need a type of server you don’t provide” that’s also okay. And sometimes, sometimes, no matter how much you love a specific person (or people) at a host, they just don’t meet all your support needs. And that too is okay. Hosts understand that. One brilliant person doesn’t make up for the masses, after all. Hosts aren’t the same. It’s okay.

    Everyone Wants Everyone To Be Happy

    In the end, the host wants the same things a customer does. A good, fast, website that does what they want and makes them happy. If you’re clear about what’s wrong, what you need, and you’re willing to work with a host to experiment a little, you may be surprised at how well you can work with them to succeed.

  • CDN vs Local

    CDN vs Local

    Which is better?

    I have no idea.

    Sorry. That’s not the end of the post, obviously, but really after the time it took to write this, my answer is that I really don’t know. So let’s talk about why I don’t know.

    The claim is this: “A CDN is faster!” The idea here is that a CDN will be faster because it lessens the load on your server. Anything that’s being process by another server means less work yours has to do. And that is totally true. Also, many CDNs have worldwide locations, which means someone in India can download your cat video from a nearer server than yours in Michigan. Also, more people have downloaded shared resources (like Google fonts) so it won’t be downloaded again, making their experience faster.

    And all that sounds great. But the actual functionality and performance gains are not going to be exactly tit for tat. At first, I thought that since I get a lot of traffic in Brazil, having a CDN that has local servers would be great for them. It was. A little. But it was a lot worse for me. Using my site in the US slowed down measurably. This was because of the latency of the CDN being worse than my own server.

    In addition, many site speed tests measure how many URLs you call in your page. Using a CDN ups that by one. It’s minor, but it’s something to consider. There’s also the idea of branding, which a CDN can hurt if you use it wrong (most CDNs will allow you to use cdn.yourdomain.com of course). Using too many servers for a CDN (think of it like cdn1.example.com, cdn2, and so on) can slow down the user experience too and cause overhead with all the DNS lookups.

    What’s the alternative? Good caching. And I do think that proper, server side caching is hugely important. But at the same time, the right network for your static files can provide significant improvements. Which is why we always end up back at CDNs.

    The real thing to consider is what your content is on that CDN. WordPress is dynamic content and shouldn’t be on a CDN. Images and stylesheets, though, those are perfect for a CDN. You take the traffic and, thus, the load off your server and it becomes faster. Streaming video too.

    Which brings us around to the idea of the cloud as a CDN.

    But is it faster? Is it better? Is it safer?

    Maybe. It certainly can be, but there is no blanket perfect answer for all of us.

    Currently I build local but prepare for the possibility of a CDN later on.

  • Cookie Free Domains and CDNs

    Cookie Free Domains and CDNs

    After I dropped Cloudflare I went back looking at other ways to speed up my site and what could I optimize things. As I mentioned in Static Content Subdomain, one of the benefits of that mess was to allow me to have a cookie free domain and, in having a cookie free domain, I basically made a domain that could be used as a CDN for my (mostly) static files.

    It was noted then that, if you’re a non-www person, you have to actually use a separate domain. I do. I hate www in URLs. So I picked up a free domain for the site where I’m doing all this: ex-static.com. I probably could have gotten it even shorter if I’d tried sitecdn.net but that was short enough for me.

    Since I already had everything over at /home/user/public_html/static I created an add-on domain in cPanel and told it to use that as its home.

    Then I ran a search/replace on WordPress:
    wp search-replace static.example.com/wordpress ex-static.com/wp-content/uploads
    wp option set upload_path /home/example/public_html/static/wp-content/uploads

    Since I’d already changed my media settings, that was all I needed to really run a replace. It changed my media settings too! Since I was planning to move my static content, not just images, I changed the path too, so I had to go back and change upload_path as well, but wp-cli is my friend.

    Next up, because of the static content move, I copied my wp-content folder over and added this to my wp-config.php:

    define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/static/wp-content');
    define('WP_CONTENT_URL', 'http://ex-static.com/wp-content');
    

    Boom. Everything’s where I want it.

    Sadly, it got messy for MediaWiki and ZenPhoto. The later doesn’t allow you to move your themes folder at all so I made a symlink to /home/example/public_html/static/themes/themename/ and called that a day. MediaWiki was a damn dirty lie.

    Supposedly you can set this:

    $wgStylePath        = "http://ex-static.com/wiki/skins";
    $wgStyleDirectory   = "/home/example/public_html/static/wiki/skins";
    

    As soon as I did that, I got errors all over the place and had to change the directory path back:

    $wgStyleDirectory   = "$IP/skins";
    

    Weirdly named, $IP is set as follows:

    $IP = "/home/example/public_html/wiki";
    

    I did the same thing as with ZenPhoto and made a symlink then I could change the style directory.

    Lastly (and this was last for a reason) I changed my .htaccess rule:

    # CDN
    <If "%{HTTP_HOST} == 'example.com' ">
            RedirectMatch ^/static/(.*)$ http://ex-static.com/$1
    </If>
    

    This was last so that I could not break things mid-flight. And I added in this:

    # CDN
    <If "%{HTTP_HOST} == 'static.example.com' ">
            RedirectMatch ^(.*)$ http://ex-static.com/$1
    </If>
    

    Everything works as expected. And? I have cookie free domains and I’m ready to move all my data off to a CDN whenever I’m ready for that step. The CDN would only have to cover the ex-static.com domain, to boot!

  • Why I (Still) SelfHost

    Why I (Still) SelfHost

    The other day I saw the notice that Google was banning all explicit adult content from blogger.

    Outside of the irony of remembering when the post’s author (Violet Blue) had her content deleted from Boing Boing back in 2008, she’s actually pretty uniquely qualified to talk about the difference between censorship and removal. For the record I think that it’s a pretty crappy thing to do and I don’t like it. But as I often say, my beliefs are pretty straight forward:

    I do not agree with what you have to say, but I’ll defend to the death your right to say it. ~ Voltaire

    Is It Censorship?

    Let’s be clear on this. The change to Blogger’s Adult Content Policy is pretty straightforward.

    Starting March 23, 2015, you won’t be able to publicly share images and video that are sexually explicit or show graphic nudity on Blogger.

    Yes, this is a change to their Terms of Service (which they reserve the right to do at any time), but is it censorship for them to say “We don’t want hard core stuff on our servers”? That’s like saying a country music station on the radio is censoring heavy metal. No, they just don’t want to have it on their servers. Google’s said they don’t want that. They don’t want to do business or make money off of things they find morally distasteful.

    Frankly I think the whole planet’s hang ups about sex are laughable. The majority of adults I know have consensual sex and like it. I do know a couple asexuals, and I know people who have reasons why they hate sex. I also know people who hate peanuts. It’s about the same thing for some of them (one has a traumatic peanut in his ear story that resulted in surgery and hearing loss). Sex is normal. It’s what everyone does and no one talks about (thank you George Carlin). So grown ups wanting to Google for information about the sex they want to have? There’s nothing wrong with that! There’s nothing wrong with kids looking that stuff up too. We used to hide in the back of libraries, looking things up when we didn’t feel comfortable asking our parents.

    The argument that they’re not ‘censoring’ they’re just enforcing their guidelines falls flat when you remember that the definition of censorship is defined as acting as a censor. So yes, I think Google’s censoring, but in this instance they’re within their right to do so. That doesn’t mean I think it’s right, but I’ll support their legal rights.

    Is It Discrimination?

    One of the sites hit up by this is a site where porn stars play D&D. I kinda like that site. It amuses me to no end and is how I learned about this change. They had just posted about how they’re leaving the escapist. They were talking about discrimination and general asshattery and non-inclusiveness. Their site may be punted off of Google’s Blogger service soon for being ‘adult’ by nature.

    I’m actually not sure about that. But I really have no idea why their site is considered ‘adult’ in the first place. I’ve never read anything about sex there except this:

    I’m Zak, I live in Los Angeles. Most of the people I know here are women I know from being a porn “actor”–so they’re porn stars and strippers. So that’s who I play Dungeons & Dragons with.

    First of all, I want to play with them because the game looks fun, but mostly I don’t recall ever reading adult or explicit content there. So of course I started thinking about how they could be making it harder for people to read about things that help them understand themselves. A lot of people sort out what they’re interested in by quietly reading stories about other people who had similar issues and thoughts and feelings. While Google’s only said they’re punting “sexually explicit” content, that’s a really slippery road.

    I shall not today attempt further to define the kinds of material I understand to be embraced within that shorthand description [“hard-core pornography”], and perhaps I could never succeed in intelligibly doing so. But I know it when I see it, and the motion picture involved in this case is not that.

    That quote is from United States Supreme Court Justice Potter Stewart, used to describe his threshold test for obscenity in Jacobellis v. Ohio in 1964 (the film being Louis Malle’s The Lovers). We’re allowing, and trusting, Google to define what is and is not explicit. And this means that it becomes a case by case value judgement. Are two women kissing ‘explicit’? It gets messy really fast.

    Is It What I Expected?

    Yes. I totally expected this.

    Google to punt all explicit blogs? Haaaaaaaaave you met WordPress?

    I meant Self Hosted WordPress, James. Yes, WordPress.com also restricts and censors your content. It’s their playground. I will, till my dying day, support their right to do this. They don’t want to do business like that, fine. I wouldn’t argue the French restaurant that servers pomme frites needs to serve a hamburger or some chutney. That’s their business choice and it just means I can’t use them.

    But it brings up the main reason why I still self-host.

    As someone who self-hosts, I still have to be aware of the Terms of Use for my webhost, but generally that provides me a lot more freedom. I have a legal contract and a leg to stand on. As long as I don’t violate that, I’m good to go.

    And of course I work for a company who would host anything, as long as it’s legal.