I recently came up with a couple of pipeable perl one-liners. perl -pechop is a shortened form of perl -p -e chop. Here are the parts of it, explained:

  • perl – the perl executable, here for completeness. to learn about the options, type man perlrun into your terminal.
  • -p – perl assumes a loop around the program where it reads each line from the standard input and prints the output. since it’s a single character option that doesn’t take a parameter, it can be grouped with other options.
  • -e – evaluates (runs) the string that’s passed to it. the way perl’s option parser works, when an option takes data, it uses the rest of the command line parameter. so it can be shortened from perl -p -e chop to perl -pechop. This makes it short enough that typing it in often shouldn’t be a problem.
  • chop – the perl subroutine chop takes the current input and chops the last character off it. It’s handy for chopping the newline. For example pwd | perl -pechop will print the current directory to standard output. It can then be piped to the command to save the current directory to the clipboard (pbcopy on mac os x.

Another perl subroutine, chomp, removes the last character of a line but only if it’s the newline character. It’s useful when you don’t know if there’s a newline. The corresponding perl one-liner is perl -pechomp.

life is the variety of spice (life is about the variety of spice)

spice is the variety of life (spices, and things analogous to it, are what makes life interesting)

variety is the life of spice (spice may not be able to observe itself, but during the life of cumin various things happen to it)

variety is the spice of life (original)

Update 2013-11-10: I added some edge cases to show the completeness of this format.

Kris Zyp’s jsonpointer is a tool for addressing part of a JSON object, that’s designed to be both powerful and familiar. It supports any value for a key that JSON supports, yet it looks like a path from a URL or a filesystem.

A jsonpointer is the path from the root node of a JSON document to either itself or an interior node. A jsonpointer starts with a “/”. A “/” is also the simplest jsonpointer. After that, it contains one or more keys or indexes (in JavaScript an index is a key, but the JSON spec makes a distinction between keys and indexes), separated by “/” characters. To include a “/” character in a key (JSON supports this), use “~1”. To include a “~” character in a key, use “~0”.

What it lacks are relative paths and home paths (“~”). Since jsonpointer requires that it start with a “/”, this frees me to prepend anything but “/” to the start of the expression. Here are the things I can prepend:

  1. A dot (.), which makes it a relative path, like “./foo”.
  2. Two dots (..), which makes it a relative path from the parent node, like “../foo”.
  3. More than two dots (…), which will go up extra levels. “…/foo” would be analogous to “../../foo” in UNIX file paths. “../../foo” in my augmented json pointer would go to “baz” to quux in this json object: {“foo”: “not here”, “a”: {“b”: {“c”: “baz”}, “..”: {“foo”: “quux”}}} That is, instead of jumping up three levels, it would jump up two levels and interpret the second “..” as a key in a json object. Two dots go up one level, three dots go up two levels, four dots go up three levels, and so on.
  4. A tilde (~) makes it a path from the home directory.

Some examples of edge cases:

  1. the absolute path [“.”, “hello”] to access foo in {“.”: {“hello”: “foo”}} will be /./hello
  2. the relative path [“.”, hello”] to access foo in {“quux”: {“.”: {“hello”: “foo”}}} where the current path is /quux will be “././hello”.
  3. the relative path [“..”, “baz”] to access “foo” in {“quux”: {“..”: “hello”}, “baz”: “foo”} when where the current path is “/quux” where there is a “..” in the current node will be “../baz”. To access “hello” using a relative path from “/quux”, use “./..”.

I tried out hood.ie today after hearing about it a few times and I think it’s worth giving a shot, if you’re interested in rich web applications. It’s easy to install for what it does, which is set up a local node.js and couchdb environment with an admin interface. Deployment looks like it will be really easy, too.

Tonight as I was walking around in downtown Boulder, someone outside a bar said hi to me and asked me how it was going. I saw he was in the mood for talking, and I didn’t mind, so I told him “Fine. Just getting used to not drinking.” I told him how I’d quit a week and a half ago, and that I’d had nothing to drink. I told him about my past, and he said “you love to get drunk, right?” I said no, but he persisted in making his argument, and I agreed with him. I realized that I like a feeling that I’ve had while I’m drunk, and that I didn’t always get that feeling when I’m drunk, so sometimes I didn’t enjoy it. I’ve also got as good of a feeling many times without drinking, without the negative effects afterward. But I came to agreement with him, and as a result I saw my self better. If I really hadn’t liked it, I wouldn’t have done it again.

He, I’ll use the name Steve for the purpose of this post, then told me his story. He said that he is in alcoholic, and he loves getting drunk, and he’s gotten himself in trouble many times, and was once in a terrible place. He pointed out that he’s gone off and on alcohol, and that he was in an on period, and drinking that night. I said that I’d only said that I’m done a couple of times, so this isn’t something that I’d failed at often, and that I was hopeful this time. He said I’d eat shit. I told him, “No, I can’t think like that”.

I’m not going to think like that. So really the answer to “if I drink again” is that I won’t. But he gave some advice for what to do that’s tucked in my memory if I ever need it. It’s to not feel bad about myself, and to pick myself back up after I fall. And it’s good advice. I’ll feel bad enough about myself if I do drink again, that I won’t need to put any extra effort into feeling bad about myself, so I should instead try to be optimistic. I don’t plan on ever needing this, but it’s nice to know it’s there.

The technique I’m using to quit drinking is to remember that for just over three years of my adult life, from when I was 18 until a month after I turned 21, I had literally no alcoholic beverages. I had many opportunities but said no each time. I know what it’s like to not drink at all. And I’m going to assume this part of my identity again, but try to have it be unshakeable this time around.

I am drunk right now, and it’s fine. I am not falling down drunk but “I’ll drink more than I planned” drunk. I don’t have a source of alcohol and its effects are wearing off so I’ll be fine. But it’s clear to me that I’m better off without alcohol, because tonight I was feeling fine but I still allowed myself to get inebriated beyond my control.

I grew up Mormon. Mormonism is a religion that takes a hard line against alcohol. It’s forbidden. I love my family and I wanted to believe Mormonism (to the point of capitalizing it when I write about it), but as many people who were raised religious but became atheists or agnostics have done, I researched and couldn’t believe it anymore. I still have moments where I want to believe it but I just can’t. What I’ve found from my research contradicts my interpretation of Mormonism. I didn’t, and don’t, accept any watered down interpretations of Mormonism as real Mormonism, so there are certain things that I believe have to be literally true in order for me to believe that Mormonism is true. And some of these are refuted by scientific observations which I refuse to deny.

When I left Mormonism my worldview was shattered. I was in college, only visiting my family on occasion. I wound up being one of those ex-members that members of a religious group love to vilify. My rules that I only had because I was Mormon went out the window! I still had compassion that I felt as a human being, but I had no rules about certain things. I tried to keep things the same because I feared change, but I was also frustrated with how I was living a lie and I looked for ways to rebel. Eventually I tried a Corona, at the age of 21. It was a bit like I expected. I had clearly crossed into another land, but it wasn’t enough to be out of control. It was what I expected, and also the dreaded feeling of doing something that I had vowed never to do, back when I had a different belief system.

A few months after that I tried drinking on occasion. I got drunk a couple of times but felt like I never really lost control, any more than when I’m mountain biking I could fail to turn and wind up falling off a cliff. My lack of disdain for hedonism combined with my lack of knowledge about alcohol wound up with me in the emergency room for drinking too much alcohol following my first introduction to “jungle juice”. Jungle Juice is a fruity drink that sometimes contains a lot of hard alcohol. It’s easy to drink, but when made strong, has a strong effect on intoxication. After having some fruity Jungle Juice I was too drunk to want to stop drinking, and I wound up in an emergency room having my stomach pumped. This was slightly more than ten years ago. I’m not sure I remember the ambulence arriving to take me to the hospital but I distinctly remember waking up in the hospital thinking that I’d really and truly made a mistake. I went to a class meeting, ate pizza, and pretended everything was normal until I talked to my dad and he knew about it. It turns out that the police chief was mormon and a friend of my dad’s and he told him about it.

I realized that my mistake had partly been because I lacked knowledge about how much alcohol was dangerous, and which drinks had how much alcohol in them. I chalked it up to inexperience and drank alcohol on occasion.

Since then there have been a couple of times when I’ve got drunk and thought, wow, if I wasn’t with good friends it could have been a problem. I thought I learned from those experiences and adjusted my behavior, yet they happened again.

Today I planned to drink three drinks but drank six, and wound up saying stupid things that are in fact a part of my brain and perhaps should come out, but came out in a way that wasn’t fully under my control. Not being in control is a bad place to be in. Tonight I was with a good group of people, at a well tended bar, and still got more drunk than I should have. I think my experiment in drinking has shown, that due to either psychology or a combination of psychology and physiology, that I’m not able to handle alcohol. I was reminded of a post by Paul Carr where he publicly stated that he’s going to quit drinking. I realized that that’s just the thing for me, so here I am publicly stating my attention to quit drinking, even alcoholic beverages that were inevitably going to be discovered by an industrious species, like wine.

This period of drinking despite my prior bad experience was one of rationalization. I rationalized based on myself and based on society. My rationalizations based on myself were that it was lack of experience and not weakness that caused me to wind up in the emergency room and wind up relying on my friends to be OK despite drinking too much. My rationalizations based on society were that alcohol is not an advanced technology relative to many of the things I use in daily life.

Now, just over 10 years after my first experience drinking and less than 10 years after my second beer, I am giving up drinking. I am rejecting my rationalization based on my states of mind and based on society. My state of mind was only partly inexperience. There is a psychological and/or physiological component as well, that persists despite me gaining experience. Otherwise I would not have got drunk enough to make a mockery of myself in front of people I know tonight. In other circumstances this level of being drunk could have caused me to drive drunk or get into a fight. I am rejecting my rationalization based on society by reminding myself that reality itself is more important than how reality becomes known. A century ago we didn’t know the details of how alcohol occurs in beer and wine, and how alcohol influences peoples’ thoughts, but we do now. I think the simplicity of how alcohol is made is part of why prohibition is such a bad idea, but I don’t think it’s as relevant to an individual person’s choice of whether or not to drink as the scientific findings about alcohol are. And the scientific findings are that alcohol is harmful when people drink too much of it, no matter how simple the beverages are. If I could consistently be a moderate drinker I might choose that path, but tonight I had a valid test and found that sometimes I am likely to drink heavily even when I explicitly planned not to. So I’m going to try to revert to being a non-drinker. I’ve done that for long periods of time after I tried alcohol and I stopped because I rationalized drinking. What I’m doing now is starting a period of non-drinking and removing my excuses, and my goal is to never drink again.

My worldview is largely indifferent to this. I have a background in a religion that prohibits drinking but atheist beliefs. I appreciate scientific reasoning that’s based on drinking decisions, indicating that moderate drinking may be ideal, and science that averages everything, which shows that people who don’t drink at all are statistically better off than the average of all drinkers, including heavy drinkers. I appreciate that other mammals don’t drink alcohol and are very energetic and also that humans are different from other animals, due to self-domestication. It is based on my personal experiences that I’ve decided that I’m better off drinking.