Over the last couple of days I’ve been messing around with node.js. I got to the point where I wanted to start playing round with what seems to be the most popular node.js MVC framework, Express. In most tutorials they have you create a skeleton app using the $ express(1) executable. This seemed pretty reasonable -> execute one command, -> have a skeleton app from which to work. The problem is that after every time I tried to do this the files that were generated were one huge line of code with commas where newlines should have been.
Ex.
,/**, * Module dependencies., */„var express = require(‘express’), , routes = require(‘./routes’), , user = require(‘./routes/user’),>
Which would give me the following error when trying to run the app ($ node app)

I asked a couple of node.js brogrammer friends if they knew what was going on, they were stumped. I scoured stackoverflow and the greater internets for someone that had had the same issue. I found a couple of people that had posted questions about this, but found no reliable answers. so I took to the node.js google group and responded to a similar question asking of anyone had the answer. In the meantime I just git cloned this repo https://github.com/brentertz/express-skeleton into any directory that I wanted to create an express skeleton in. That was a good short term solution but I still wanted my shit to work. About 24 hours later I got a response from the google group saying to edit the /usr/local/bin/express file changing
var eol = os.EOL
to
var eol = ‘\n’
I tried this and everything seemed to work. I also took a look at an older version of the express skeleton file and noticed that the eol var had previously been
var eol = ‘win32’ == os.platform() ? ‘\r\n’ : ‘\n’
I tried this as well and it also worked. It’s funny that I only got the error while using the most recent version of express with the most recent version of node and npm.
Developing SMS apps in developing countries is all the rage for social entrepreneurs. It’s even a bit rageful in the US and other developed markets with tools like Twilio making app development super easy. For people used to developing solely for the browser and smartphones SMS often sounds scary. “How do you get the messages from users’ phones to your server and then get messages back to the user? Don’t you need an SMS gateway or something like that?” Yes indeed, you do need an SMS gateway or something like that. Twilio has taken any and all pain out of that in the US with their APIs. Essentially you just develop your server side code as you would for any browser based app, handle each SMS as an HTTP POST request, perform whatever logic needs performing and return a message that is sent back to the user. Pretty simple.
With Twilio this is all pretty cut and dry, but in countries where Twilio doesn’t operate or is prohibitively expensive the options have always been a bit weird. Either you try to negotiate something directly with a domestic carrier or you find yourself on some internet 1995 style website with someone offering bulk SMS messaging at wholesale prices around the world. Usually these options lack decent developer tools and charge you absurd fees to get going. 2 way messaging is also a bit difficult….Enter TeleRivet. A couple weeks ago my buddy Adam Walker, founder of RemoteCycle, said I should take a look at TeleRivet as a quick and easy solution to setting up an SMS gateway. Having gotten my Arduino HTTP GET requests spraying correctly and having graphed that data I decided it was time to make the data queryable (sp?) via SMS. I gave TeleRivet a gander, noticed that it’s used by one of my previous corporate patrons and decided it was the solution I was looking for.
Here’s how it works. You need an Android phone. On your Android phone you need to download the TeleRivet app. The TeleRivet app uses your phone to send and receive SMSs. All inbound and outbound logic is handled by the app. They offer a pretty easy, no programming necessary, web dashboard for sending and receiving messages plus basic rules based responses to

received messages. The real beauty in the service are their webhooks. They allow you to setup a service that forwards any SMS received by the app/your phone to a URL where you can perform whatever server side logic on the message that you want, save messages/data to a DB and respond with another SMS.

This is a pretty seamless way to set up 2-way SMS messaging. This is pretty much exactly what Twilio offers, but you can do it anywhere in the world with a local SIM card and an android phone.
Each HTTP POST request comes with 12 parameters, most important being from_number, contact_id, content (message content), secret (security stuff). And to respond you just need to put together a JSON response with a “messages” property and an array of messages. Note that you can send multiple messages in response to one message, so either messages to multiple users or multiple messages to one user.
Another cool feature of the service is that the monitor your phone (SMS gateway) and send you email alerts when anything seems out of line. Today I got emails about the gateway being inactive, the gateway becoming active again, the battery of the gateway getting low, and the battery of the gateway recovering.
Connection Inactive

Connection Active

Battery Low

Battery Okay

Here’s my TeleRivet setup
1) Nexus S Android phone for the gateway, passed down by friend Jack Krawzyck many moons ago.

2) Azumi (yeah I know WTF?) purchased for $10 in a Santiago electronics store as a test client phone.

3) A couple of Entel SIM cards to take care of sending and receiving the SMSs (bought Entel because seemed like they had most favorable rates)

4) Boom and the final result was returning some poorly formatted data from my sensors to the Azumi phone via a simple SMS command

While recently reading an Abraham Lincoln biography I came across a human state (melancholy) and a human trait (empathy) that I had never before connected. Abraham Lincoln seems to have been a decently gloomy person. Physically very long, with a lanky gait and kind of mopey appearance he was described by many as melancholic. Melancholy is something I hadn’t much contemplated before reading this battery of text describing Abe as melancholic. It sent me scrambling for the dictionary definition of melancholy -> A deep, pensive, and long-lasting sadness. The thing that strikes me here is “pensive”. Can sadness me pensive? Thomas Pynchon goes a step further and says that melancholy can led to productive behavior -> “Melancholy is a far richer and more complex ailment than simple depression. There is a generous amplitude of possibility, chances for productive behavior, even what may be identified as a sense of humor.” The biography goes on to say that:
Modern psychiatry regards humor as probably the most mature and healthy means of adapting to melancholy. “Humor, like hope, permits one to focus upon and to bear what is too terrible to be borne,” writes George Valliant. “Humor can be marvelously therapeutic,” adds another observer. “It can deflate without destroying; it can instruct while it entertains; it saves us from our pretensions; and it provides an outlet for feeling that expressed another way would be corrosive.”
So melancholy is a deep, pensive, and long-lasting sadness that can potentially be cured by humor and is potentially productive. Okay, and now where does empathy come into play. Empathy is the capacity to recognize emotions that are being experienced by another person. One may need to have a certain amount of empathy before being able to experience accurate sympathy or compassion. (definition from wikipedia). Abe seemed to possess tremendous empathy and given his childhood and a lot of crazy thing he had suffered through it’s easy to attribute his melancholy to his empathy.
Lincoln’s abhorrence of hurting another was born of more than simple compassion. He possessed extraordinary empathy—the gift or curse of putting himself in the place of another, to experience what they were feeling, to understand their motives and desires. The philosopher Adam Smith described this faculty: “By the imagination we place ourselves in his situation…we enter as it were into his body and become in some measure him.” This capacity Smith saw as “the source of our fellow-feeling for the misery of others…by changing places in fancy with the sufferer…we come either to conceive or to be affected by what he feels.”
So a few observations here: 1) People that are extremely empathetic and compassionate are often empathetic and compassionate to a fault where by they become depressed (note I say depressed here not melancholic) 2) People that are extremely empathetic, compassionate and very pensive and introspective are able to avoid bouts of depression by using their ability for thoughtful reflection to learn from suffering rather than get buried in it. So I guess the next time you’re getting sad go for a long walk, get all kinds of introspective, reflect, learn, see what you can take from it and avoid getting too sad.
After getting my arduino GET requests (mentioned in a previous post) spraying properly, I decided it was time to graph the data. I asked around for a simple graphing tool and a couple of friends pointed towards Chart.js. This was pretty dead simple to implement. All you have to do is:
1) Include the Charts.js library
<script src=”js/Chart.js”></script>
2) Add a canvas DOM element on which to draw the graph
<canvas id=”myChart” width=”980” height=”400”></canvas>
3) Get the context of the canvas element that you just created
var ctx = document.getElementById(“myChart”).getContext(“2d”);
4) Create some data. In my case I’m using two arrays that I previously constructed (javascript_array_hum and javascript_array_temp). You can give a unique stroke color, fill color, point color and point stroke color to each data set. To do this just set those parameters with CSS type strings.
var data = {
labels : a,
datasets : [
{
fillColor : “rgba(220,220,220,0.5)”,
strokeColor : “rgba(220,220,220,1)”,
pointColor : “rgba(220,220,220,1)”,
pointStrokeColor : “#fff”,
data : javascript_array_hum
},
{
fillColor : “rgba(151,187,205,0.5)”,
strokeColor : “rgba(151,187,205,1)”,
pointColor : “rgba(151,187,205,1)”,
pointStrokeColor : “#fff”,
data : javascript_array_temp
}
]
}
5) And finally draw the graph. In this example I’m using a simple line graph, but you can also do bar, radar and polar graphs.
var Chart = new Chart(ctx).Line(data);
To further customize your graphs there are a ton of options that you can send the graphing function. A lot of people have suggested using node.js for working with sensors because it will never lock, which is important when you’re writing a shit ton of data to a DB. Not having to convert arrays from another server side language (python, ruby, php etc) to javascript for easy graphing is another advantage of potentially using node.js.
Over the weekend I started reading The Opposing Shore by Julien Gracq. It’s littered with interesting vocab. Here are some examples:
Jeunesse Dorée - Obviously from French, meaning = young people of wealth and fashion. I’m surprised this hasn’t been cooped by a rap group.
Cavalcade - Also from French, meaning something like a parade of horses. I participated in one of these over the weekend so this word was particularly prescient.
Juvenescence - This one only caught my eye because it’s so close to the first one. Seeing words like this makes it clear that the book was originally written in French and translated to English without watering down the vocab. Juvenescence pretty much means youthfulness.
Yesterday I was banging my head for a couple of hours trying to figure out why my simple GET request going from my arduino to shared server space I have at 1and1 was returning a 500 internal server error. Yeah, shared server space at 1and1 is shitty, but I figured it would be sufficient for the tests I was running. What I was trying to do was gather some basic variables that were being read by a temp/humidity sensor, put them into a GET request and send them to my server. Most of the code examples I saw were like the following that stretched the GET request out over several lines.
client.print("GET /writetemp.php?t");
Serial.print("GET /writetemp.php?t");
client.print(i);
Serial.print(i);
client.print("=");
Serial.print("=");
client.print(temp);
Serial.print(temp);
client.println(" HTTP/1.1");
Serial.println(" HTTP/1.1");
client.println("Host: www.yourdomain.com");
Serial.println("Host: www.yourdomain.com");
This seemed reasonable enough, but I kept on getting a 500 internal server error when sending the request from the Arduino. When sending the request from the browser everything worked fine. After experimenting with a lot of things including changing the HTTP version from 1.1 to 1.0, removing the www from the domain name I finally got things to work by putting the get request on one line. Apparently 1and1 couldn’t handle the request because packets were being lost as the request was spread over several lines. To fix this I converted my float variables to string variables and concatenated the GET request into one line. This is what the result looked like.
char buff_h1[6]; char buff_t1[6]; String h1_string; String t1_string; dtostrf(h,4,2,buff_h1); h1_string = String(buff_h1); dtostrf(t,4,2,buff_t1); t1_string = String(buff_t1);
Serial.println("\nStarting connection to server..."); // if you get a connection, report back via serial:
if (client.connect(server, 80)) { Serial.println("connected to server"); client.println("GET /tempwrite.php?t="+ t1_string + "&h=" + h1_string + " HTTP/1/1");
client.println("Host:www.yourdomain.com"); client.println("Connection: close"); client.println(); }
The line that starts with client.println(“GET… is the fully formed request with the concatenated. Note that you can’t concatenate float variables directly into a string and need to use teh dtostrf() function to turn them into a string before sending them.
Been reading Project Gutenberg books for a while, but just stopped to check out their licensing policy. Love it, let the knowledge be free! “You may copy it, give it away or re-use it…”
Something that often grips me in literature and history are duels. There are few existing remnants of duels. One might be the battle rap, which seldom, although sometimes, ends in death. While it’s probably best that people aren’t arbitrarily killing each other when their pride is hurt or their honor put in question I feel like we’re probably living in a more cowardly and definitely more passive aggressive society than our ancestors. Here’s a list of a few of my favorite duels from history/literature:
1) Pushkin going under in a duel with a Frenchman he thought was sleeping with his wife. The Frenchman was later proven innocent, but Pushkin was TKO’d, down for the count, dead.
2) Another good one was the wild duel between Arturo Belano and an editor that had wounded his pride in Los Detectives Salvajes (Roberto Bolaño). Best part about this duel is that it ostensibly took place in the 90s on the Catalan coast. Obviously the appeal here is that it’s a modernish duel.
3) This isn’t technically a duel, but the knife fight between Juan Dalhman and the drunk in the bar in El Sur (Jorge Luis Borges) is also one of my favorites. Primarily because of this line “Sintió, al atravesar el umbral, que morir en una pelea a cuchillo, a cielo abierto y acometiendo, hubiera sido una liberación para él, una felicidad y una fiesta, en la primera noche del sanatorio, cuando le clavaron la aguja. ”
4) And finally (what I just finished reading about) the “interview” at Weehawken that ended Alexander Hamilton. Aaron Burr being the guy that unfortunately had a decent shot, killed Hamilton and subsequently disappeared into obscurity. This duel is interesting because it seems to have brought an end to the duels that I find most interesting those that are “bathed in a midst of aristocratic glamour and clad in the armor of medieval chivalry”.
Here’s the line passage about the last duel that I really like ->
Meanwhile, clergymen, college presidents, and other self-appointed spokesmen for communal standards of morality seized upon the Burr-Hamilton encounter to launch a crusade against dueling throughout most of the northern states. What had once seemed an honorable if illegal contest of wills, bathed in a mist of aristocratic glamour and clad in the armor of medieval chivalry, came to be regarded as a pathological ritual in which self-proclaimed gentlemen shot each other in juvenile displays of their mutual insecurity. Though the practice of dueling survived in the South, and in its more democratic blaze-away version on the frontier of the West, the stigma associated with the Burr-Hamilton duel put the code duello on the defensive as a national institution. Not that it would ever die out completely, drawing as it did on irrational urges whose potency defies civilized sanctions, always flourishing in border regions, criminal underworlds, and ghetto communities where the authority of the law lacks credibility. Nevertheless, the Burr-Hamilton duel helped turn the tide against the practice of dueling by providing a focal point for its critics and serving as a dramatic object lesson of its self-destructive character. One of the reasons the Burr-Hamilton duel became legendary as the most famous duel in American history is its cautionary role as the most memorable example of how not to do it.
Ever wondered why the tech crowd often seems hollow? The passage below by NNT (Also from Antifragile: Things That Gain From Disorder) does a great job of explaining it. He mentions that most technothinkers have engineering minds, which is fair and I agree with the criticism he has for them, but I think the technothinkers that lack the engineering mind and also lack elegance and any sort of literary culture are the grossest of gross offenders. These people disgust me. To be clear some of my best friends work in tech and are engineers, but these people are usually people that also have some sort of other craft, enjoy literature and history and resemble more of a Michelangelo than a poster boy of modern “tech”. It’s when you get into the unfiltered herds of tech folk that the gross stuff starts happening.
After I left finance, I started attending some of the fashionable conferences attended by pre-rich and post-rich technology people and the new category of technology intellectuals. I was initially exhilarated to see them wearing no ties, as, living among tie-wearing abhorrent bankers, I had developed the illusion that anyone who doesn’t wear a tie was not an empty suit. But these conferences, while colorful and slick with computerized images and fancy animations, felt depressing. I knew I did not belong. It was not just their additive approach to the future (failure to subtract the fragile rather than add to destiny). It was not entirely their blindness by uncompromising neomania. It took a while for me to realize the reason: a profound lack of elegance. Technothinkers tend to have an “engineering mind”—to put it less politely, they have autistic tendencies. While they don’t usually wear ties, these types tend, of course, to exhibit all the textbook characteristics of nerdiness—mostly lack of charm, interest in objects instead of persons, causing them to neglect their looks. They love precision at the expense of applicability. And they typically share an absence of literary culture.
This absence of literary culture is actually a marker of future blindness because it is usually accompanied by a denigration of history, a byproduct of unconditional neomania. Outside of the niche and isolated genre of science fiction, literature is about the past. We do not learn physics or biology from medieval textbooks, but we still read Homer, Plato, or the very modern Shakespeare. We cannot talk about sculpture without knowledge of the works of Phidias, Michelangelo, or the great Canova. These are in the past, not in the future. Just by setting foot into a museum, the aesthetically minded person is connecting with the elders. Whether overtly or not, he will tend to acquire and respect historical knowledge, even if it is to reject it. And the past—properly handled, as we will see in the next section—is a much better teacher about the properties of the future than the present. To understand the future, you do not need technoautistic jargon, obsession with “killer apps,” these sort of things. You just need the following: some respect for the past, some curiosity about the historical record, a hunger for the wisdom of the elders, and a grasp of the notion of “heuristics,” these often unwritten rules of thumb that are so determining of survival. In other words, you will be forced to give weight to things that have been around, things that have survived.
Unlike dillettantes, career professionals are to knowledge what prostitutes are to love