Thursday, October 24, 2013

Golang, cgo, and XCode 5

TL;DR: Don't. Stick with XCode 4 for now.

I don't know much about developing on Mac. I may also be a moron. I'm a Linux guy and can at least make the claim that I'm a programmer. I'm definitely comfortable with command line tools and relatively uncomfortable with IDEs.

I've been working on a video game project on Mac in go, using go-gl. The go-gl suite is a set of thin wrappers around C opengl libraries. As such, it depends on local C compilers and the cgo compiler. My libraries are installed via MacPorts which required installing XCode and its command line tools. Those command line tools also provide tools and headers that will be used by cgo to compile go code and C code that are linked together.

When XCode 5 came out it showed up as a regular upgrade which I followed. I dutifully installed the new command line tools. I later found that I could no longer compile my game code. Any code that didn't require go-gl was working fine.

Eventually I found that the issue was that XCode 5 no longer includes GCC. I eventually figured out that if I install gcc47 from MacPorts, prefixed builds with CC="gcc-mp-4.7", built go from source, then prefixed all my go get and go run commands wit the above CC envvar I could get it to work. However, it would no longer produce static libraries for the opengl wrappers and my compiles that were previously instantaneous where now taking on the order of 10 seconds.

I upgraded to Mavericks today and my XCode along with it. It didn't help. Being frustrated I did more digging and found that if I went back to XCode 4 things should be fine again. I ripped out XCode 5, navigated the Apple Web Maze to find XCode 4, download it, grab the command line tools, etc. Seems to work now the way it used to.

Except, MacPorts is broken. Mavericks doesn't have /usr/bin/gnutar so I have to ininstall MacPorts. There's no binary package for Mavericks so I have to do a source install. That was at least painless. This gripe has nothing to do with go, of course.

Friday, October 18, 2013

Be Careful With Your Brain Drugs pt II

At a friend's suggestion I tried setting an alarm for a couple hours before I intend to get up and when it goes off I take my Cymbalta and go back to sleep. The idea is that after a couple hours of absorption the "upper" effect of the medication will be there and it will be easier to hop out of bed and be an obnoxious morning person.

Instead I had incredibly bizarre dreams. I normally have weird dreams but this was on another level. While they had what passes for dream continuity, I can only recall fragments and I won't try to reproduce them here.

The really strange thing was after I got up and into the shower. I found myself experiencing real paranoia. I wondered if someone had installed a camera in my bathroom. I wondered if someone else was in the room. I wondered if my girlfriend was going to ambush me when I reentered the bedroom.

For each of these thoughts it only took me a second to realize that it was unfounded, but when the thought occurred it felt plausible for an instant. Very strange.

I'm going to keep trying this for a couple days to see if it persists, settles down, or was just a fluke and additionally to see if it provides actual benefit. So far I don't feel particularly more alert but having taken the meds early they should diminish early and I will hopefully find it easier to get to sleep early.

Tuesday, October 15, 2013

Be Careful With Your Brain Drugs

I've always had trouble dragging myself out of bed. I've mentioned here that I have sleep problems and the early morning is the worst time for my motivation.

I take my Cymbalta once per it after I get up it. It's therefore at its lowest concentration in my system when I'm getting up. Since it has an "uplifting" effect I figured maybe it would make more sense to take it just before I go to bed so it will still have a fairly high concentration when I got up. The actual result was that it made me jittery at night and had trouble getting to sleep and staying asleep. I switched back to mornings pretty quickly.

I had run out yesterday but had a new prescription ready to be picked up. I grabbed it in the evening and took it as soon as I got home. It wasn't until about 7:00am that I realized why I couldn't sleep. My day was pretty much wasted for lack of ability to concentrate. I think I would have been better off not taking it yesterday.

Thursday, August 22, 2013

Sleep Study Redux

Got the results back from my sleep study and all I can say is that I'm pretty darn confused:

Clinical Background:
34 year-old patient is now referred for an unattended diagnostic
sleep recording.

PROCEDURE: 
An ambulatory PSG with a digital sleep system for recording
respiratory effort, oximetry, body position, airflow, pulse rate,
and limb movement channels.


SUMMARY: 
Total recording time was 253.1 minutes. The patient estimated a
total sleep time of 178.0 minutes. 


Respiratory Analysis demonstrated 5 obstructive apneas and 12
hypopneas, with an APNEA HYPOPNEA INDEX (AHI) of 5.7. The
patient spent 0.0% of total sleep time in the supine position,
with a supine AHI of 0.0, versus a non-supine AHI of 5.7, though
the body position cannot be verified. 

The lowest oxygen saturation was 89 %, and 0.0 % of the sleep
time was spent at saturations below 90 %.

The pulse rate was at 78 beats per minute.

The PLM Index was 50.9 events per hour. 

CLINICAL INTERPRETATION:
1. Sleep study findings are consistent with mild Obstructive
Sleep Apnea. The overall RDI was 5.7 events per hour of sleep. 
The lowest oxygen saturation was 89 %. This unattended study
likely under estimates the severity of the patient's sleep apnea
(as measured by the AHI) as frequent periods of flow limitation
in addition to the scored events were observed, but these could
not be scored as respiratory events due to lack of EEG channels
in this limited channel unattended sleep study.
2. Evidence of snoring was present.
3. There is also evidence of frequent periodic limb movements. 
Due to lack of EEG channels in this limited channel unattended
sleep study it cannot be determined whether these leg movements
were present during sleep and if they are associated with
significant cortical arousals and sleep fragmentation. 
4. Positive airway pressure therapy (CPAP) is usually the most
effective treatment option. Surgical treatment modalities are
alternative options. An oral appliance may be effective
treatment in mild cases. The patient should avoid sleeping in
supine position (i.e. side-sleeping or elevation of the head 30
degrees is preferred). Other non-specific adjunctive treatment
include significant weight loss, and avoidance of sleep
deprivation, alcohol and nicotine. 
5. It is recommended that the patient come-in to the sleep lab
for a full-night attended polysomnographic titration sleep study
to determine the optimal positive airway pressure therapy and
this attended sleep study recording is indicated for further
evaluation of periodic limb movements as well. He will be called
to schedule this study. 

Sleep study raw data was manually reviewed and the report
reviewed, edited, and electronically signed by me. Please feel
free to contact me if you have any questions.

I reported on the form exactly what I wrote in my previous blog entry. I'll reproduce the focus of my confusion:

I doubt there will be anything useful in the hour or less of sleep data that got recorded. I am unlikely to try this again.

I'm not confused about how much sleep I got during the study. I was very careful to write it down. I got less than 60 minutes of sleep. While that may not be entirely precise, I can guarantee I didn't get three hours of sleep. So I apparently have apnea events that I don't notice while I'm awake. I think I can explain the restless limb movements; I was using my limbs.

I am now more turned off toward this.

Thursday, August 15, 2013

Boozing, not Snoozing

My sleep has been pretty poor lately and I began to suspect that a recent increase in my enjoyment of fine liquors might be related.

The last two evenings I've abstained and found that my sleep has been better. I've found myself awake less in the small hours and less sluggish in the morning.

I'm a little disappointed since I've been enjoying trying new boozes. I'd like to continue enjoying it so next I have to figure out if there's a cutoff time and if the limit is two, one, or zero drinks.

Wednesday, August 7, 2013

(No) Sleep Study

Did my sleep study last night. My borg assimilation included the following:

  • An elastic band around my chest with a sensor in the middle and a wire coming out there. This is to monitor breathing.
  • An elastic band around my stomach with a sensor in the middle and a wire coming out there. I presume this is also to monitor my breathing.
  • An accelerometer taped to the center of the chest band to monitor my position.
  • A sensor taped to the outside of each calf muscle to detect restless legs.
  • A microphone taped to my neck to detect snoring.
  • An oxygen sensor on my index finger, taped to my hand.
  • A nasal cannula with side tubes taped to my cheeks to monitor the pressure of my breath.
  • All wires and tubes running to a recording device.
I also had a form to record when I turned on the device, when I went "lights out", which periods I was awake for during the night, my final wake time, and time when I turned the recording device off.

I got wired up about 11:00pm and read for a bit as I normally do. I was ready to go to sleep about 11:30pm. I got to sleep in about 15 minutes I think.

My girlfriend came to bed about 1:00am which woke me up and I couldn't get back to sleep. I stayed in bed trying to get back to sleep until about 2:00am at which point I got up and took 3mg of Melatonin and sat in a chair with a laptop until the Melatonin could kick in.

About 3:00am I felt I was ready to sleep so I laid down again. About 3:30am I gave up trying to sleep with all wires and such so I shut off the machine and pulled the sensors off. I think I eventually got to sleep about 4:45am.

I doubt there will be anything useful in the hour or less of sleep data that got recorded. I am unlikely to try this again.

Tuesday, August 6, 2013

Dragging My Ass Out of Bed (Redux)

I saw a sleep doctor yesterday for a consult. I described my situation, reproduced here in brief:

  • I used to have a great deal of difficulty getting to sleep. That's mostly been resolved with medication and therapy addressing the thought patterns and emotions that were keeping me up.
  • I toss and turn in bed (thrashing we call it).
  • A relatively recent development: I wake up frequently to go to the bathroom but fall back to sleep quickly. This change coincides with taking Cymbalta but that contradicts it's indication as a drug with success in treating incontinence.
  • If I sleep on my back it's reliable that I snore, sometimes such that I wake myself up. Consequently I try to never sleep on my back. I also never sleep on my stomach.
  • When I wake up I feel like a bag of smashed assholes. The earlier I wake up, the worse it is. This is lethargy in the best case and great nausea in the worst case.
  • It's about 3-4 times a year that I wake up feeling rested and refreshed.
  • No record of waking up unable to breathe, short of breath, headache, etc.
  • While in college, when I had a variable schedule and no job, my sleep cycle would consistently drift forward around the clock.
  • I often have difficulty focusing at work, especially at the beginning of the day, highly dependent on the quality of my sleep.
  • I drink caffeine but on weekdays rarely have any after 2:00pm.
The doctor's opinion was that my circadian rhythm is later than most and that I should get up later than what I normally try (6:45, with mixed results), maybe 8:00.

I'm a little disappointed because if I'm leaving the house by 8:00 I generally contend with very little traffic. 8:30 or later and my 4.5 mile drive to work is on the order of 20-30 minutes. I also like the idea of getting to the office early and finishing my day early.

Of course, if I find that my workday focus and energy level are improved I'll be getting more done and feel better about the day. I also think it will help with my mood and may make it reasonable to bring my Cymbalta down from 90mg back to 60mg. That will be a decision to look at in a few months.

This morning was my first day intentionally getting up at 8:00 and I have to say that I do feel a little more attentive and focus. Not a huge difference, but I understand that it can take a few weeks of getting up at the same time for my body's schedule to settle.

Today I have to pick up an at-home sleep study device to use this evening and return tomorrow. I'll provide an update when I get the results back.

Monday, July 1, 2013

Dragging My Ass Out Of Bed

I'm terrible at sleeping. I frequently have trouble getting to sleep. I frequently wake up in the middle of the night. Maybe a few times a year I'll wake up feeling rested.

Since I've been having a tough time lately I've been really lax about getting up at 6:50, when my alarm goes of. That alarm has transformed into "wake up to evaluate how tired you are and set the next alarm". I really want to be an early riser but I always feel like crap in the morning so it's tough. I appreciate anything that forces me to get up no matter how I feel, like early morning appointments.

This week I've set a goal for myself; get out of bed every day when my alarm goes off regardless of how I feel. I'm trying to train myself to have a mantra: this will pass. Feeling like crap when I get up will pass. When the alarm goes off, I'm going to focus on getting moving so that I just get the feeling like crap over with rather than focusing on feeling like crap and sleeping in, which just delays the discomfort but doesn't really lessen it.

I succeeded this morning so there's one day to check off. As I was in the shower (where I tend to get insights) I realized that by sleeping in every day I had been starting each day off with failure. I knew I should be getting up but just didn't feel up to it. Later, having slept in, I'd feel guilty about having a late start on the day. That's a pretty poor precedent for the day and tough to recover from. Every day that I can get up early is a day I start with success. This is good practice.

Monday, June 17, 2013

Depressing

In the not-so-distant past I lamented the cultural perceptions of mental health in the United States. This year my depression has been particularly bad so I've made the most effort to improve that aspect of my life. I recently realized that I've consciously avoided discussing my depression with my peers. This isn't to say I need to bring it to their attention, but avoiding the subject doesn't make sense if I feel like more people should be talking about it casually.

I've been on Cymbalta for a few months and it's been really, really helpful - in ways that neither Prozac nor Celexa were (SNRI vs SSRI). I've been able to see how totally out of proportion my emotional responses were in comparison to the stimuli. Things that shouldn't have bothered me had made me really angry, or really defeated, or both. Things that should have been enjoyable and fulfilling were insignificant. With the SSRIs I found that my emotional spectrum was just narrowed. Bad things weren't really bad, but good things weren't really good. Now it feels like things are pretty well sorted out. I'm not skipping around giddy, but I feel like what I think normal, healthy people feel like.

When you're depressed for a long period of time, your thought patterns get warped. You get trained to be frame everything you experience through negativity aimed at yourself. The properties you admire in others are reflections of your shortcomings. Remorse (regret for a bad action you've taken) becomes guilt (the belief that you're inherently bad). All insecurity, doubt, and discouragement are amplified. Simple tasks meet with defeat before they are started because your mental habits tell you that you can't do them.

I've been regularly seeing a therapist for most of the year. Behavioral therapy is much like physical therapy. A trained professional can discern between your healthy motions (thoughts) and your counter-productive ones and help you find the right ones. A few weeks ago my medication seemed to be less effective. My moods were crap, but I found that I was able to maintain reasonably positive thoughts. Eventually the low period passed and things were back to good. Also like physical therapy, much of the purpose of the therapist is to ensure your movements are correct; the actual rehabilitation occurs when you're away from the therapist, practicing what you've learned.

Overall, that's the gist of my situation. I intend to write about my experiences as much as I can. I'd like it if this were helpful to others, but that's out of my hands. It will certainly be helpful to me.

Thursday, January 17, 2013

New Year's Inventory

Now that we've all failed our New Year's Resolutions, we should focus on something genuinely productive. I don't do New Year's Resolutions. Culturally we rarely seem to set them in earnest so I find them to be of little use.

Instead, do a New Year's Inventory. Look at different aspects of your life and assess where you really stand. Do you do well at these things or do you do poorly? Is your performance so low that you should be striving to improve or so high that you should be mentoring?

Consider the following:

  • Family
    • Are my family members adequately cared for?
    • Am I a positive influence on their lives?
    • Do I distribute my attention appropriately?
    • Are there strained relationships I should be mending?
  • Friends
    • Do my friends add value to my life?
    • Are they trustworthy in intention, word, and deed?
    • Do I provide the support they deserve?
    • Am I a positive force in their lives?
  • Career
    • Am I performing at the level I should be?
    • Am I doing what I can to improve my career?
    • Can I be doing more to derive more satisfaction/less stress from my job?
    • Do I cultivate the respect of my boss/peers/subordinates?
  • Finances
    • Am I meeting my financial obligations?
    • Am I confident about the next few month's finances?
      • Next year?
      • Next decade?
    • Am I prepared for a few months of no income?
    • Have I prepared to provide for those who depend on me in my absence?
  • Health
    • Am I eating well? How do I know?
    • Am I active enough?
    • Am I getting sufficient rest?
    • Am I taking steps to prevent illness and disease?
    • Am I managing stress and negative emotions well?
All of those are off the top of my head. You should add the categories and questions that are relevant to you. The first year you do it it is informative. Doing it every year tells you what you're doing with your life.

It's critical to be honest with yourself, not just about your shortcomings but also about your strengths. Identifying where you should improve is the purpose of the exercise but if you don't identify your strengths it's difficult to feel empowered in tackling the other challenges.