Setting Up Canon G3111 on Mac OS Mojave

Today I was setting up the home printer on the Mac OS Mojave machine, and, although there is a driver download page from canon, there is no download button, or at least I  couldn’t find one. The printer doesn’t seem to support AirPrint, and none of the other options in the printer settings seemed to work. The solution: find a driver.

A quick search got me to this page https://ijcanon.com/canon-pixma-g3110-drivers-download/ where I selected the CUPS driver for Mac OS, and went through the set up process. After that was done, I went to system preferences > Printers & Scanners, and clicked the plus button. The printer was listed in the Default section, and I selected it as I had been doing previously, and again, no driver was auto-selected for it. I selected the “Select software” option in the section labeled “Use”, and this time, there was a G300 driver option on the list that appeared. That option wasn’t there previously. I selected that, and Clicked Add to add the printer. The printer is now set up and working.

The Lazy Function Declaration Pattern – Javascript

Among the many patterns in javascript, there is one called the lazy function declaration pattern. It is supposed to be an improvement over this:


var a = (function(){
    var b = [1,2,3,4];
    return function(n){
        return b[n];
    }
})();

What this does, is it creates a function and executes it immediately, and stores the return value in a. We want to do this in order to take advantage of the closure created in the process which allows us to access the values in b. This piece of code is an improvement over this:


var a = function(n){
    var b = [1,2,3,4];
    return b[n];
}

which tends to be slower because it creates a new array every time you execute the function. In this case we are only setting b, but if we were doing something more computationally expensive, then we would appreciate the performance hit even more.

The lazy pattern tries to optimize even more over that piece of code, but fails on doing so. First, lets look at the lazy pattern:


var a = function(n){
    var b = [1,2,3,4];
    a = function(n){
        return b[n];
    }
    return a(n);
}

The advantage of doing this is that we don’t need to initialize b unless we really need it. On our first example, the outer function executes immediately, and defines b, and it will define it, even if we never get to actually call the function. Again, in this example the initialization is very simple, but if we had to do more than just create b we would see why it may be important to skip doing the preparation. Think for example of a case where the initialization involves creating a bunch of new elements and adding them to the DOM tree. This could be expensive, and if we are not going to need them, why should we create them in the first place?

So far it looks like the lazy patter really is an improvement over the first example, so where does it fail?

Suppose we want to assign a to an object:


var a = function(n){
    var b = [1,2,3,4];
    a = function(n){
        return b[n];
    }
    return a(n);
}

var c = {
    d : a
}

Now, the function will never perform the optimization that it is supposed to, because we are assigning a reference the the original function, rather than the optimized version of it that takes advantage of the closure. In order to understand a bit more what is going on, lets do some testing.

Lets start by understanding exactly how the lazy pattern works.

When a is called for the first time, it performs the preparation, in our example, that preparation is initializing b. Then it replaces itself with a new shorter version, which skips the preparation and just returns the value that we want. Finally, it executes the new function. Lets change the function a little bit so we can follow as it executes:


var a = function(n){
    var b = [1,2,3];
    alert('b');
    a = function(n){
        alert(b[n]);
    }
    a(n);
}

as you can see, we have added an alert right after the declaration of b. This will help us “see” when that part of the code is executed. We also change the return in the inner function for an alert. That way we can keep an eye on when that part of the code is executed. Lastly, since the inner function doesn’t return anything, the outer function doesn’t have to return anything either, so we get rid of the last return statement. Lets now proceed to call the function:


a(1);
a(2);

As you can see, the first time we call the function we get first an alert that says “b”, which lets us know that the preparation code was executed. Then we get another alert with the value that we were accessing from b, and finally, we get another alert, but this one corresponds to the second execution of the function. In this second execution we don’t get a b alert because that part of the code is not executed again, but we can still access the values of b because of the closure that was created. This is pretty cool. And if we never call the function, the preparation, which could be expensive, is never executed, whereas on the very first example it is, regardless of whether the function is called or not. However, what happens when we assign a to an object’s method?


var a = function(n){
    var b = [1,2,3];
    alert('b');
    a = function(n){
        alert(b[n]);
    }
    a(n);
}

var c = {
    d : a
}

c.d(0);
c.d(1);

You will now notice that we get two b alerts, which lets us know that the preparation code is being executed on both function calls. This completely eliminates the performance improvement, which is why the lazy pattern is not such a good improvement over the very first example.

If we want to understand how the improvement was supposed to work, we can do so by modifying our very first example a bit:


var a = (function(){
    var b = [1,2,3,4];
    alert('b');
    return function(n){
        return b[n];
    }
})();

Make sure this code is the only thing being executed. As you can see we also added an alert. When you run this code, you get that alert, even though there is never a call to a. Compare to this:


var a = function(n){
    var b = [1,2,3];
    alert('b');
    a = function(n){
        alert(b[n]);
    }
    a(n);
}

Again, make sure this is the only code being executed. You will see that the preparation is not executed as evidenced by the lack of an alert popping out on the window. So the idea is that we can save the preparation if we don’t need it. However, we can modify the first example a bit to make sure the preparation only happens if we need it:


var a = (function(){
    var b;
    var prep_done = false;
    return function(n){
        if(!prep_done){
            b = [1,2,3,4];
            alert('b');
            prep_done = true;
        }
        alert( b[n] );
    }
})();

This way we make sure the preparation only happens if the functions is called. If you run that code alone, you won’t see an alert, and that lets us know that the preparation is not being executed. However, if we bind that function to an object’s method, we don’t see the double b alert:


var a = (function(){
    var b;
    var prep_done = false;
    return function(n){
        if(!prep_done){
            b = [1,2,3,4];
            alert('b');
            prep_done = true;
        }
        alert( b[n] );
    }
})();

var c = {
    d : a
}

c.d(0);
c.d(1);

You could argue that this new example adds the cost of an if to the function execution, but that is actually very minimal and will most likely have no real effect on the performance of the code. The lazy function definition pattern fails in that it makes the function more confusing to use and it could end up never really performing any improvements.

Note: This post was inspired by a little section on the Function the Ultimate talk by Douglas Crockford. I recommend you watch the entire talk, and the others belonging to the same series of talks.

Storage Space is a Lie

I just recently moved from my old place in the not-so-interesting city of Oakland to the more familiar city of Los Angeles. I lived in Los Angeles before, and I find it to be a bit more dynamic than Oakland. Although, I should mention that I don’t really like L.A. that much. I always thought I was a city kind of person. I like walking around big buildings, and going into malls just to look around, but L.A. is a city that was never really well planned, if it was planned at all. It just expanded and never really became anything other than a big web of streets that are usually a pain to walk because of the cooking heat that never really ends.

When I was packing my stuff, I realized that I have too much stuff. More than I want, and certainly more than I need. When I first got to the U.S. I was carrying nothing more than just few clothes, a sleeping bag, and a huge math book. Today I own a lot more books, a lot more clothes, and no sleeping bag. However, I own more than just that, I have two computers, monitors, speakers, a big new desk, the table I used as my desk for a year, a couple more little tables, pans, knifes, cooking utensils, a nice rice cooker, a big tall chair, and the list goes on and on. I could get rid of most of this, and it would not really affect me in any way. However, any time I set to get rid of the things that I don’t use, I end up not throwing away anything, and event worst, I realize I “need” more stuff. “Hey, how about a bookshelf?, or more hangers?, or a lamp?, What about a couch?”

I don’t use most of the stuff I have, but I don’t want to get rid of it. At the same time, I don’t want to have it at home because it is just wasting space. This is a predicament a lot of people find at some point in their lives. The solution? storage space!

No more than 5 blocks away from my current apartment, there is a storage space building. It is really convenient because you pay a small fee per month, and you can put all the things you don’t use, and you don’t want at home, but that you don’t want to get rid of. All those things that you will probably never see again after you put them away have a place of their own now. No more wasted space at home. But this, my friends, is a lie.

Why is it so hard to get rid of the things we own? There are a lot of things we can just get rid of, but there are even more things that we can’t. I have a ton of sketches, and drawings that I never take out. I never sit and look at them, or bring a friend over and show them to that friend. They are just there. They are not good drawings, and most of them are not even finished, but I just can’t seem to get rid of them. We cling on to this kind of things because they remind us of something, and we feel like if we get rid of them, that part of our life is going to disappear in some old memory, but as long as we keep that something, we can always remember that part of our life.

We have taken this problem to our digital lives. The early solution was to burn disks of the things we wanted to preserve, but to delete from the computer. I know people who have hundreds of disks filled with old files, photos, and music. At some point disks were not enough, and another medium was making an appearance: welcome, “the cloud.”

The cloud is one of those things that are so good, that they turn bad.The concept of the cloud is a nice one; you have a place on cyberspace where you can store anything you want to, and it will be available to you at any moment, from any device. This can be nothing but good. No longer do you need to worry if your computer has 500 GB of HD space, of 1TB. You just buy a computer, and let the cloud take care of storing your stuff. It will be available from anywhere, any time. But is it really?

The problem I’ve always encounter with the cloud is that no one can guarantee you that their server will always be accessible. Even the huge Amazon had problems not long ago. These problems affected a lot of people who relied on Amazon’s cloud to run their services.

There are of course some other problems with the cloud. For example, would you gather all your pictures, and hand them to a total stranger to keep them from you? What about those sexy pictures that your wife let you take on the honeymoon? Lets not forget the picture of you baby. Oh, and what about that video tape that a lot of couples seem to be doing nowadays. Next thing you know the service you are using had a security breach and that video is on some .xxx-domain website. This would be like that building I was talking about earlier being robbed and all your stuff is gone.

Storage space is supposed to solve a problem, but in reality, it is just allowing us to continue clinging on to those things we don’t need, use or want anymore, but that we can’t just throw away. That is why storage space is a lie.

Afterword:
This is an ill-written article. There are a lot of errors in the text, and I am aware of it. I did not try to write a master piece, or even a good article, I just wanted to say this “out loud.” I’ve had a storage space service’s website on my tabs for a while now, and that is in fact why I initially thought of writing this.

Let me Explain to You What I Do

A question often asked to me is what I do for a living. For example, last Thursdays, at the airport (Where I was once again treated like if I were a criminal), the lady who was kindly going over all of my stuff, unpacking everything, and asking a lot of questions, asked me what I did for a living. I told her I am a freelance web developer. I would think that was enough, but it wasn’t. She was not happy with my answer, so she asked: “What do you do?”, and I explained that I build websites. It wasn’t until she READ a contract that I had printed out that she suddenly realized what I do; “Oh, you build software!” She said. I just agreed, not really willing to explain to her what kind of software I build: web-oriented software. But, do I really do that?

Not really.

I don’t like it when people ask what I do, because even if I tell them, they don’t get it. My friends are not techies. I have a bunch of friends, most of them in my home country (unfortunately), but non of them are web developers. They don’t understand what I’m talking about when I say that I create websites. Well, I might be exaggerating now, some of them do understand. However, sometimes I find my self trying to explain to people what it is I do, and why I charge so much (not really, but my hourly price is really high if you compare it to a regular Mexican salary). But maybe, the real reason why I don’t like it when people ask what I do, is because I don’t really know what I do.

I do not create websites. I do not create complex systems. I could, but I don’t. I spend my days coding, that is true, but there is not a website that I can say “Look, I built this site”. All I do is fix bugs, and extend existing systems. Many times I work on wordpress plugins, and many times I work on wordpress themes. In fact, I am trapped in a wordpress world.

I never wanted to be a wordpress developer. In fact, I don’t quite like the idea of a site built that way. I do believe wordpress is an amazing piece of software, but I think websites should be more personal, and with wordpress that personal touch is often times lost. But I think that is material for another rage post.

Sorry if I disappoint you, but that is the plain truth. I do not build complex stuff. I just fix somebody else’s screw ups. Would I like to build complex stuff? Maybe, maybe not. I would like to build websites. I don’t want to create the next wordpress super theme, or plugin. Not even build the next wordpress that runs on node.js. I just want to build websites for people who love what they do. Maybe you have a local bakery, maybe you grow your own carrots and sell them on the local farmers market, maybe you are a photographer that travels around the world taking nice pictures that you hope to sell and make a decent living out of it. Whoever you are, and whatever you do, I want to build your website. Maybe we use wordpress, or maybe not, but I don’t want to use a template, and I don’t want to build you a template. I want to create a website.

But, why don’t I? Because I am too busy. People continue screwing up, and clients continue wanting their current plugin to do more. They continue asking for upgrades, and custom features. And for as long as my clients are loyal to me, I am loyal to them. That is the way it works. Would I build your website? Yes, I would. Maybe one day I stop being such a lazy boy, quit my current clients, and look for people who need a website. Or maybe not. I love my current clients, they are the best I could wish for. They come back again and again, they pay promptly, they don’t ask for lower prices, and don’t complain when the prices change. I am happy doing what I do, that is true. But sometimes I just want to really build websites.

Do I blame anybody? No, I don’t. I am quite thankful for all I’ve got. I thank God for my clients, and for the work I have. And maybe, one day I will be building just websites, but for now, my clients need me, and I need them. That is the way it works. And for now, I am happy with that.

My Tools of the Trade

Or, I’m a Programmer and this is how I roll.

Frequently people ask me kind of tools I use to work, so I’ve decided to write this post so I can refer people to it as my answer to the question “What kind of apps do you use?”, and the classic “How is your set up at home?” I believe this will be a better answer than trying to remember everything right at the spot.

To begin with, you should know I’ve been working from home since the very beginning of 2010. The story of how I ended up working from home is out of the scope of this post, but some day I might even tell you guys that story. Any way, I work from home, and have had quite a few set-ups and as for now I feel really comfortable with the one I currently have.

Initially I used to work on a Macbook computer which one day simply just refused to run. As you can see, I do have a reason to not like those [insert your favourite adjective here].

When that piece of crap stopped working, I went on and installed ubuntu on a Dell laptop I had mere bought for the sole purpose of testing on IE (Internet Explorer). Ever since then I’ve been using Ubuntu. By the way, the Macbook crashed around mid 2009, so since 2010, when I started freelancing, I’ve working using Ubuntu.

Back when ubuntu didn’t have unity, and we were all happy with Gnome shell, I used to work with 12 virtual desktops. It seemed efficient back then, but now it just feels a bit of an overload of workspaces. Then unity and its fixed 4 workspaces came along. I had to adjust myself to this new seemingly insufficient and inefficient restriction  placed onto me by unity.

Things worked out pretty well, I learned to have less windows open at the same time and reuse workspaces. Then I had the idea of connecting a second monitor to my laptop, and that is when I saw cats flying around my home-office. Having 2 monitors has been the best setup I’ve tried, but I dream of having 3.

So, after the long intro, here is my current setup.

I currently work “from the floor”. I don’t have a desk and a chair, mostly because I’m too lazy to look for a desk. I have a small table ($45.00 at a Korean marker) that I use for my computer, and the monitor has a high-enough stand. I use a comfy floor chair I bought for $70.00 bucks at a Korean market. The chair is very comfortable and has an adjustable back support with 5 different position going from completely flat to about 100 degrees. I alternate between positions to make it easier on my back.

I also have an extra monitor that I bough for $50.99 at a famous thrift store. The monitor is an IBM ThinkVision L191P, a bit outdated, but gets the job done.

Recently I acquired a Logiteck keyboard an mouse set (Cordless Desktop E100) for $14.00. Not your dream set, but definitely gets the job done.

As for my software tools, I use a combination of vim and textedit to develop, GIMP for the occasional design job and Firefox with a few developer tools.

I use VirtualBox OSE to run a virtual Windos XP install to test in IE 7 & 8. I have IE tester to test in IE7 and a real IE8 install.

Today I started to use twitter.com again, after the many limitations of Gwibber finally got me tired. On firefox I have 4 tabs pinned as apptabs. The first is hotmail, second google +, 3rd Google Reader, and 4th is Facebok. From these the only one I really use throughout the day is Hotmail, and in less frequency Google Reader.

Here is a screenshot of how my desktop looks right at the moment of writing these lines:

The single application that is running all the time is Firefox, and if I could I would have everything running in it. For example, I know many people like to have an email client, I instead love the usefulness of having hotmail open perpetually on firefox.

The programs that I use on Ubuntu besides the previously mentioned GIMP and Firefox are Chromium (Not Chrome), Opera, Shotwell, and Skype.

I don’t much like the idea of filling up my computer with the last hits of the moment, a big collection of movies or the pictures of my niece’s birthday. I regard my computer as a working tool, not a box of memories or an entertainment system. My box of memories is a 1TB external HD, and my music player is youtube. I tried grooveshark but never really loved it. I might try it again later.

Old projects all go to  the external HD. I do have, however the photos of the current year on the computer. When the year ends, I transfer them to the external HD. This makes it easier for me to find and edit pictures to upload to my deviantart page.

There might be things I’m missing, and when I remember them I will come back and update this post.

 

In the Ocean, Mi nueva foto en DeviantArt

Hace unos días me tomé la tarde para rodar por San Francisco. Estuve caminando por al rededor de 4 horas y tuve la oportunidad de capturar un par de spanshots que considero fueron muy buenos. Hoy terminé la post producción de uno de ellos. Lo he titulado In the Ocean, y está disponible en DeviantArt.

Lo tengo a la venta via DeviantArt, así que si les gusta, no duden en comprarlo. También está disponible la imagen para dscargar. El formato es jpg y el tamaño es de un poco mas de 3000 pixeles. Puede descargarla y usarla libremente mientras que se dé atirbución a mi persona y se coloque un enlace de regreso a la página de DeviantArt en la que se encuentra el trabajo. Sí, pueden usarla en trabajos comerciales siempre y cuando NO se venda la foto por sí sola y se cumpla con el requisito de la atribucíon y el enlace.

Si deciden usarla en algún trabajo, no duden en mostrarlo. Me gustaría ver que esta imagen es bien recibida y sería un honor que fuera usada en algún trabajo comercial o no.

Eventos, trabajo y más

He estado sumamente ocupado. Tengo muchos pendientes y me ha quedado muy poco tiempo personal, pero aun así me las he arreglado para asistir a algunos eventos, de los cuales el mejor ha sido wordcamp. Wordcamp me presentó una perspectiva fresca del diseño y desarrollo web basado en wordpress. Me alegra decir que tuve la oportunidad de asistir a una charla impartida por Chris Coyier la cual fué muy instructiva.

En estos días estoy planenado algunas cosas, entre ellas desarrollar un par de templates que estaré distribuyendo de forma gratuita. Esperen ver lo que estoy preparando. También estoy pensando iniciar un blog sobre mis aventuras en la cuidad de San Francisco, aun que ahora estoy en proceso de mudarme a otra ciudad a unos 15 minutos de San Francisco. Estoy con muchas ganas de desarrollar mi primer RIA, que será un WYSIWYG moderno con enfoque a producir documentos bien formados y estandarizados. Esto es solo un plan ambicioso que tengo, pero la verdad mi agenda por el momento está muy apretada.

Por último, me gustaría compartir con ustedes mi última fotografía. Esta la tomé hace ya unos meses cuando estuve de viaje por México. Estoy distribuyendo esta foto de forma gratuita bajo una licencia creative commons. Las condiciones de su uso es que se mantenga una referencia a mi persona así como un enlace a mi perfil en deviant art en cualquier trabajo en el que sea usada, aún así sea comercial.

My latest submition on Deviant art

Una experiencia de aprendizaje para diseñadores.

El día de ayer estuve con algunos diseñadores. La idea de la reunión era ver el sitio de cada uno y aportar nuestra opinion. Tuve la oportunidad de ver sitios muy bien diseñados y otros no mucho. Creo que lo más importante que aprendí es que tu diseño puede ser muy bonito, pero si no está bien orientado no sirve de mucho. Otra cosa que me quedó de esta experiencia es que demasiada información en tu página principal es tan malo como muy poca información.

Esta experiencia me ha dejado con una muy buena vibra. Si puedes hacer lo mismo, te recomiendo que lo hagas. Es una experiencia muy constructiva.

Visitando las oficinas de Automatic

Ayer tuve la oportunidad de visitar las oficinas de Automatic, los creadores de wordpress. Estuvimos ahí algunos usuario s de wordpress mirando lo que hay de nuevo en wordpress y discutiendo sobre funcionalidades que podrían ser agregadas al famoso motor de blogs. En general la plática y la presentación fueron muy básicas, pero el mes que entra estaremos hablando sobre wordpress como motor de aplicaciones y no solo de blogs. Además, personalmente ya solo espero la hora de ir al wordcamp. 😀

Regresando a DeviantArt

Si sigues este blog desde sus crudos inicios, pues antes que nada gracias. Seguramente sabras que tengo un gusto por la fotografía, aun que no sea tan bueno en ello como me gustaría. Hace tiempo abandoné deviantart, pero este año he decidio regresar. He pueto ya un par de fotos y espero seguir poniendo más. Mi más reciente trabajo lo pueden ver en:

http://fav.me/d375yjk