Thursday, June 11, 2015

#50over20

What is this hash tag? Well I got tired of seeing all these #30under30, or #40under40 clubs that people are a part of. There are plenty of awesome people who are not necessarily part of these communities where they can be nominated and win (assuming it's not just a popularity contest). So here's my idea. I'm going to find 50 people I have met in person that I think are awesome. My ONLY requirement is that I have met them. That is all. I think you guys need to have some recognition. If you're tagged in my #50over20 twitter feeds, (or if you're not on twitter, well that's ok too, we'll mention you somehow). Please send me a short bio and I'll try to talk you up too. (If you don't have my email, it's my twitter @gmail.com unless it's my onaclovtech twitter account, in which case it's tyson @ well you know my domain name.

For those of you reading this thinking. Man I wish I were part of a #50over20 club... YOU CAN BE, just start your own. Tweet things with the hash tag, and just rock it. Recognize people around you that you think are deserving, or well have simply met you that you would like to call out!

Maybe I'll make it on someone's list, but if not, at least I know that there are 50 people I know who deserve to be on someone's list!

I'll be following up with a post of the "winners" :)

Thanks and have fun!




Friday, June 5, 2015

Working Around Nodejs Module Common Singleton Design Pattern

I ran into a problem a few days ago. I built this really nifty queue module. It removes elements once they're old as defined by the key "endTime" (which come to think about it, maybe that could be a future enhancement to specify how to "expire", but I digress). Here is the problem, I needed a second queue. Well I can't just require my queue module in because it's cached and well it's not a "new" instance.

So for example.

var queue = require('queue.js');
var queue2 = require('queue.js');

queue.add({endTime : 1234});
queue2.add({enddTime : 2345});

// Assume queue.element returns the head of the queue
console.log(queue.element());

Output
>> {endTime : 2345}

// Assume queue.entire returns the entire queue
console.log(queue2.entire());

Output
>> {endTime : 1234}, {endTime : 2345}

As you can see you don't get a unique queue.

I found some examples around the interwebs and gave it a try. I have a problem with the common approach shown below.

var queue = function(){
   var self = this;
   self.local_queue = [];
   var funcs = {
                      add : function (obj){
                      ...... stuff ......
                      },
                     entire : function(){
                     ..... stuff..........
                     }
                     ...
       }
}
module.exports = function(){
    return new queue();
}

I don't like implementing my functions IN the surrounding function (the add: function example).

I prefer the following:

var add = function(obj){
... stuff ...
}

...

...


var queue = function(){
   var self = this;
   self.local_queue = [];
   var funcs = {
                      add : add,
                     entire : entire,
                     ...
       }
}
module.exports = function(){
    return new queue();
}

The problem is that my functions were not able to reference self. 

So I finally worked around this like this.

var add = function(self, obj){
... stuff ...
}

...

...


var queue = function(){
   var self = this;
   self.local_queue = [];
   var funcs = {
                      add : function(obj){return add(self, obj)},
                       ...
       }
}
module.exports = function(){
    return new queue();
}


If you notice now we have a self reference being passed to the function, all is now well in queue land.

Now when I require in it looks something like this.

var queue = require('./queue')
var queue1 = new queue();
var queue2 = new queue();

Now any adds and removes all affect only their own queues.

If you have a better cleaner way to implement this I'd be happy to see it.

Wednesday, June 3, 2015

My First Hour with a Chromebook

I'm excited. I do believe that a computer with all the tools you need at your fingertips exist. Why should compiling git require figuring out build resources, and installing a handful of different things, why not just be able to go to git.com/org/whatever and say I have a file, please compile, and it does it, on your machine (or optionally on their). Why do we have to fight to install software we may use intermittently?

Well in keeping with that thought, I decided my first laptop purchase in nearly 10 years (I know let the ridicule begin for a Software Developer to go so long between computer purchase), would be a Chromebook. I thought about this alot, I did *some* research, but frankly I'm a hands on kind of person. I like to get in and get dirty. So this post about my First Hour with a Chromebook, is being written on my Chromebook. I purchased the Chromebook linked to on this page. (Fair Warning: Click "Chromebook" anywhere here and you'll be taken to my Affiliates link on Amazon). It's a $250 dollar computer. I opted for the 16GB SSD, with 2 GB Ram, and HD display. From what I found online thanks to the NVIDIA Kepler GPU with 192 CUDA Cores and a few other things it's got a great power profile and the transitions are like butter I read somewhere.

Developing

First things up I installed an SSH terminal as I am working on my webdvr. It works as expected, however I do plan a future post on setting up keys so I don't have to type in my password every time. Hopefully we can get a series of posts to setup a basic dev environment with these tools configured to make things easier and faster.

Second install was Caret. I read this is a GREAT editor with a Sublime like interface (I have heard enough people praise Sublime I was interested). I haven't gotten deep into configuring, but once I do, this will be another post as well.

I finally tried opening a file from my raspberry pi. You can "add service" in the Caret Open File dialog. Once I selected SFTP, entered my credentials (Also future post about setting up keys for this). I was connected and running. Now for some reason while I was trying to copy a file and paste a copy (so I could rename and use again), the connection got flaky, and I decided to close the connection to my pi. This is where things were "weird" for me. When I clicked Open in Caret I was expecting the ability to essentially remount my drive and keep going, since that's what I did the first time. This was wrong (I have a question with the developer if this is expected behavior, I'll report back if it is/not), you need to find the SFTP service again from your system mount again, and THEN the folder will be visible again. I find this unexpected, and I get if Caret has no control, but seems like it would be nice to have. Aside from this, thus far, I really like the Chromebook for developing. I haven't searched but I expect I can find a Diff tool (similar to Beyond Compare) in the Web Store.

Looking at Carets github wiki they mention following the Unix Philosophy, wherein a bunch of small utilities able to be chained. I love that and think it works. In fact as I begin to use this system more and more, I am sure there will be some "small utilities" I'd like to build.

Movies

Ok so For some of my friends the question of whether Amazon Instant Video works or not.  The answer is a resounding YES. Does the site need some love, yes. I guess browsing amazons regular site works but it would be nice if they had a "instant video" specialized site, that worked similar to their roku app. (Which I guess maybe it is close enough, but just feels like some UI improvement could be possible).

Things that will take getting used to

I normally am used to the "delete" key in the upper right. Now it's the power button. Gotta be careful with that one, but frankly everything is synced, it's a 10 second or less boot, really not a big deal.

I'm not sure the "proper" right click, but I've found that ALT and a click accomplishes the same thing.

I'm told Apple folks are pretty used to the two finger scrolling. I am not, (I haven't owned an Apple laptop ever), so I'm sure there are some scrolling features I'll have to learn, but this one appears to have two finger scrolling.

More eventually.

Future Plans

I plan to install nodejs locally. (for when I need to do offline development).
I plan to get a Sandisk UltraFit low profile USB memory to both boost my RAM (using virtual Ram) and to boost my HDD space in the event I need it, which if I'm developing locally I suspect I may run into a space issue. I really like the SanDisk Extreme CZ80 but it's a bit "big" for a laptop like this. If you're aware of an SD card that has speed like the above mentioned drives thats an even more ideal scenario.
I have tried a few of the android IDE's and they kinda work, but they're just not quite there for me the last time I tried. I'll probably try them first before trying to setup locally.

I plan to setup Android App Development (at least try it) eventually. I am nervous about speed, but this is much faster than my netbook so that should be less of an issue.

I'd really like to see if I can connect an Arduino to this and actually program it (Fair Warning, I haven't researched if it's been done before). I think ideally to me, if you could make a webapp that interacted with it, that would be key. I mean we can install linux tools on here all day, but that defeats the purpose of this device. Same goes for the Android IDE. Building something that uses the native ecosystem just seems right to me. Plus it'd be handy to be able to have an always updated, and always working "install" of a program. I hate trying to wade through configuration. Just give me a site. If I need to pipe into another program, let me decide when I get there (and/or give suggestions along the way).

Final Thoughts
I really like this device, it's sleek and works well. It's a really reasonable price, the screen is crisp and clear (unlike my 10 year old Dell...hahah). I truly believe this is the future of a computer and what Puppet, Vagrant, etc are all trying to accomplish with VM's. I guess we'll see where we are in a year or two. I hope that I am able to contribute to this future. If Firefox came out with a REASONABLY priced device (similar to this) I fully expect I would give it a try. I tried the Firefox Phone and unfortunately the jump from an android to it was tough. I think it's got a ton of potential though, and I'm very interested in it's future.


So that's basically my first hour with a Chromebook.  I hope you had fun. Leave me a comment if you have any questions.


*Hey anyone reading this, a battery profile would be pretty slick to see, I.E. Time since charged, and all that jazz for someone interested in a 11-13 Hour battery life. Harder to keep track when you use it an hour here and an hour there. I think Android has something like this, but I don't see anything obvious here. But I digress.