Automate The Boring Stuff With Python Review

I was pretty bored over the weekend and found this book on special. Normally I would not buy it since it’s targeted at the beginner level but I got to read for free.

It was a nice surprise and I would highly recommend it to anyone starting into the programming world. If you are planning on using python the examples in the book are well described and straightforward to do. I felt the sense of power that computing has and a reminder that programming can actually make day to day tasks better. My favorite example in the book was working with Pdf’s to add a watermark. Just for the fun of it I combined with the email sample to make an app that takes a folder of pictures adds it into  a pdf watermarkes them and email them.

Travis CI + Windows Azure App

For one of my open source projects( I ended up setting travis CI to build a windows azure application ( and I wanted to record my findings since some of the problems are not very descriptive.


To start you go to and make and account then you have to basically mark your project active and submit a .travis.yml file to get it running.

I suggest you start with this:
language: csharp
solution: debesalgo.sln
– latest

Once you save that into your file your build will attempt to run and you will see and error about tools not matching and the version not being supported this happens if you are using VS2015 and anything above framework 4.5 So let’s downgrade our application to 4.5(Note further released of xbuild will solve this).

Now the next error will mention System.Web.Entity for some reason this file does not download from Nuget so add it to you bin and make sure you force commit it into git.

Once that step is done they build will kick once more and you will be at the point that it says there is an error with your pdb go into your project settings and compile your release version without pdb’s (Note you can use EmitOptions to do a portable pdb also) that will clear this error and get the build phase of this project done. It should look green and building.

Unit Test

Go into your test project remove the reference to the Visual studio quality tools since those are not supported in mono. Add the nuget reference nunit (I’m using 3.0.1) and to the Nunit.VisualStudio.TestAdapter package. Once that is done go and make a test case that we know will always pass. I tend to do this:

public class SampleTest
public void Empty()
//Sample test for those joining the project.

Once we got this we are ready to go modify our travis file to run our unit test we will do this by scripting so it downloads the runner console and additionally makes a call to the compile dll.

My final code for the .travis.yml looks like this:

language: csharp
solution: debesalgo.sln
– latest
– nuget restore debesalgo.sln
– nuget install NUnit.Runners -Version 3.0.1 -OutputDirectory testrunner
– xbuild /p:Configuration=Release debesalgo.sln
– mono ./testrunner/NUnit.Console.3.0.1/tools/nunit3-console.exe ./debesalgo.Tests/bin/Release/debesalgo.Tests.dll

This configuration assumes a new azure project but it works and it will compile. If you want to add test code coverage SharpCover is a great tool to use on this stack the big difference is that you will need to use a debug build.

Thanks for reading and remember to add your build badge to your page.

When you HAve a 3d printer Christmas is a pretty fun time.

I’ve been using my wanhao and my m3d in overtime for the last couples of months. I made a commitment to myself to basically attempt to 3d print the most gifts possible during christmas time.

It was cool because I could try and figure out what people liked and give them something in that category. For the most part all of the prints came out at acceptable levels. The one that I had the most problems was a vase for succulents and it was mostly because I forgot to check to mark for non solid top I left and when I came back it had printed filled.

Okay so without further ado the pictures from all the items.

Too many darth vader rings


Thor’s hammer.


Can you say Batman?


Dendritas succulent pot


Did I mention Genius Link Key Chains


This where particularly hard those hooks are hard to add.


Mr. Kylo Ren


One of my pendants for my wife I printed in gold from Shapeways.


I also printed Kylo Ren’s Lightsaber and a skull but I forgot to take picture so I have no copies of it.

So you want to create a UI System

So I had to do a research project last year I decided to do a UI system for Azul UI Depaul’s internal framework. Learned a lot about doing 2d on top of 3d and the different libraries available. Below my notes in case anyone wants to compare. At the end there are two documents attached that show usage and general design.


The purpose of this document is to outline the process that got us to the result that we have today with PaletaUI we will highlight the problems and the solutions that were picked. We will also conclude on lessons that we go thru out the process. This differs from the Design Document which talks about what actually got constructed and from the usage guidelines which are meant for the end user if we have one for PaletaUI.


How to change azul to ortographic mode.

This was the first problem that we faced. In Azul or better said my custom version of azul we were not using the traditional camera but we had a system that involved our custom camera and a camera manager. We wanted to keep that functionality and still be able to render In 2d so what I decided was that in the rendering loop we were going to split the two parts so this problem became simpler to just how we set the camera. I implemented a method for orthogonal projection to pass to the shader manager in order to be able to handle this. The method is static in camera manager is called GetOrthogonal.

How to draw on top of a 3d scene

Like we mentioned above we had to split the rendering cycle into 2d and 3d. I wanted to isolate Paleta as much as possible from Azul. So I created a class called UIManager to be the external facing point for the drawing call. Then in render scene I call ui manager update and draw after the scene from Azul does its call. We decided that the 2d equivalent to the Scene was the View and that we were going to Have only one active at a time. Additionally the Scene was going to assign the view using UIManager and be responsible of filling it.

How to draw a quad

We have our call set and know we need to be able to make a square because the first object we were going to create was basically a panel. We used the same rendering technique used in the rest of Azul create a predefined Vao. The only difference is that we are not using a translation function but recreating the quad if it ever moves. This is due to the fact that on the 2d ui things hardly ever move.

How to Control Rendering Order

Basically drawing on the screen is a stack so we needed a way to order ourselves. The decision that was made was to add the frame basically and object that only purpose is to be read in the order it should be drawn so a view has many frames.

Different types of Settings needed for the quads

To be able to display Text , Backgrounds and images I had to use control flags to indicate when to load a texture and load the texture shader, the specific text character shader or simply draw solid. I handled inside the quad class.

How to load fonts

To load fonts we used the library freetype which allowed to grab fonts directly out of ttfs. All fonts load from the same folder the application is running from. Note in the visual studio solution is the main folder for the solution.

How to Store the Font

Decided to make a font manager that basically contains a hashmap of the loaded fonts one font basically means a font file in a specific size. We basically create a texture for every character.

When to Store the Font and for how long

We load them until someone tells us to unload. They are fairly expensive to read and turn into textures in memory so we are super lazy on letting them go this is handled on the FontManager Class

How to calculate position for the letters

This was pretty tricky we used a technique extremely similar to the one We basically create a character struct to give us width height and the bearing so we can do proper spacing between characters. The logic to do this is inside label since is the class that everyone else that has text inherits.

What Shaders to use with Freetype

We had to create our own fragment and vertex shader. Basically what our shader does is that it looks at the image and uses the color red from the texture to set the alpha. The textures from freetype have Red characters with black backgrounds. Additionally it substitute any color that you send into it to replace the red so we can print in different colors.

What Structure should we use for the UI objects

Once we had figured out how to render text we were ready to actually start working on creating a compelling structure to place things on the screen. Added to the View and Frame decisions that had been previously made. I decided on the widget to be the base class for all representing a rectangular area of the screen and made the coordinate system to work from the bottom left. So we have two functions to basically push from the bottom and push left a widget.

How do we keep our structure open

It was my goal to allow people to create their own components later and to be able to make aggregated components like the highscore one in the demo. Due to this the widget class is an abstract that allows to be inherit and can redefine its draw and update so that it can be manipulated.

Is Panel a special type of widget

Not really but yes the difference with panel is that it works like an anchor basically allows you to add many widgets to it and anchor them to its x and y.

Are Buttons and Textbox special kinds of labels

It made sense for buttons to inherit from labels because they needed to show text and a background it ended up working very well. I also thought that textbox was a button and then realize that it was not since it only shared one characteristic that it could be clicked.

How do we take mouse input without getting too attached

To solve this problem I created a Virtual Mouse that needs to be updated every cycle. It works well and reduces all the data to normal ints.

How do we take a click

I did not made an elaborated collision system. Realized that you only have 5 o6 buttons or textboxes per screen decided to let them manage it themselves by doing a selfcheck on update. This is a possible area for improvement later on.

How do we take the actions that a button needs

Created a command system for this you need to inherit the class and create a specific command for your action. It ended up being great it encapsulates the action and makes them reusable. There are two commands implemented natively in the system on debug prints that something got clicked. The second one set focus to the widget that uses it.

How do we load the images for our system

I wanted to use Soil and add an image loader similar to the font manager but due to problems with SOIL ended up using the tga loader and texture manager from azul. So for now they need to be added to the enum. This is my number one area for improvement.

How do we take keyboard input without getting too attached

The same solution that we used for mouse would not work here. What we ended with was creating a keystroke observer that only has one subject which is whatever widget that is focused at the moment. Which created the problem of having to track and reset focus.

How do we keep track of Focus

We use focus to know where to send our keystrokes right now for the textboxes. There is a FocusManager class that gets set via the SetFocus Command Whenever a textbox is click other classes can use this command to set focus to themselves if they need it. The focus is no hierarchichal only one widget at a time.

What format should we use for declarations

I started on the route of using protocol buffers and thought it was a good idea had to do a reversal and fallback to xml for the following reasons. The compiler adding it to the solution was hard and while I solved this and got it running in the solution was worried that my setup would fail later. Second Reason and I think is the most important is that custom parsing of hierarchichal objects was really complicated. Seems like protocol buffers was meant to handle flat objects which makes sense for messages instead of nested hierarchy’s. With that said the format is pretty need and I think we should try to use it to create a duel networking system with protocol buffer serializing the messages. Is one of the projects I’m suggesting for the next semester.

I decided to use tinixml2 class to do deserialization.

How do we load the declarative format

Added a Load method on the View class and the frame class and that solved it for the top level objects. I only had to give a filepath to the view to be able to load an entire structure. With that said this created the problem that we have to be able to find the objects and ended up having to make the hasname interface that lets me search thru the frames and widgets.

How do we deserialize nested objects

This was an interesting problem and it was around the widgets ended implementing a singleton class widgetserializer which host a list widgetserializercomponents and uses a chain of command pattern to figure out who it matches with and executes it for that specific section.

How do we keep our serialization logic apart from our objects

We did not include the logic at all in the widgets but made a parallel structure in charge of loading them up.

How do we extend the serialization for custom components.

Widgetserializer has and add method to let you register widgetserializercomponents that were not created has part of the framework.

Lessons Learned

Libraries can take a while to integrate

If you abstract well you can forget about the underlying presentation

Let the user control lifetime of loaded objects

Deserialization != Construction

A few Ui Pieces can make an app a lot better looking

Abstractions for input can be complicated

Using Commands for Events is a good way of encapsulating logic

The Ui View is a separate element controlled by the scene


Better image loading

Clipping to size.

Add Border to Widget

Add Gradients to background Circular and linear.

Parse Colors defined by rgba in the declaration xml.












Milestone 1-

Final –

Link to Design Document

Link to usage guide

Creating A Random Walk pendant In OPen Scad


In the procedural world the random walk is probably the easiest algorithm. Basically start in a given position roll a dice and move in any direction. We are going to use this to create a stylish looking pendant to keep this simple we will only use the cardinal points. We will be using openscad and at the end we will add a loop so we can place it in a chain.

In order to do this we need to understand what is a recursive function and how do they work. Recursion is when a function can be decomposed into itself. For example the easiest recursive function that I can think of is counting.   The Count(5) = Count(4) +1 if we take this is into a form using a variable count( a ) =  count( a – 1 ) + 1 then we have a base case that on 0 we return 0 in openscad that looks like this:

function count(a) = a == 0 ? 0: count(a-1);
//we can call that function like


Now that we are pro’s at recursion. Lets take a look an see what else we need to understand to get this done. Well the next step is to understand how to do randoms in openscad. Is pretty simple you use the function rands the first para is the lower bound, the second one the top bound and the third one the amount that we need.

//amount of steps in our function
cantidad = 100;
direction = rands(0,4,cantidad);

Cool so if we look at our algorithm we just know need to basically create a recursive function to tell us if we should draw or not for each step based on the number of the step.

They look like this for my example:

function calcx(vector , pos) = pos == -1?0:vector[pos]>3?calcx(vector,pos-1)+1:vector>2?calcx(vector,pos-1)-1:calcx(vector,pos-1);

function calcy(vector, pos) = pos == -1?0:
    vector[pos] <1? calcy(vector,pos-1)+1:vector[pos] <2?calcy(vector,pos-1)-1:calcy(vector,pos-1);

Then we just need to call each step so it gets drawn the code is just a loop.

for  (i = [0:cantidad-1])

To add the loop to add the chain all we do is add 4 blocks and make a hole in it using difference at the start. You can get the entire code from my thingiverse page.


You can also order some of them from my Shapeways shop

If you have any questions or something is not clear please let me know I love answering questions and trying to make the articles better.

Live in Puerto Rico and work Remotely (or a guide to Remote Work).

This is going to be a fairly long post but I want to be had detailed has I can in order for this to be helpful.

After a reddit conversation I promised to write down basically the info I know in particular about working remotely in Puerto Rico. Not this does not involve creating a new business but offering a service.

Good professions to do remotely from the island:

  1. Programming – It starts around 50k  and it can go up for has much has low 6 figures while doing 9-5 to remote work. Progressing here will depend on the problems that you can solve and if you are in a desirable area of work. This change with time. Right now if you are getting into this I would recommend the mean stack, python or unity.
  2. DevOps / Db Admin – about the same has programming with that said it tends to start about 10k lower.
  3. Copywriting – Freelancing copywriting can make from 20k – 50k. Getting up in this field requires a bit of luck since you need to be able to attach your name to some lines that became famous.
  4. Translations – If you are able to translate and are good in both languages there are always opportunities here. Full time translation makes about 30k using the normal websites(list is below).
  5. Grant Writing – All nonprofits need you at the lowest tier you work for a fee of grants that you get. At the top end you get a salary  assigned to you from the non profit. Is normal to get between 30k –50k.
  6. Stock Photography / Videography – 30k to 40k if done full time going above this will require you to specialize. The equipment needed is pretty decently cheap and if bought used it goes down even more.
    One important thing here is that this will take time when you start you won’t make that much but has you go building a portfolio it starts adding up. They tend to have a long tail. I recommend dreams time to start.
  7. Creating courses for online / Bookwriting – There are many places where you can sell classes right now If you have an unique skill and you can market yourself this is a good gig. It all depends on your ability to create and online following.
  8. 3d modeling – Freelance 3d modelers get hired pretty often and can get paid between 30-50k anything higher than that is similar to the copywriter needs some projects with fame.
  9. Photography Retouching / Video editing – Freelancing here makes about the same has 3d modeling. Is similar in the ways to increase your earning potentials.
  10. Import items and sell them using fulfillers – This will depend on what you do but running a subscription box or a niche website using shopify and selling a few items can leave a decent amount of money. This requires money to start and knowledge of marketing. The trick is to use a fulfillment house in the US so the product never goes into Puerto Rico. You are basically and orchestrator.

Has you can see this are all professions that can be done from home in a disconnected sort of fashion.

How to get the jobs

  1. Create proof of your work and a online presence. Go answer some questions in quora so people can tell that you know what you are doing.
  2. Hit the freelancer sites – they got most of the categories above. Make sure that you polish your responses to get money and get the premium subscription. I recommend trying at most 2 at a time so you can dedicate time. Pre-baking a portfolio helps.
  3. For stock video and photography
  4. Create call lists and hit the phone.  For example for programming make a list of startups incubators and co-working spaces. Make sure that they all know that your services are there and that you can find more people in the island if there is a need.
  5. Join the community of new business and startups in the island. Startups after hours in facebook is super active.  Visit Piloto 151 so they know your face even if you have to drive from the west coast.
  6. Make sure you are in the appropriate sites for search.(looking and posting your services offered).
    1. Craiglist – Post on the ones in the states.
    2. Reddit – hit r/forhire.
    3. – You want the local gigs if you can.
    4. –> Pretty self explanatory.
  7. Build events for the community related to your area when you can. If no one in aguadilla is talking about freelancers and what can they do nobody will think of you. Even if is just a coffee talk for microstock photography.

What is the end goal.

Build relationships you want to get gigs that lead to sustainable gigs things that you can keep doing. Retainers are amazing in this situation.

Last but important details.

Make sure you have money to cover your bills for 4 months has soon has possible. In the case of Puerto Rico make sure that you also have enough money in case you need to suddenly relocate back to the US or wherever you moved from.

Really important make sure that you have talked to a lawyer and accountant before you make decent money there are a lot of benefits you can take.

BookMArkLet vS Chrome plugins

I spend quite a bit of time researching bookmarklets and specific browser plugins in particular chrome plugins. Below my notes on how to get started and what my conclusions where of when to use the different technologies.


Let’s start first with the bookmarklet’s since they are the older technology. Basically is an anchor that runs javascript and allows you to execute javascript on the page it is. If you bookmark this anchor it means that you can have a piece of javascript on whatever page the user is browsing which is really useful if you want to do dom sensitive operations. Like for example reacting to a specific page and provide an ui or adding a button to the netflix web interface(someone did that).  Let’s look at a small example if we add this to a link it will let us create a quick target link for the place I work.


Click me

You are going to end in the bad link page because my blog is not something valid to process. With that said if you go to you will see it process thru.

For Bookmarlets over the years the capabilities for have increased with the ability to add libraries and your custom javascript files into the bookmarklet. Additionally they currently got support on every browser on the desktop and mobile(at least the big 3’s). So in conclusion they are great for:

  • Manipulating the dom.
  • Adding new elements to a page.
  • Cross Browser compatibility.

Below a few links that help. I really recommend using the bookmarlet generator since it trivializes the process of creating a bookmarlet.

Bookmarklet Basics

Bookmarklet Generator

Chrome Plugins

Alright So all the browsers now a day have a plugin system that is proprietary and work by using javascript to call api’s they have exposed in a sandbox. 

The plugins can do all that a bookmarlet can except be cross browser compatible. Additionally to that they provide a few advantages in the case of chrome:

  • Access to the chrome api’s – This allows you to store data, set alarms even capture the desktop has an image. Aditionally they include new api’s so if you need any of these capabilities doing a plugin is a great idea. Documentation
  • They give you access to the store. Bookmarklet’s need to be discovered via someone hitting your site. The plugins by being on the store you can benefit from someone browsing the new arrivals list.
  • You don’t have to click to activate it. Is running on the background so if your experience would benefit from not having a click to start this is the way to go.

In terms of effort required for simple task they are both very straight forward and there is clear documentation on the web.

With that said the not being cross-browser compatible is a really big weakness in terms of maintenance.

How to build a chrome plugin

K9 (Dr Who) Cosplay MAsk PRoject

A few months ago a friend of mine mentioned that she wanted some headgear for a cosplay costume. I’m not a doctor who fan, so I had no idea what was involved when she said K9, but thought that maybe we could 3d print it. Got home pretty excited about having a new project and went to google to see what it was.

So it was the headpiece for this:


Interesting!!  I decided that it did not had that many curves so it was probably something that I could do in openscad. Called my wife had her measure the dimensions of my head.  So I could use them has a base and started hitting it.  After about an hour or two I was here.


I send that image to my friend and we talked about a few revisions that it could have. For example airflow is pretty constricted in here. So we decided to add some vents and that I was going to go ahead and get the ears modeled.  The vents became a bit tricky because substracting a lot of geometry became heavy for openscad. So I had to make them bigger till it was within the boundaries of what I could render. The final design was the following:



So here we were it was modeled and it looked the way we wanted it to be. With that said there was no way that we could fit this into the print bed. So I measured my print volume and placed into openscad to make distinct stl’s. Ended up with Basically 10 stls 8 for the parts surrounding the head and 2 for the nose. Some of the sides where interesting to print because they consumed the entire bed of the printer. I printed at lowest resolution due to the size of the printe with that said still ended with at least  one 28 hour print.

Nose top printing


Parts stacked


Testing the volume limits of my printer – printing the sides


So yeah it was an experience to print it. I basically finished an entire roll of hatchbox most of it was at 60% infill since it was going to be worn I wanted for it to be solid. So after about 130 hours of printing and one z end stopper that broke halfway thru it I was done printing.


So got some loctite extra strength and started the gluing process. Once we got to this point we started checking to see if the face actually fits inside of the mask. We realized something, the measure we got was not accounting for ears. So we decided that we would not make it completely closed and use a strap in the back and bend the sides to fit(A bit of a spoiler that plan worked).


So here it is all glued together.


I delivered it in this state and let them do the finishing touches since I had ran out of time and they needed it for the Providence comic con. Here is the final piece(Aparently the ears fell during the con).


So things ended up pretty well with that said learned a few lessons:

1. Make sure to measure ears or use a model of a head when modeling head gear.

2. Try to slice parts to maximize volume. I think some better alignment on the bed would had help with printing the nose on one piece.

Hope this was worth reading.

Oh yeah before I forget you can find the files in thingiverse at:

Some more 3d printing adventures

I have been working on a costume for halloween for a friend is the biggest print that i have done today. So far it’s been about 36 hours of printing. In the end is supposed to be K9 from Doctor Who. Once Halloween Passes I plan on uploading it into Thingiverse so others can get the files.


I modeled the piece in openscad. Some pictures of what I got so far.



It was going good then i decided to print today a Marvin to activate my 3dhub and got probably the worst print quality I have gotten since I got my Wanhao printer.




The bed seems calibrated so I’m guessing that my extruder might be clogged. I have never cleaned it yet so that might be an interesting experience to go thru.

I’m trying to write a bit more in here. I also got a printm3d about a month ago and want to review it and show some of what i gotten out of it.


Unboxing And First Impressions Wanhao duplicator i3

A few months ago I decided to jump on the bandwagon and get the duplicator I3. My old printr bot has been dead for more than 6 months and I wanted to get into the 3d printing game again (Note my printr bot was from the originals – so old).

I received my unit this past Thursday. It came in great condition and was packaged with care and handled well by FedEx.  Alright, so I opened it up let’s see what was on the box.


We have a base plate , a tower, and the power supply/computer unit. In terms of parts, it was a pretty easy setup. The memory card, which was included, had the instructions which was pretty straightforward. Essentially, screw 4 screws between the base and the tower and add the handle to the spool. After that, all I had to do was plug in the electric switches.

Following the instructions in the memory card, I first leveled the base which took about 10 minutes – I was ready to print. Start to ready in basically 40 minutes. The card already had a sample file called OK.gcode so I selected it without knowing what was in it.


So here we go. The first print took about 2:00 hours the noise level was quieter than my old printer but the base did squeak a bit whenever it moved but nothing unmanageable. It had no problems and completed the print. The model that had been prepackaged was the following.



The quality was excellent, honestly better than what I had gotten with my previous printer. The model came in a raft that auto detached the moment I peeled it off. So far so good; the entire experience had gone smoothly. The only thing that felt a bit off was that some of the English in the instructions needed a bit more proofreading.

I went to my box and installed Cura, it’s also in the memory card. I followed the instructions and decided to print the ultimaker robot model on the fast, normal, and high quality settings without making any changes. My results are shown below (They are all white – the grey color is from me not setting my camera flash correctly):






High Quality


This was the first part of the experience that needed some improvements. The problem was basically that the filament was not the standard size (I had to use a caliper) that Cura is set for. This was also true with the nozzle. Additionally, the temperature of 220 is a bit high for the material (PLA) included in the box. They should provide these instructions on the box to make the unboxing experience smoother. In the Cura for Wanhao instruction file, it mentions that there are profiles available but the provided link did not work.

Taking this into consideration I created my own profile and reprinted the model.
Custom profile

It looked pretty good. I was happy with the model.

At this point I also had an army of robots Smile


So far I had not printed a model of my own so I fired openscad and created a stl for a rook that I had designed. I used the same profile and did a print and it ended up like this:


It has some warping on both of the 2mm details but all the other edges are pretty high fidelity. I sent an email to Wanhao so I could get the settings they used for the hand model and hope to get the answer soon.

Last but not least, I set octoprint but was getting delays while printing and decided to go back to using the sd card print method. I think the delay occurred because my rasberry pi is super old and it’s probably a bit bugged. Going to get one of the new ones next month to try again.

So far I think this is a leap ahead in terms of being a beginner printer. The only problem that needs attention is a bit more details on a profile to get started with for Cura.

A picture of the printer working:


Link to the printer in amazon