Drupal 7 entity reference field is displaying unpublished content

So I had a view with an exposed filter, to filter the content type by an entity reference field which was referencing another content type. However, it included unpublished items. So I traced the problem back to the content type, which also listed unpublished nodes as options to select for that field.

Entity reference, by default, grabs the most recent state of the entity, whether published or not. So, I needed a workaround, and pieced this together:

Go to the admin “Manage fields” page in your content type for the entity reference field you need to work with. Under “Entity section”, you have the option to select a Views Mode. So using a view will give you more control over the entities that are available.

You’ll need to create the view first. Make sure the view’s display is “Entity Reference” when creating the view, and make sure “Content: Published” is set in the filter criteria.

You may see an error like this: Display “Entity Reference” needs a selected search fields to work properly. See the settings for the Entity Reference list format. If so, go to “Settings” for your Entity Reference list Format, and check an option under Search fields (I’m using Content: Title for mine), and Apply.

Once this view is set up, you can go back to the Node field under Entity Selection on your Manage Fields page, and select the Views mode. The page will then load a “View used to select the entities “ field where you select the specific view.

Now, if you create or edit your content type, you should only see published entities for that entity reference field. And, going back to my original problem, any view where you filter that content type by that entity reference will also only use the published entity reference nodes for filtering.

Drush throwing ‘Segmentation fault: 11’ error thanks to node_modules dir in inconvenient location

So I recently started seeing a ‘Segmentation fault: 11’ error whenever I ran a drush command for my various Drupal sites at work. So some research turned up this very helpful post: http://dannyenglander.com/blog/drupal-drush-segmentation-fault-11-error-avoiding-rabbit-hole. The problem, as it turned out, was related to the fact that we use node/npm to compile our SASS. When installing the node packages, there is a dir created called node_modules, and this dir contains a .info file that Drupal thought was a Drupal .info file, which led to that lovely segmentation error.

So – our SASS (which is a framework shared across many sites) primarily lives in a dir in /libraries, which is added to the system via a simple custom module. Then, in the theme for each site, this SASS framework was being symlinked in, so that each site would have its own vars file, index file, along with any custom scss files needed that apply just for that site. The symlink was causing the issue. So, I removed the symlink, so now the files accessing the SASS framework have much grosser looking paths to get to the files they need, but the segmentation error is gone at least.

Drupal does not check the /libraries dir for .info files, which makes it a convenient place to store anything node related if that’s necessary for the site.

So I finally got a tonsillectomy, and here’s what happened

I’d been needing one for a very long time. I would get sore throats at least once every two months, and on a regular basis I would have this feeling of my tonsils being “full”. This meant that I would have to manually squeeze out white goo from their teeny tonsil-holes. Neglecting to do this meant, inevitably, another sore throat. Not fun.

So, approximately 12 days ago, I had the surgery.

The only surgery I’d had before this was getting my wisdom teeth removed, so I assumed the process would be similar. I’d heard horrific things about how painful recovering from a tonsillectomy for adults can be, and as a result did a bunch of reading online about other people’s experiences. Huge range. People kept telling me not to worry about the upcoming surgery, and I didn’t really worry about it at all. I did worry about the very light sore throat and headache that I, of course, had to develop a few days beforehand. Apparently that wasn’t enough to postpone the surgery though. Anyhow, I didn’t start stressing out until walking into the operating room and realizing that this was the first time I was ever in such a room (minus when I was born, I assume). Luckily they quickly pumped in the anesthesia, and I laid there feeling progressively more dopey, mostly by that point being annoyed that the last thing I would hear before passing out was the Rolling Stones that they happened to be playing at the time.

I remember nothing, and must admit that I find anesthesia a rather pleasant experience. I woke up to the sore throat I expected to have, along with the persistent headache, and was soon being fed, and then given, a cup of ice chips by the nurse. Josh was ushered in, hung out while I recovered from the anesthesia, and we then headed home.

I expected to be groggy and in horrific pain that day, but was mostly just tired, and the pain was no worse then a bad sore throat. This was helped by my diet of ice chips and Tylenol 3 with codeine. I found that chopping up ice in the blender, then adding gatorade, made an adequate throat-soothing drink. Apple juice worked well for that too. I believe day 1 was “watch the 6 hour Pride & Prejudice A&E miniseries” day. I purchased a Hulu subscription to get me through the after-surgery period, well worth it.

Sleeping the first night was vaguely nonexistent, as it was hard to be comfortable, hard to go without drinking water long enough to sleep, and once I did fall asleep, my mouth would more often than not fall open and I would end up breathing through it, drying out my throat. I default to sleeping with my mouth open at night, and suspected that might be a problem. I’d read some people suggest to set an alarm in the middle of the night to ensure you took your drugs every 4 hours, but I found that unnecessary, seeing how often I’d wake up anyways.

Day 2 was not dissimilar to day 1, though I ventured into the world of dairy with milk & yogurt popsicles, which were very good. Another “living on the couch” day. Throughout each day, I would also regularly gargle salt water, as that helped keep things clean and ease my worries about what little I was consuming possibly infecting the area. The area, by the way, looked completely disgusting. I had a teeny flashlight, I looked every day (several times, usually) to check the progress. Went from red & gross to white & gross to white & puffy & gross. Also, my uvula swelled up really big and tongue got a bit puffy as well. Super gross.

Day 3 was when things started going downhill. My dairy experiment from day 2 caught up to me, and I realized that I was not equipped to deal with the resulting phlegm. I also had the brilliant idea of attempting mashed potatoes, and later bread. Even light chewing was a horrific idea, as it killed every part of my mouth that was involved. Same with anything that involved my tongue. Plus, both bread and potatoes managed to get lodged in my tonsil-holes, which was both uncomfortable and very gross. So I gave up on non-liquids for the time being.

Day 4 was hell on wheels. I think it was a mix of my poor (read: nonexistent) diet catching up to me, the meds catching up to me, and who knows what else. I had a splitting headache that only got worse, along with some wicked nausea. I curled up crying for a few hours, I vomited into a bucket, ended up taking 2 ibuprofen on top of my regular dose of codeine, some of which may or may not have been lost in the vomiting, and just being in a semi-coma for the rest of the evening. It was pretty awful.

So, one reason I think I hadn’t perceived the pain from the tonsillectomy to be *that* bad is my history of horrific cramps. For a period of time in my life, I had, on a monthly basis, the sort of cramps where I would pop 4 pain pills at a time and curl up on the bed and cry my eyes out until they kicked in. I was useless for 2-3 days a month, and it’s a good thing that I was working from home at the time I was experiencing this because I don’t know how I would have managed being at a job in that condition. So, any pain I have now, I compare it to those cramps. Helps to put things in perspective. The day 4 pain was the only point where I felt the pain level to be equivalent to my old cramp pain.

After that, I started alternating between codeine and ibuprofen. The ibuprofen was more friendly on my stomach for sure. I also forced myself to be a bit better about having something in my stomach – I tried getting more applesauce and yogurt in there mostly.

So it’s been a slow but steady process of healing since Day 5. I watched an incredible amount of television in that span of time – I tried reading, but found it hurt my head, and wasn’t until week 2 that I could really do books again. I did manage to get some drawings done once the pain was a bit better. Day 7 (the following Monday) I started working again – partially. I had also planned on working from home, and it’s just me on my laptop catching up on things. I don’t think I did any actually programming until Tuesday or Wednesday.

Friday was my first day being able to eat solid food again. It was also the first day since the surgery that I pooped. I thought at first it was because I was on a mostly liquid diet. But no, pain pills constipate! TMI, but that first poop was horrific and awful and I highly recommend anyone in a similar situation have as many assistive medications as possible available to them to help with the poopening. Despite this, we ate pizza that night to celebrate. It took me 20 minutes to eat 2 teeny slices but it was delicious and worth it.

The ole intestines have been quite burbly since then, so I’ve been trying to get back into food in a healthy and fiber-rich manner. Well, minus the ice cream. Everyone says that you should eat lots of ice cream with a tonsillectomy because that’s one of the only things you can eat, but I never really wanted ice cream at that point. Right now, however, it’s amazing. I still feel like I have a pretty crappy sore throat, one that is taking it’s sweet time going away. I’ve done some walking this weekend, though, so I feel OK being active again, and plan on resuming doing Zumba next Saturday.

Also, it’s amazing what finally getting a full night’s sleep will do. I believe Friday was the first night I managed to sleep through my normal ‘wake up in the middle of the night in dire need of drugs’ pattern. As I started weaning myself off the drugs, I found that I could not give up on nighttime. I’d take either syrup or ibuprofen about 30 min before bed, and then wake up at 2am or 4am with my mouth hanging open and this horrific throbbing in the back of my throat. I’d get up, take pain medication as quickly as possible, woozily stumble back to bed fighting the waves of pain, and sit up in bed and wait out the pain until the painkillers kicked in and I could sleep again. This was also the morning process – even when I was trying to be back to work, I’d set my alarm, get up, take drugs, then sit in bed 30 minutes or so until the pain was minimal enough so I could get up.

I think some of this sounds really awful, and it definitely was at the time, but when you’re going through it you just push through and know it’s gonna be worth it. I might have another week or so before the sore throat goes away fully. And, apparently it takes up to a year to fully recover from surgery. But I look forward to far fewer sore throats, and am glad I got this done when I did.

So, we’re moving. Here’s the details on that.

At this point I’ve told a few people, but I haven’t really made any announcements as such, and really need to. So, here goes:

1.) I’ve been working contract for Autodesk for the past several months remotely, with occasional trips to SF. They offered me a full time position, and I agreed.

2.) Part of the agreement involves me working on-site. So, as of early-ish October, we’ll be moving to San Francisco. Well, working in San Francisco, but probably living in Oakland. My mood is greatly impacted by weather, and as neat of a city that SF is, the whole ‘damp and dreary most of the time’ thing makes me think I’d be better off living in warmer & sunnier Oakland and commuting in.

3.) And, since I’m gonna be gone by end of October, this means I won’t be a NaNoWriMo ML for the Denver area anymore. It’s been a great several years doing it, and I’m definitely going to miss the Denver NaNo community. That being said, I still plan on attempting NaNo this year (maybe not as focused on hitting 50k, but I’d like to get involved in the SF community).

And some details on all of this:

– Josh is coming with me. He seems pretty excited about the move.
– As much of an awesome opportunity this is, I’m going to miss Denver like crazy. The people here are amazing, the city is amazing, and Colorado in general is amazing. And, never fear, we will come back to visit.
– I plan on going to any game the Rapids play against San Jose. So, come out to away games and say ‘hi’!

I made up a theory involving toilet paper & fruits/vegetables

So I was sitting there, as you do in the bathroom, and I came up with this theory on toilet paper. I think that if you were to compile purchase histories at your average grocery store, you’d find that quality of toilet paper purchased correlates inversely with the amount of fruits & vegetables purchased. So, people who eat the worst might be more likely to buy fancier TP.

There’s a pretty big range in terms of quality for toilet paper. On one end you’ve got your dirt cheap single ply Scott, and the on the other end you have 3 ply super fluffy toilet paper made from the tears of angel babies.

Now, your poop is a good representation of how you eat. A diet rich in fiber (AKA all of those fruits and vegetables) results in fluffy poop that comes out clean. And if your poop comes out clean, that means minimal wiping. A less healthy diet means messier poop, which means more time spent on the toilet, and more time (and toilet paper used when) wiping.

If you’re not spending that much time wiping, cheaper toilet paper works just as well as anything else. The more you have to wipe, though, the more sore your wee bum is going to become using lesser quality paper, so that fancier paper that’s thick and fluffy and infused with aloe is going to be a lot more appealing. Thus, my theory.

There’ll still be outliers, of course. Some people will always choose the cheapest option available. Others will always choose the fanciest option available. But, even with those averaged into the data, I still think my theory is spot on.

I finally got around to updating my professional site, so I’ll write some boring details about the process

I updated varoper.com. It had sat untouched for almost 4 years prior, and really needed it. It’s been through approximately 2398475293847 iterations. The Wayback Machine has its first record of varoper.com on January 26, 2002. I believe I created the first design for a class project, and then went from there.

In terms of sites I’ve built, it wasn’t the first. Technically my first website was a beautiful monstrosity on Tripod.com, created in 1996 during study hall in high school. My first site that I built for someone else was for the Department of Adult Health in VCU’s School of Nursing back in 2000. And ptocheia.net, my personal dump site, first came to life somewhere around August 8, 2001 (or at least, the 1st record the Wayback Machine has of it).

These weird reminders that in 2 more years, my html skills will be old enough to drink. And I’ve been doing PHP for 13 years now. And god I’ve logged some serious time on these internets. I try to avoid thinking about these things in the context of my last job, better to focus on the fact that I’m no longer there, and I can try to be somewhere that appreciates the time and effort I’ve spent building all of these internets.


My first iteration of the site was straight html & images. No css or anything, and I’m pretty sure it involved a giant brain that I’d painted, which I scanned in and used to represent my head or something. Wish I still had that .jpg (or the painting itself) somewhere, but it seems to be long gone.

According to the Wayback Machine, I was clearly uneducated about how to present oneself professionally. Specifically: back in college, I was on a DDR team called Team Yaoi. I built the website for the team, & linked to it from my resume, available from my website at the time. The Team Yaoi website included a page that consisted of nothing but erotic furry art, drawn by myself & a few other members of the team. Classic. Of course, I did land a job using that website (plus a few others) as examples of work, but it’s definitely not the sort of content I’d consider including on a resume now. On a related note, I might have to throw up stuff like that somewhere just for historical/hilarity purposes, to share with those who have long forgotten such things exist. The early 2000s were a great time for beautifully awful websites.

At said job, I learned shell scripting and m4 (a macro language), and redid my website using those to generate the html. They were easier to write than the perl I was also learning at the time, and strangely satisfying for someone who was still excited at the idea of server side includes.

Sometime after that I rebuilt the site in php. I had a period of voluntary unemployment after quitting my watercolor job, and I used that as an excuse to build PHP sites and learn OOP. So I made processes where, in order to add a new piece of artwork to my gallery, I’d just upload the image, and then add some content to a text file, and it would automatically get pulled onto the site.

At some point I realized this was a huge pain for updating text content. However, I spent a couple years at a job that overworked me and left me extremely burnt out, followed by a job that left me feeling unimportant and disillusioned. This bled over into my enjoyment of building websites, such that I had a very hard time convincing myself to work on a website during my off time. I am happily unemployed at the moment, and chose to dedicated this delightful state of joblessness to redoing my personal site, amongst other things, and to take my time doing so in order to rediscover how much I really enjoy making these internets.

I built the site in Drupal 7 because Drupal 7 is what I do. I briefly contemplated implementing it in Drupal 8, but it’s in beta and it seemed a rather bad idea to build one’s primary site in a system that might break at any point. I purposefully chose to build a few things more difficultly than I otherwise might have – I built a custom module to generate the contact form, and chose to write preprocess functions in my template.php where someone else might have implemented a module. Part of this was for skill refresher/building, and another part because the “there’s a module for that” mentality can lead to implementing something large and bloated when all you might really need is a simple code snippet for your particular circumstance.

The design of the site is stark, bold, black and white with strong color accents – this veers away from past iterations in that I decided to design based on a color palette I personally found appealing, rather than something I thought looked more professional and/or trendy. So, blacks & whites, with colors only for linked items (and a different color for each section of the website). Having a neutral setting allows the art to pop, and makes it clear what is a link and what isn’t. I tried to make the responsiveness as smooth as possible, and I spent extra time doing custom alt tags on all images in accordance with accessibility standards as suggested by WebAIM. It is depressing how many otherwise modern sites don’t do basic accessibility. I don’t claim to be an expert, but some of the stuff is so easy to do.

Anyhow, I’m glad to be finally done with the site, so I can focus on other things. Need to do art more regularly, and I still have a giant pile of short stories that stare at me guiltily. I’m also thinking of maybe adding a “crafts” section to the site at some point too – this would accommodate my painted shoes and refinished furniture and weird things I sew and whatnot.

Adding active trail classes to your menu links in Drupal 7

So I’m working on a site with a gallery page with /art as a path, along with single artworks pages with the path art/[title]. When on a single artwork page, I still wanted the visual indicator that the user was in the main “art” section of the website, ideally by highlighting the /art links in menus. I found a module, Menu Trail By Path, which took care of this.

However, I also had another section for photography. This was a separate gallery, living at art/photography, with single photos living at art/gallery/[photo title]. I wanted to highlight both the top level /art menu item as well as the art/photography menu item, but Menu Trail By Path didn’t want to go that deep.

So I wrote a chunk of code for when you want to indicate on all of your menu links when a menu item’s path is part of the URL for your current path. I was able to remove the Menu Trail module, and this (which lives in template.php in your theme) took care of everything:

function yourtheme_menu_link($variables) {
  //get path alias of current page
  $current_path = drupal_get_path_alias();
  //get path alias of menu item
  $menu_path = drupal_get_path_alias($variables['element']['#href']);
  //if the href of the menu item is found in the current path
  if (strstr($current_path, $menu_path)){
    //add active-trail class to li and a tags for that item
    $variables['element']['#attributes']['class'][] = 'active-trail';
    $variables['element']['#localized_options']['attributes']['class'][] = 'active-trail';
  return theme_menu_link($variables);

Why it’s good to take breaks (Drupal + Fences + Field tpl.phps + Dumbness)

So I’m working on a redo of my site in Drupal (finally). I’ve got a custom content type, where I have a term reference that’s displaying taxonomy terms. I’m using the Fences module to cleanup Drupal’s “div diarrhea” issue. And I really wanted my set of taxonomy terms + label to properly wrap themselves in a div so I can easily separate them from other content – but with Fences, the combination of label + terms is wrapped in absolutely nothing. I can’t find a tpl from the Fences options that would work, and then adding a field–[fieldname].tpl.php wasn’t working either: because of Fences being enabled for that field, I’m assuming.

And then I take a break, come back, and realize I can just wrap the render statement for that field, living in my custom node tpl, in a <div>. Welp!

I painted and varnished a table that someone threw out

So there’s a spot in the basement of my apartment building where people, usually when moving out, will dump unwanted items, primarily furniture. I always pass this spot when I take out my recycling, usually 1 out of every 3 times there’s something there. On one lucky day about 2 weeks ago, someone had dumped several pieces of furniture, including this little table:

little table

The paint job was poor, the colors mismatched, and I’m not sure what was going on with the sheet music at the top. While the concept of sheet music collage is a good one, taking 3 sheets and just plastering them on there (not even fully covering the table) is not exactly the best execution of that idea.

So I decided to repaint it to match a table I’d repainted about 2 years back. Picked up some pink and black acrylic, dug out my varnish, and had at it. Did 3 coats of paint, and then 2 coats of varnish. Took slightly longer than it could have, however; I needed to dry the varnish outside to due cancer-causing fumes and whatnot, and while I was crossing my fingers for sunny skies, the weather had other plans.

snowy table parts

I’m pretty happy with the outcome. The drawer is a little wobbly (this was clearly originally a cheap IKEA-esque piece of furniture), but aside from that it’s sturdy enough. My pens and notepads finally have their own home!

painted end table

And, here it is with it’s matching table (please ignore the shoes!):

table set

Profitability & hotfix to release ratios in Agile environments

So I have this theory that, for the average company that uses Agile, the hotfix to release ratio directly correlates with the success of a company.

OK, so “success” is pretty vague, so let’s look at it in more specific terms.


Let’s say a given company’s hotfix to release ratio is very high. So they’re doing at least as many hotfixes as releases (if not more). This suggest that their development team’s primary focus is on fixing existing bugs and/or rushing in changes to the application. Which leaves less time for developing new products/features/advancements. Thus less value added to their existing product, meaning fewer shinies (as it were) that marketing can use to drive in leads. Or fewer products to add to the market. All of which will shrink profits.

Customer Satisfaction

One thing that could cause very frequent hotfixes to be necessary is the discovery of bugs on the production version of the application. So if these are major bugs, it’s probably guaranteed that users are noticing them, and are none too pleased about them. Regular occurrences of bugs on production imply a lack of solid QA, meaning there might be even deeper flaws in the application that simply haven’t been discovered yet.

Even minor bugs that are getting hotfixed, such as grammar edits, imply a sloppiness in the application itself. And who wants to use a sloppy application?

Employee Satisfaction

Frequent hotfixes also imply a process issue. Lack of proper QA is in itself a process issue, and will lead to frustration for all parties involved when development work isn’t properly tested – or when a proofreading process for copy is inconsistent to nonexistent. And, if the hotfixes aren’t QA-related and are simply “mini releases that couldn’t wait”, this implies a team that’s overly focused on the short term and missing out on the long view of the project (well, long view in Agile terms, at least) and are stuck rushing slapped together solutions rather than properly being able to focus to building a good solution (a frustration for anyone who actually likes making high quality work).

So I’d like to make there be a thing called the HFR ratio (for Hotfix Release). You can magically get access to protected Github data and calculate the HFR ratio for different companies (assuming companies generally have a naming schema that indicates if that push is a regular or hotfix release). This could be useful for many purposes, such as determining what companies to invest in, what applications to pay (or not pay) money for, and what companies to pursue employment with.