Archive for February, 2015

One weird trick to induce lucid dreams and out of body experiences

February 23rd, 2015

What if I told you that I have one weird trick to help you have a lucid dream and/or out of body experience? This particular trick has been well documented elsewhere, but if you don’t want to read an entire book I’ll give you the quick version here. Also note that this is intended for weekends or non-work days in general, because it requires sleeping in a little.

What’s the difference?

Now you may be asking what the difference is between a lucid dream and an out of body experience. In the former it’s like a traditional dream, except that you’re lucid enough to do what you want — it’s not just a passive dream experience. Yet all the normal weirdness of a dream still applies.

In an out of body experience you typically start by “waking up” but soon realize that your surroundings are a little off. This is known as a false awakening. For me at least these out of body experiences don’t feel like a dream, yet are recognizable thanks to suffering from dream-like continuity problems. Additionally, physical things that don’t usually work in dreams (mirrors, light switches, etc.) will often function to some extent. In many ways it’s like a lucid dream only more grounded.

There’s no real yardstick for determining whether an experience is one or the other. Dreams, lucid dreams, and out of body experiences can and will blend together along a spectrum of consciousness. For the rest of this post I’m just going to stick with the term “lucid dream,” but I’ll be referring to a variety of conscious sleep experiences.

Cut to the chase

So here’s the trick: wake up around an hour or two before you normally would. Use this time to read a book, check Twitter, or anything else that requires little effort and won’t wake you up too much.

At about the time you’d normally wake up, go back to sleep. Ideally you should be a little tired at this point, but more or less fairly alert. You’ll probably have trouble falling asleep, which is a good sign — focus on keeping your mind clear of distractions. Any meditative exercise will do, my favorite is slowly counting your breaths backwards from 100.

Now comes the important part: relax. At this point your brain will take you directly from being awake to being in a dream, so it’s important not to let anything that’s about to happen startle you into waking up. For some folks this will take a bit of practice.

The first thing that will happen as you transition into sleep mode is you’ll hear a buzzing, almost chainsaw-like sound that fades in and out. Even though it’s all in your head it can sound both loud and real. Don’t worry about it, it’s natural and happens to everyone.

Next, you’ll see a series of images float into your mind’s eye. You might see people, animals, etc. Sometimes they’ll be a little scary, but again it’s all in your head. The images will slowly start to move, and then *POOF*! You’re in the dream world now!

With any luck, the transition from being fully awake to your body being asleep will leave you in a fully lucid state. Congrats!

How it works

Many lucid dreaming books explain the same technique. Technically it’s called a Wake Induced Lucid Dream (or WILD) because you’re inducing the lucid dream from a fully awake state. But most of the books leave out one key detail: this type of dream induction only works in the morning hours.

Why? Let’s look at this sleep diagram from Wikipedia:

First note that dreams can only occur in the REM cycle, which is marked in red. As you can see, the time between when you fall asleep at night and the first REM cycle is over an hour long — most of us can’t maintain consciousness that long while asleep. But as the night progresses, the REM cycles get longer, and you can go (as the diagram indicates) directly from being awake into REM.

Waking up an hour or two before your usual time deprives your brain of that last extra long REM cycle, which means that when you finally sleep again, it will almost certainly jump straight into REM and thus a dream. The only tricky part is maintaining consciousness during the transition.

Having any dream right before you wake up makes you far more likely to remember it. If you’re serious about lucid dreams, keeping a dream diary will also help build your ability to recall any and all dreams.

By the way, if you’re wondering what to do in a lucid dream, just explore! You may be amazed by what you find hidden in your own mind. For a strange experience, try looking at your hands for a minute. Shoot me an email when you find out what happens — as they say, “You’ll never guess what happens next!.”

My own QML TreeView

February 15th, 2015

It’s Valentine’s Day and here’s the point where I have to confess my love as a software engineer for QML. It’s a markup language for building simple modern UIs with Javascript controls, and can be bound to C++ and Python via Qt. Since it’s based on Qt it runs on pretty much any modern desktop or mobile platform you can think of.

But like any relationship, sometimes one is left wanting for more. Sure, QML is great but it has flaws that are hard to overlook. For example, there’s no “tree view” component (think: file system UIs, Windows RegEdit, etc.) which is a deal breaker for some use cases.

That deficiency ends today.

I’ve been busily working on my own tree view implementation, which you can find on GitHub. It supports drag and drop rearranging and folder creation with a mouse or touch interface. Like the iOS home screen, folders are limited to one level (i.e. no subfolders.)

Here’s the sample test harness in action:

The trick? It’s all a standard QML ListView with a special type of delegate, my own RearrangeableDelegate.

The items can be rearranged by pressing (or long-pressing, see update below) on them, then dragging to the desired space. If you position it between two items a line appears, and releasing the mouse positions the item at that location. Positioning on top of an item causes the two items to pop out into a new folder. Dragging the last item out of a folder deletes the folder. If you want to have special items at the top of the list that can’t be rearranged, that’s supported via the numStationary property.

Everything is designed to be styled to your liking. Want to change the drag border, the opener image, the indentation, etc? Easy! Just set some of RearrangeableDelegate’s existing properties and you’re good to go.

The UI state of each item is stored in the list model itself, which provides an easy (if somewhat hacky) way of maintaining the UI state with a database or settings file. Here’s what you need to provide, subject to change:

ListElement {
    // Unique id (integer)
    uid: 1;

    // Used for drag and drop UI. (Persistence not required.)
    dropTarget: "none";  

    // True if a folder, else false
    isFolder: false;     

    // -1 if not in a folder, else the uid of the parent
    parentFolder: -1;    

    // For folders, this indicates whether their children are
    // displayed. Otherwise, indicates if visible.
    folderOpen: true;

Best part: I’m giving away the entire thing for free under the MIT license, which ought to satisfy pretty much everyone (except for Richard Stallman.) Take my code and do what thou wilt. If you encounter a bug please file a new issue or fix it on your own and submit a Pull Request. Either way I — and perhaps other QML developers — will be eternally grateful for your ongoing efforts to make up for this missing QML component.

UPDATE: After convincing Hryx to do some user testing, we decided that long-pressing wasn’t discoverable enough for a desktop. So now there’s a flag called dragOnLongPress to control this behavior. By default it’s set to false so that a long press isn’t required to move an item around. You can set it to true in situations where a long press to move makes sense, such as on touch and mobile devices.

The John Barrowman Theory

February 6th, 2015

Image credit: Phoenix Comicon

What if the television shows Doctor Who, Desperate Housewives, and Arrow are all part of the same universe? Crazy, you say? Well sure. But let me explain The John Barrowman Theory to you anyway.

After the events in Doctor Who and Torchwood, the enigmatic man who calls himself Captain Jack travels forward in time and discovers Earth is destroyed by an environmental disaster. Rather than work with Torchwood he decides to take matters into his own hands. He travels back in time and assumes the name Patrick Logan to conceal his identity from Torchwood.

As Patrick, he becomes an eco-terrorist to stop the impending doom. To escape his crimes, Patrick fakes his own death in an explosion (an easy feat because he’s immortal) then changes his name to Malcolm Merlyn. In the face of tragedy Malcolm decides to become even more of a badass and trains with Ra’s al Ghul’s assassins. When things take an ugly turn, what does Malcolm do? He fakes his own death again, that’s what.

See? There’s a pattern here — morally ambiguous, vengeful, mortality-challenged. Jack, Patrick, and Malcolm could easily be the same character in the same universe. And that’s the John Barrowman Theory.

Mind = blown.