Category: Personal

  • Logging errors in WooCommerce

    Logging errors in WooCommerce

    Tracking down errors in PHP can be tricky sometimes, but WordPress and WooCommerce have some built in logging to make it easier. Here are a few snippets for future use:

    WP_Debug logs

    First, you need to turn on wp_debug and logging in your wp-config.php file. This will create a debug.log file in your wp-content folder, which you can then view errors on. This is how I do that:

    // Enable WP_DEBUG mode
    define('WP_DEBUG', true);
    // Enable Debug logging to the /wp-content/debug.log file
    define('WP_DEBUG_LOG', true);
    // Disable display of errors and warnings
    define('WP_DEBUG_DISPLAY', false);
    @ini_set('display_errors',0);

    Then, you can output specific variables or functions to that debug log.
    Some examples:

    • To view contents of variables, output vars inline in code using
      error_log( 'In ' . __FUNCTION__ . '(), REPLACE_WITH_VARIABLE_NAME = ' . var_export( $REPLACE_WITH_VARIABLE_NAME , true ) );
    • To backtrace which functions are using a function
      error_log( 'In ' . __FUNCTION__ . '(), backtrace = ' . print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), true));

    WC Logs

    To access the results of the log easily from the dashboard, you can log to a WC logger rather than the error log. You can access error logs by going to WooCommerce > System Status > Logs.

    You can then select the error log file you need and click “View”. This will give you any debugging information that you can copy and share, which is super helpful for the support team. Error logs are also located in the /wc-logs folder within your site install.

    Example of running a stack trace on a caught exception:
    // Log any exceptions to a WC logger
    $log = new WC_Logger();
    $log_entry = print_r( $e, true );
    $log_entry .= 'Exception Trace: ' . print_r( $e->getTraceAsString(), true );
    $log->add( 'new-woocommerce-log-name', $log_entry );

    Note: this method is updating as of WC 2.7

    Starting with WooCommerce 2.7 3.0, logging can be grouped by context and severity. For example:
    $logger = wc_get_logger();
    $logger->debug( 'debug message', array( 'source' => 'my-extension' ) );

    I will try to add to and refine this list as I get more logging tools in my toolbelt.

  • A new job! (pants optional)

    A new job! (pants optional)

    After 3 years working for IronGate Creative, I’ve accepted a position at a new company that will allow me to work remotely full time. I’m super stoked to be on board with Prospress, one of the larger players in the WooCommerce plugin space and general believers in open source software and improving the world.

    My new title is still undetermined, but I’m guessing it’ll be somewhere between “Code Detective,” “Support Sleuth,” and “Bug Squasher.” The position is based on the idea of a “Support Engineer,” but I don’t feel like that’s really following the trend of modern tech companies giving their employees catchy titles like “Happiness Engineer,” “Growth Hacker,” or simply “Ninja.”

    I’ve passed my Lead Developer torch on to someone who is more than capable of filling my shoes, and it is with some nostalgia that I hand over the reigns of some of my beloved projects. I won’t miss commuting, though.

    As I embark on this new position, I’m excited to see how working with a new team will increase my learning curve, as well as how working remotely will decrease my stress. When I told my wife I’d be working remotely full time, she said, “Is this going to affect your hygiene?”

    We all have different priorities…

  • Retro Reggae Posters

    Retro Reggae Posters

    My buddy Zack asked me to make another poster for his reggae night. In doing so, I found a couple of other old ones and I thought post them up here. Full disclosure, I pull heavily from stock vectors, but I still thought these had a cool vibe to them, and they’ve helped me work on my Adobe Illustrator skills immensely.

    xacto_20161107

     

     

    version_2

     

     

    version_1

  • the_date() vs. the_time()

    the_date() vs. the_time()

    These two WordPress functions can be somewhat confusing, and and for good reason: they are nearly identical, and used in similar locations. Both are used to display the publish date (and time) of the post. How are they different?

    the_date()

    the_date() will only display the same date once per page. This is designed to be used primarily in post lists where you want to group posts by publish date, and it would be redundant to show the same date twice.

    For example,

    <?php 
    if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
    
    the_date('Y-m-d', '<h5>', '</h5>'); 
    the_title();
    
    endwhile;
    endif;
    ?>

    Might produce a list of posts like this:

    2017-4-12

    Test Post

    Another Post

    2017-4-11

    A third post

    A final post

    the_time()

    the_time() is more commonly used to get nearly the same results. It will display the date (and time) every time it used, whether on an archive or post template. Similar to the_date(), it must be used within The Loop.

    If you’re in doubt, use the_time()

    Example usage:

    <div><?php the_time('Y-m-d'); ?></div>

    Formatting

    Both functions use standard PHP date/time formatting. However, in a WordPress context, it’s a good idea to use the format that has been set in the admin interface (that’s the point of a CMS, right??). For example:

    <?php the_time( get_option( 'date_format' ) ); ?>
  • Keeping the Web Boring

    Keeping the Web Boring

    There is a lot of temptation to create overly complicated websites. Whether influenced by the client that always wants the page to “pop,” or simply pulled along by the hype train of the latest JavaScript frameworks, it is often too easy to make things unnecessarily complicated. Web developers also tend to be a clever bunch, and it’s tough to resist the temptation to flex one’s cleverness.

    Here are a couple of fittingly short, uncomplicated opinion pieces on why it’s best to be boring and simple:

    also, related:

  • Ergodox with Datamancer keycaps

    Ergodox with Datamancer keycaps

    When you work on front of a computer all day, your keyboard becomes very personal. I love stumbling across unique keyboards, and this one certainly fits the bill. Here’s an Ergodox EZ with Datamancer keycaps. It’s like the clash of two worlds for me: the keyboard I type on daily and my grandmother’s preferred way to write paper mail. Very cool.

    B9BRGCEXHAc7ztR8vzfYUeeE_dzKl0l2YoEFoxnAZtk

    Source

  • Screen Brightness for MacOS

    Screen Brightness for MacOS

    Like many people, I have issues with varying screen brightness when working long hours or in low-light situations. The issue is particularly apparent when switching from a full-screen text editor with a black background to an achingly bright Google search window.

    My solutions thus far have been running f.lux, which changes the color warmth of your screens based on time of day, and wearing out the brightness toggle keys on my keyboard.

    f.lux

    f.lux is an application that has been around since 2009, and has a large support base. It works by changing the screen color (warmth). You can set it to change automatically with the time of day or, like I do, just set a standard warmth to help prevent squinting and eye strain during periods of prolonged exposure to white backgrounds.

    One huge pitfall of f.lux is that you should be very wary of using this program if you are working with any graphics or design-related projects, as it will completely throw off your colors. I made the mistake of creating a poster design, handbill design and web graphics for a music festival only to realize when we received the printed product that there was almost no yellow or orange in the design, all of which I blame on my use of f.lux.

    images

    Shady

    If you are looking to reduce your screen’s brightness well below the default minimum, or at smaller increments, then try Shady. It works by adding a transparent overlay over your display and changing the transparency of it. It’s a pretty simple application of apparently legit origin, and likely low processing overhead.

    shady_before_after

    Lumen

    I just stumbled across an interesting new approach that makes me wish I had thought of it: a program that sets the screen brightness based on your screen contents.

    Called Lumen, it appears to solve one of the main issues I have with my otherwise perfect screens. Check it out!

    Note: as of this posting, Lumen doesn’t appear to work with multiple monitors, and running alongside f.lux is untested.

    demo

     

  • Social VR is weird. Really weird. And probably the future.

    Social VR is weird. Really weird. And probably the future.

    I got nauseated for the first time in VR today, and I’m still not sure if it was from losing my VR legs for a minute, or if it was because chat rooms in VR can get super weird. And there was a baby.

    When Facebook bought Oculus in 2014 and declared social VR to be the future, there were many that were dismayed by the idea, as if the dark overlord had just revealed his plans to control, and therefore ruin, their VR dreams. Mark Zuckerberg has reiterated on numerous occasions that “VR is going to be the most social platform,” and though I agree with him, it is unfathomable to me that people think that he came up with this idea, or will be in any way able to dominate the space.

    Snowcrash (1992)
    Snowcrash (1992)

    The dream of social VR really goes back to Snow Crash (Stephenson, 1992), where the “Metaverse,” a virtual alternate reality that is reached by using one’s computer to interact with others using your avatar, is laid out in great world-building detail. I know that Gibson started pulling at a similar thread in Neuromancer (1984), but I don’t think he fully realized the extent to which social interaction would act as VR’s raison d’être. Like many others, I consumed the book within a few years of its release not quite grokking that VR would someday soon be realized.

    The dream resurfaced in 2003 when Second Life launched, a massively multiplayer online, and ultimately clunky and disappointing, video game aimed at providing a user-created, persistent virtual world. I was fascinated by the idea behind it, and spent far too many hours suspending disbelief in the primitive graphics and low frame rates.

    Though the technical challenges of relatively low internet speeds and the game’s way of delivering graphics (the server would generate the image and send the image to the user) proved to be too much for the success of the game, it was at least a successful step in the direction of the dream of the social virtual world. Yes, there was a lot of weird stuff in Second Life too, from sex dungeons to griefers, but it still felt enough like a video game – 2d screen, clunky controls – that it never really impacted me in a negative way.

    Fast forward to today, when technology is finally starting to catch up with the VR dreams of 25 years ago, there are multiple social VR platforms, and I entered one with no reservations. After a couple of false starts getting things set up, I finally found myself in a room with about 15 other floating avatars hanging around a huge screen showing YouTube videos. There was an interface where anyone can search for and add videos to the list, vote on which one they want to see next, and vote to skip the one currently playing.

    I was immediately hit with a wave of anxiety, which is weird, since I’ve been comfortable with every other VR game I own and have played for a couple of months, and spent countless hours in my 20’s playing social games on 2d screens. This time it felt more real, more immediate. More weird. A video of someone in a wheel chair sloppily eating a chili dog was quickly followed by real footage of Hitler giving a speech, and one of the avatars immediately stood in front of the screen and started shooting ‘applause’ emoji out of his head. After retreating to the back of the room and asking a few questions about how the video interface worked, and about halfway through the subsequent borderline softcore porn Nicki Minaj video, the baby appeared.

    BABY_GettyImages_86481433

    Well, child, I guess. Their avatar was about half as tall as the other avatars, which makes sense in retrospect, since the headsets are tracked in space, and the kid was actually closer to the ground in real life; it was actually a toddler on the other end, donning a VR headseat and fully engrossed. The short avatar was waving their Vive controllers at other people, saying “hi!” and mumbling lots of nonsense, as toddlers tend to do. I was both hit with a jolt of cuteness because, well, toddler mumbling is cute, and a wave of dread, since there are so many potential ramifications of a tiny child wandering around unsupervised in a VR social space. When a death metal video came on the screen and someone said suggestively next to the child, “this song makes me want to kill my parents,” a couple of us went in search of a mod to try and kick the pint-sized orphan out for their own good.

    Social VR has a lot of potential – the immediacy of VR can convey emotion in highly concentrated doses – but much like Reddit or other social platforms, it will only truly shine when heavily moderated, and therefore is perceived as safe. A VR version of 4chan’s /b would be truly terrifying. Call me old and stodgy, but if you’ve never felt the impact of social VR then you don’t yet know how much it starts to feel like real life, and we have established social and legal rules in real life.

    I’m not saying that we should try to rule the VR social space with an iron fist (we know that never works online), but that if we are going to have little kids running around, probably unable to distinguish between real worlds and virtual worlds, then we need to start putting some serious though into how all this is going to work. Because the dream is finally here, and everyone should pay attention.

    As I ripped off my headset last night and tried to recover from my persistent feeling of sweaty nausea, I questioned whether what I had experienced was good or not. I think, just like life, social VR is both good and bad, and extremely weird, and that alone is enough evidence to show that virtual worlds are finally here.

     

     

  • My ErgoDox Keyboard Layout

    My ErgoDox Keyboard Layout

    After nearly a couple of decades playing drums and hammering away at keyboards with horrible posture and typing skills, my repetitive stress pain in my hands and arms have led me to this decision to type on an ergonomic keyboard. As strange as it looks, the ErgoDox is pretty comfortable once you get used to it. Sure, it may take a few weeks of frustration before your brain releases the old ways, but it seems worth it so far.

    IMG_20160701_101832
    The ErgoDox EZ comes pre-built. Those are custom colored keycaps I put on to help my brain with the unlabeled keys.

    One of the great things about this keyboard is that the keys are fully customizable. My preferred layout isn’t much different than the current default, but I’ve changed a few keys around to match my commonly-used functions. For example, I tweak my music volume and screen brightness regularly, and wanted those to be easily accessible (on MacOS, Pause and Scroll Lock adjust screen brightness, and modified with ‘ctrl’, adjusts the secondary screen brightness, if you have one). Here’s my layout:

    Screen Shot 2016-07-01 at 10.41.20 AM

    How to customize your ErgoDox key layout:

    1. Go to the Massdrop Configurator and create your layout, then download the hex file
    2. Download and install the Teensy loader
    3. Click the ‘auto’ button and drag the hex file into the Teensy loader (here’s mine if you want to use it)
    4. On your ErgoDox, hit the Teensy button. This is either assigned to a key on your keyboard, or you can stick a paperclip into the tiny hole on the top right of the keyboard and hit the hardware Teensy button
    5. That’s it!

    Note: When you first plug an unusual keyboard into MacOS, you must go through the keyboard setup process that pops up. That process is quick and painless, but if you back out of that, even if by accident, you will have a hard time getting that setup window to retrigger.

  • Sparrow, oil on board, 18×24 in.

    Sparrow, oil on board, 18×24 in.

    Every once in a while, among the piles of meme-filled dreck, something really poignant gets posted to reddit. This particular one is a bit dark, but it’s a great example of the story behind the artwork being the driver of emotion. Credit to marksonwalls for his great, and somewhat disturbing, art.

    Sparrow, oil on board, 18x24 in. - marksonwalls 2016 - click for larger
    Sparrow, oil on board, 18×24 in. – marksonwalls 2016 – click for larger
  • Entertaining

    Entertaining

    “It is the mark of an educated mind to be able to entertain a thought without accepting it.”

    – Aristotle

  • You paid for Reverend Randy White’s $1.75 million mansion

    You paid for Reverend Randy White’s $1.75 million mansion

    Your tax dollars hard at work
    Your tax dollars hard at work

    When people donate to religious groups, it’s tax-deductible. Churches don’t pay property taxes on their land or buildings. When they buy stuff, they don’t pay sales taxes. When they sell stuff at a profit, they don’t pay capital gains tax. If they spend less than they take in, they don’t pay corporate income taxes. Priests, ministers, rabbis and the like get “parsonage exemptions” that let them deduct mortgage payments, rent and other living expenses when they’re doing their income taxes. They also are the only group allowed to opt out of Social Security taxes (and benefits).

    Washington Post, 8/23/2013, You give religions more than $82.5 billion a year

     

  • Head pancakes

    Head pancakes

    The cars and bling don’t do it for me, but the thought of 100 Japanese maids serving me head pancakes makes me want to change my priorities.

    https://www.youtube.com/watch?v=NewiSNS-vLk

  • Why life is absurd

    Why life is absurd

    “People are commonly thought to have two central concerns: love and work. So much has been written about how little time there is to do both that we need not elaborate. Suffice it to say that when people ask me how I manage to be a philosopher, mother, teacher, wife, writer, etc., the answer is obvious: by doing everything badly. We could abandon love or abandon work, but giving up one fundamental human pursuit in order to have time for a better shot at the other leaves us with, at best, half a life. And even half a life is not really accessible to most of us — life is too short for work alone.”

    Full Article by RIVKA WEINBERG  – http://opinionator.blogs.nytimes.com/2015/01/11/why-life-is-absurd/

    Banner image Translator by Dmitry Filippov

  • Everything happens for a reason

    Everything happens for a reason

    https://twitter.com/biiimurray/status/352177447124467713

  • The Utopia of Free Time

    The Utopia of Free Time

    There is no question that technology continues to make menial jobs redundant: one journalist can now do the job of many, armed only with an email account and google, teams of bank employees that used to process checks have now been replaced with optical sensor technology, and tax accountants are increasingly becoming anachronistic as more and more sophisticated consumer software allows people to navigate doing their taxes on their own.

    Is this altogether a bad thing? It would be easy to spin the story of our fledgling post-singularity society as heading to hell in a handbasket, but it would also to be possible to view it in a positive light. Rather than threatening our survival, perhaps it is allowing us to transcend survival.

    There is a frequently repeated anecdote regarding housewives in the early 20th century and how household appliances were supposed to free up time and ease their burdens. As a plethora of appliances were shutterstock_96193475invented and became available to the average consumer, fancy new household gadgets were increasingly marketed to women as tools to make their lives easier. The conclusion of the oft-repeated story is that even though increasing automation of household tasks made women’s jobs easier in some respects, it actually tied them even further the household. They became beholden to an army of appliances.

    However, a study from 2009 by the University of Montreal suggests that the inventions of the fridge and washing machine are actually responsible for the liberation of women to join the working world. They became more free to pursue higher challenges. It is with this in mind that I wonder why so many people are scared of the increasing automation of our society at large.

    In early 2014, The Economist published what I consider to be an alarmist word of warning against the computerization of jobs.  They believe that as technology replaces more and more low-level jobs, we will have a smaller, more skilled workforce as well as rampant unemployment. Similar to the video I linked to a few weeks ago explaining the inevitable replacement of human labor with machines, it’s a little like the technological forecasts of the mid-twentieth-century, but with a dystopian rather than utopian slant.

    To economists, of course, greater unemployment is the kiss of death to a healthy society. In the short term, I agree that employment results in a more robust global economy, but I disagree with The Economist in one important way: I don’t think that capitalism is the lens through which we need to view this issue. Similar to the Canadian housewives that were able to enter the workforce because hand-washing clothes became obsolete, perhaps being free of the shackles of labor for survival will free us up to accomplish higher level tasks.

    For the last decade or so, we have been bombarded by survivalist, pessimistic science fiction. The 2004 remake of Battlestar Galactica is the perfect example of this proliferation of pop cultural warnings against our dependence on technology. The human race is nearly destroyed by our own robotic creations; the only humans that survive are the ones not connected to the internet, and therefore not susceptible to the high tech domination of the Cylons. I’m not sure exactly when this fear of technology in our culture became dominant; growing up in the ’80s and ’90s, there was always a Star Trek to balance out the Bladerunner, a Diamond Age to balance out the Neuromancer.

    replicatorIn the Star Trek version of the future, you can press a button, state what type of food or beverage you want, and it will appear. The protagonist is then free to discuss interstellar politics at his or her leisure. Are they bemoaning the loss of cafeteria jobs that inevitably succeeded the invention of such a food-creation device? No, that’s silly. They’ve surpassed survival by using technology, allowing them to spend their free time doing post-survival things, like drinking earl grey tea and discussing alien politics.

    Just as household appliances allowed many previously housebound people to enter the workforce, the technology that will make our workforce obsolete will free us to spend our time doing more important things.

  • Humans Need Not Apply

    Humans Need Not Apply

    A chilling 15-minute look at how human jobs are being replaced by ‘bots, and we aren’t ready for it.

  • And fuck the God of War

    And fuck the God of War

    “People under the age of 20 have this massive hole in their soul. And they have built their personalities around cynicism. Cynicism means, simply, aping or putting into an ironic form, mocking, existing institutions, instead of building institutions of your own.

    What I’ve discovered is that because these people have such a deep need for something to believe in. Someone like me or you who can come along and show these people that there is a meaning to life, that there are things worth believing in, that there are things worth being passionate about, they respond immediately.

    I’ve been searching the Gods all my life and now I know them, the Gods inside of us. Or I feel I do.

    Now, we’re either going to have the new Adolf Hitler’s coming along, who know how to manipulate this need, and do it with the new nationalisms and the new tribalism’s, and the new hate groups, or we’re going to have a you or a me, who will come along and pour a positive message, a positive sense of something to believe in, a positive crusade for emotionality.

    The only messiahs who exist are as human beings. We human beings are all basically cockroaches at heart. That is to say, we’re insecure when we’re alone by ourselves, we have all kinds of self-doubts, we have our depressions, and we have all kinds of reasons to believe that we’re nobody at all. But it’s the ‘nobodys-at-all’ who become the Isaiahs of the world, it’s the ‘nobodys-at-all’ who become the Einstein’s of the world, it’s the ‘nobodys-at-all’ who become the Jesus Christ’s of the world.

    It’s up to human beings to be the messiahs. We’re the only ones who are there to do it. And we have to do it. We have to do it. Because if we don’t do it, someone with an equal belief and passion to ours, who believes that the way to achieve things is through the old animal way – built into our limbic system, built into the lower parts of our brain, who knows that the best way to unite people is by uniting them in hatred against an outside group; and uniting them in mass murder.

    We have to come along before that person comes along. We have to fill that void, and we have to fill it with positivity. It’s about digging into the elemental passions. All of this plays a part in trying to give to the new generation a movement that’s based on something extraordinarily passionate. That you can powerfully believe in. That you can use to advance humanity tremendously, absolutely tremendously, but that excises, deliberately, the God of War.

    When you find the Gods inside yourself, you’ll find the God of War. You’ll find the God of bloodlust. You’ll find the God of genocide. And he will be one of the most powerful passions in you. And you have to knife him out of existence. You have to freeze him in his own private Hell, and make your positive Gods the Gods that take you over.

    And by ‘the Gods that take you over’ I mean you have to find those passions that are so much more powerful than you, than anything you’ve been allowed to express in your life, and making those things the things you work on. In other words, not putting off until you’re 40 or 50 the things you feel passionate about at the age of 15 and 16 – but going directly to those things, and trying to implement them when you’re 20.

    Pass ‘Go’. Forget the 200 dollars. Go directly to Park Place. And put your life there, on the line, with all the emotion and power and passion and insight in you.

    And fuck the God of War.”

    – Howard Bloom

  • Workaholics

    Workaholics

    I flew over my workplace on Saturday, and noticed that someone was parked in my spot. Coming in on Saturday to work, sheesh… workaholics
    WP_20141115_014

  • We are what we eat

    We are what we eat

    “We do not know the effect of this grand experiment that is being visited upon humanity by the purveyors of genetically modified organisms. If, in fact, we are what we eat, then we certainly should be mindful of the nature of the products we are consuming, so we know what we will become.”

    – Dennis Kucinich on GMOs

  • Sunset

    Sunset

    “I have a stalker, a beautiful one: the sunset. Every day she’s there, watching me, whether I watch her or not.”

    ― Jarod Kintz, This Book Has No Title

  • The weight of thoughtfulness

    The weight of thoughtfulness

    Einstein 1948
    (L-R) Cord Meyer Jr., president of United World Federalists, Inc., visiting physicist Albert Einstein at his home to discuss Russia’s attitude toward world government. – 1948 Alfred Eisenstadt

    According to Wikipedia, Meyer joined the CIA shortly after this.

  • A reliable indicator

    A reliable indicator

    “When someone takes to calling things “hipster”, it’s a reliable indicator that you can safely ignore the rest of what they’re saying.”

    LegionSB

  • “It’ll be easy…”

    “It’ll be easy…”

    When a client says, “It should be pretty easy and won’t take long,” it invariably means it will be a lengthy and painful slog through all of the seven levels of Hades.

  • The two states of every programmer

    The two states of every programmer

    BzmDP_yCEAAvXdx