Software Developer and a bit more

Software Developer and a bit more

You should check out the fable project, is awesome.

Pastel de tres leches, 3 Milk cake

For English version, just scroll down.

Hoy traigo la receta para hacer pastel de tres leches :)

La lista de ingredientes es la siguiente

2 tazas de harina

1 barra de mantequilla

1/2 tazas de azucar

7 huevos

1/2 taza de leche

1/4 taza de agua

4 cucharadas de royal

2 latas de leche evaporada

3 latas de leche condensada lechera

500 g de crema

Media taza de brandy

Instrucciones para preparación

Romper los huevos y poner la clara (cosa transparente del huevo) en un contenedor aparte.

Capear la clara, (batirla con la batidora hasta que se haga espuma).

Mezclar en un tazon grande, la yema (cosa amarilla del huevo), harina, azúcar. Royal, mantequilla (yo la derrito en el horno de microondas pero no es necesario), leche, agua.

Mezclar todo y agregar la clara batida.

Seguir mezclando.

Calentar el horno a 176 grados centigrados. Hornear el pastel por 35 minutos.

En la licuadora mezclar la Leche clavel (leche evaporada) , lechera (leche condensada endulzada), la crema y el brandy.

Sacar el pastel del horno después de 35 minutos, dejar enfriar ponerle la mezcla de leches, y decorar al gusto :)

English version


2 cups of flour

1 bar of butter (1/2) cup

1/2 cups of sugar

7 eggs

1/2 cups whole milk (or whatever milk you like, I guess anything will do)

1/4 cups of water

4 tb spoon of baking powder

500 grams of sour cream

2 cans of condensed milk

2 cans of evaporated sweetened milk

1/2 cups of brandy


Separate the eggs white and yolk, and foam the egg white with the mixer.

The mix in a container the flour, butter, sugar, egg yolk and white, milk, water and baking power.

Bake at 350 F for 35 mins

then in the blender and in a separate container mix the condensed milk, evaporated milk, sour cream and brandy.

When the cake finish baking take it out of the oven, let it cool down and then proceed to pour the milk, cream and brandy mix into it, wait a couple of hours for the bread of the cake to suck the milk/brandy mix and presto.

Finally eat the whole cake in one weekend and regret it on Monday.

One plus 5 dual lte Sim dual ATT

So if you found yourself locked out due to att disabling 2g in their network (in the US) and now you find that your dual Sim phone can only have one Sim working at a time, you may be looking for a solution, or a phone that can enable both Sims simultaneously again. 
So you probably have found the one plus one and wonder if this will serve for the purpose of having dual lte Sim enabled at the same time. 

The short answer is yes :), one plus 5 works with dual att Sims,  go for it. 

The long answer may start with, why is my current phone not able to work with dual lte Sims, what is the point of dual Sims then, or why did the manufacturer of the phone, in my case one plus, build it without the capability of dual lte. The answer is actually, is not a mistake from  the phone manufacturer, but rather from the soc manufacturer, (normally qualcomm). 
So the piece of hardware that can not handle dual lte is the soc (system on chip) which in mobile phones is the mind and heart of the phone, commonly containing graphic card, processor, storage controller and wireless connectivity (Bluetooth, lte, wifi). 

With that in mind, one plus two have a snapdragon 810, this model of chipset does not support dual lte Sim, On the other side, one plus 5 have a snapdragon 835, which does support dual lte Sim. 

Why is so hard to found if will it work? In part because there is a lot of confusion, from phone manufacturers and even within chipset manufacturers. Qualcomm documentation shows that both snapdragon 810 and 835 are lte dual active chipsets, but that is not true. 

I can not stand for any other phone other than one plus 5 because that is the only one I have tried, but I presume that any dual Sim phone that have a snapdragon 835 inside should work with dual lte Sims (dual att Sims in the US for example). 

Tutorial 1 – The Basics

In this tutorial we will review the basic elements and panels of FABLE as well as the basic functionality to start getting in touch with the environment.


Building a page in FABLE

Here is a fast video of a page of my tale being created in FABLE, The video is speed up 64x. Also I show to you the texture result that comes from the publish of this exercise as well as a video containing the end result. Next post I will talk about how to make it work on ios.

Fast creation.

Textures generated

second images



Download the latest version from the official site

Fire Ant Box2d Level Editor feature texture optimizations

As many of us know, when the time comes to reduce the size of our applications the first thing that comes to our minds is textures, textures usually takes the biggest part in games or rich interactive applications.

Taking this into account, FABLE have a series of heuristics aimed to reduce the size of the textures, by resizing them, rotating them and so.

For example, lets take a look at the next group of elements for a page of my book. This elements are with the size that the artist sent to m. As you may guess, In the final version the flowers should be smaller than the cat and the window should fit the window in the background. But this is what I got, very big and highly detailed images for my page, which is cool. This image is scaled, the original size is 7023 x 8122.




The next image is a screenshot of the page finished in the program, at the end, this page should look like this.



Now comes some of the nice feature of the program, as you  may remember from the last post, Automatic splitting tool, the program takes care of importing and splitting the images so that is painless for the user, so you got this result very fast. Then you are ready to test it in you ipad project so you would be likely to click on publish. this action generates the following couple of files.


There is the classes for ipad and the textures, as you may see, the texture atlas looks way different from the original thing. next we can see it more neat.


We can see that the flowers have a size that makes sense and everything seems to keep an aspect ratio. This texture was generated by the program automatically. Also we can see more optimizations. for example the program can rotate the images to a position where they reduce the amount of white space. Let’s take the example of the window, in the original image, the window was rotated in a diagonal way that makes it waste a  lot of space, in this version the program gets aware of that and rotate it to stay vertical so that it saves more space. This rotating technique can save between 10 an 15% of space.  BTW the size of the texture for retina display is 1024×1024. It is 57 times smaller than the first image I showed to you.

Here is a video of the page in the program


And here an example of the page running on ios simulator.




Download the latest version from the official site

Automatic Splitting tool

This tool allows you to import an image or texture that contains multiple elements and the tool automatically process the image and split all the elements. Very useful.


Download the latest version from the official site

Fire Ant Box2d Level Editor Introduction


Hi there, here is a very beloved piece of software in which I have been working lately. So, what exactly is Fire Ant Box2d Level Editor, FABLE for short.

Well as the name says, FABLE is a Box2D Level Editor, It gives you a GUI in which to develop Box2D environments, It is useful for building small Sketch’s as is useful for building full levels. Some of the features on the box are, the capability not only to build the physics environment, but also the ability to map the textures to each body. the tool is also capable of generating optimized texture atlas.

The develop environment currently supports a lot of user experience features as is as the Copy Paste capability, the undo redo stack, load and save files and the capability of exporting a XML file with the definition of the world and also objective C code for use in IOS projects.

As for the development tools it contains specific tools to create joints, bodies and fixtures, it contains a tool to create irregular polygons for both bodies and fixtures, it can handle all of the features of Box2D like collision levels and masks, densities, frictions, damping frequencies (for some joints like distance joints), motors, torque, angles, limits, and so on and so for.

It also contains playback controls for test the current environment and also for change the original environment state.

Another great feature is that for textures it can handle Layers, so you can distribute objects among layers, this is specially useful for levels that have more than one interaction layer or simply to handle in a better way the elements on the screen.

Here is a small screenshot of the GUI with some explanations.


Yes I know, the buttons are horrible, I drew them by myself Smile with tongue out.

Here you can see a bit of the functionality in this video, narrated with my melodious voice Open-mouthed smile.

FABLE Demo One


Well, that is everything for now, I’ll be publishing new entries with more small tutorials and also more new features to the program cheers and here is the link to the program.

Box2dLevelEditor Download

Also visit the new official site

And here are the FABLE file and the images just in case you want to try it by yourself.’’

Let me know if it was useful to you

Heap implemented with a Binary Tree How to find the position in O(log n)

Today I was trying to find a complete implementation of a heap in google. Although I found a couple of implementations using an array, I never found a single one that where complete and uses a binary tree instead. So I decided to implement one.

Now, briefly explained, a heap is a data structure that can keep the priority of a set of values and that the value with the highest priority can be accessed in O(1) time.

This structure have other properties, for example, to insert and prioritize an element takes O(log n) , and the same takes to remove the element with the highest priority.

Now, a heap implemented with an array can meet this requirements until you reach the end of the array, in which case the operation will fail or it will need to move all the elements to a bigger array, passing from a complexity of O(log n) to O(n).

Depending on the way the Heap-Array is implemented one of two things can happened. You could end with an implementation that makes a lot of memory reallocation but waste little memory or an implementation that makes fewer memory reallocations but may waste a lot of memory in a worst case.

On the other hand, an implementation with a binary tree doesn’t waste memory, doesn’t do memory reallocation and always perform insertions in O(log n), at least as far as you make a good implementation. I hope that mine is one of those.

Now, the tricky thing with a heap using a tree is how to find the place to store the new element.

In an array implementation you just keep a variable storing the number of elements in the heap and then with some pointer arithmetic you can access the slot in which you need to store the next element.

In a binary tree you can not access the node you want like that but instead you need to traverse the tree to find the next available slot.

Now, since in a heap tree you need to satisfy the Complete Binary Tree condition CBT, you need to store the new values in a Breadth First way, this is, you can not insert a node in a certain level if the previous level is not completely filled.

You can see this video that explains very well this property in a heap tree.

Heap Tree By bogateiit


This lead to the problem of how to find that very specific place in an efficient manner. Sadly my well beloved wikipedia explains that step as  “Add the element to the bottom level of the heap.”  A rather ambiguous explanation and certainly not very helpful.

The first thing we noticed is that we may be able to find the correct part in the tree with a slightly modified version of a BFS, the problem with that is that the complexity turns form O(log n) to O(n)  and life became meaningless. The other solution becomes by analyzing how a binary search is performed.

Certainly you can not perform a binary search in something that is not sorted as for example, our binary heap but there is something interesting in this search that I’ll explain with some chars Open-mouthed smile.


Up there you can see four balanced binary trees with only the numbers from 0 through the maximum capacity of the tree with a certain amount of levels. So for example in the first tree we only have 0 because that is all the elements that you can store in a one-level tree. In the four tree we have the elements from 0 to 14, that is 15 elements that is the maximum amount of elements you can store in a 4 level binary tree.

The number of elements that you can store in a n level tree is given by the formula 2n –1 .

Now If you haven’t realized, the last level in all the trees is filled with only even numbers, even more, all the even numbers in the tree are in that very last level. And of course that cero is an even number Smile with tongue out, just in case you where wondering.

Now, that property is useful because of this next chart. Here you can see the way a heap is constructed and the way a balanced binary tree looks like.


As we discuses earlier, perform a binary search is easy and efficient, unlike performing a BFS that is slightly more complicated and not that efficient, so it would be nice to be able to perform a binary search instead of the BFS, the only thing we need is to transform the heap index to a binary search index and that is not too complicated.

So we have our desired heap index that for example could be that 3 in the heap-tree, and the index of where a binary search would perform efficiently, that is the 0 in the balanced binary tree.

We can realize that in the heap three the last level is filled with consecutive numbers, we can translate to start from zero if we simply subtract the number of elements that are in the higher levels, for the case of the last chart that number would be 3.

So our numbers would end like 0, 1, 2, 3 instead of 3, 4, 5, 6, now if we multiply each of these numbers times 2 we ended with a series of even numbers, that numbers are 0, 2, 4, 6 that is actually the numbers on the last level of the binary tree.

So we can came with the next magic formula.

(DesiredHeapTreeIndex – power(2, deepOfTree – 1) +1) * 2;

this part

power(2, deepOfTree – 1) +1

is the number of elements in the higher levels.

DesiredHeapTreeIndex  this is the number we want to convert.

and the 2 is a 2 to convert it all to even numbers.

This will help us to make a binary search only because we are not looking for a specific value but instead for a specific position in the tree.

With this we can create a function that given a heap tree, its deep and the position return a pointer that points to that specific slot welter this is empty or not.

The function will look pretty much like that of a binary search.

Node ** getPonterofPosition(int dest, int current, int deep, Node ** root){
    if(dest == current)
        return root;
    if(current > dest) 
        getPonterofPosition(current - pow(2, deep-1), dest, deep-1, &(*root)->l);
        getPonterofPosition(current - pow(2, deep-1), dest, deep-1, &(*root)->r);

In the above function, the dest variable is the position we want to find, the current is the current node position, since we are not traversing a real balanced binary tree we need it to perform the binary search.

So a call to this function will look similar to this.

int htindex // the heap tree index Node * root;// the root of the tree int deep = (int)ceil(log((htindex+1)/log(2)); //calculating the deep of the tree. int dest = (htindex- pow(2, deep-1))*2; //converting from heaptree position into bt position int current = pow(2, deep-1)-1; Node ** lePointer = getPointerPosition(dest, current, deep-1, &root);


//Now we can increase htindex and store a new node in the obtained pointer.

htindex ++;

lePointer = new Node(2);


so there it is the node stored where it should be stored. Now wee need to implement all the other stuff for heapify the tree.

Now, because right now it is getting late, here are the whole implementation with the other shinny stuff Open-mouthed smile, I promise to eventually finish this entry.


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <stdint.h>

typedef struct Node{
    struct Node * l;
    struct Node * r;
    int val;

typedef struct Heap{
    Node * root;
    bool isMaxHeap;
    int count;

Heap * createMaxHeap(){
    Heap * h = (Heap*)calloc(1, sizeof(Heap));
        h->isMaxHeap = true;
    return h;


Heap * createMinHeap(){
    Heap * h = (Heap*)calloc(1, sizeof(Heap));
        h->isMaxHeap = false;
    return h;


Node * createNode(int val){
    Node * newNode = (Node *) calloc(1, sizeof(Node));
        newNode->val = val;
    return newNode;

void insertAndHeapify(Node *n, Node **root, int current, int dest, int deep, bool isMaxHeap){
        *root = n;
        if( ( isMaxHeap && n->val > (*root)->val) || (!isMaxHeap && n->val < (*root)->val)){
            n->val ^= (*root)->val;
            (*root)->val ^= n->val;
            n->val ^= (*root)->val;
        if(current > dest)                    
            insertAndHeapify(n, &(*root)->l, current - (1<<(deep-1))/*current - pow(2, deep-1)*/, dest, deep-1, isMaxHeap);
            insertAndHeapify(n, &(*root)->r, current + (1<<(deep-1))/*current - pow(2, deep-1)*/, dest, deep-1, isMaxHeap);

bool insertInHeap(Heap* h, int val){
    Node *n = createNode(val);
    if(!n) return false;
    h->count ++;

    int deep = (int)ceil(log(h->count+1)/log(2));

    int dest = (h->count-(1<<(deep-1)))<<1; //= (h->count - pow(2, deep-1))*2;

    int current = (1<<deep-1)-1; //= pow(2, deep-1)-1;

    insertAndHeapify(n, &(h->root), current, dest, deep-1, h->isMaxHeap);


void Heapify(Node * root, bool isMaxHeap){
    if(!root || (!root->l && !root->r))
    Node * tmp;

    if(!root->l || !root->r)
        tmp = root->l ? root->l : root->r;
    else if (isMaxHeap)
        tmp = root->l->val > root->r->val ? root->l : root->r;
        tmp = root->l->val < root->r->val ? root->l : root->r;

    if (isMaxHeap && (root->val >= tmp->val))
    if (!isMaxHeap && (root->val <= tmp->val))

    root->val ^= tmp ->val;
    tmp ->val ^= root->val;
    root->val ^= tmp ->val;

    Heapify(tmp, isMaxHeap);


Node * removeLastInsertion(Node **root, int current, int dest, int deep){
        return NULL;
    if(current == dest){
        Node *t = *root;
        *root = NULL;
        return t;
    }else if(current > dest)                    
        removeLastInsertion(&(*root)->l, current - (1<<(deep-1))/*current - pow(2, deep-1)*/, dest, deep-1);
        removeLastInsertion(&(*root)->r, current + (1<<(deep-1))/*current - pow(2, deep-1)*/, dest, deep-1);

int peakFromHeap(Heap *h){
    if(!h || !h->root)
        return 0;
    int deep = (int)ceil(log(h->count+1)/log(2));

    int dest = (h->count-(1<<(deep-1)))<<1; //= (h->count - pow(2, deep-1))*2;

    int current = (1<<deep-1)-1; //= pow(2, deep-1)-1;

    int val = h->root->val;
    Node * t = removeLastInsertion(&(h->root), current, dest, deep-1);
        h->root->val = t->val;
    h->count --;

    Heapify(h->root, h->isMaxHeap);

    return val;

bool isHeapEmpty(Heap *h){
    return h->root == NULL;

void printHeapInBFS(Heap * h){
    if(!h || !h->root)
    Node ** q = (Node **) malloc(sizeof(Node*)*(h->count));
    int i = 0;
    int r = 0;
    q[i++] = h->root;
        Node * tmp = q[r++];
        printf("%i,", tmp->val);
            q[i++] = tmp->l;
            q[i++] = tmp->r;


void printInOrder(Node * root){
    if( !root)
    printf("%i,", root->val);

void printHeapInOrder(Heap *h){

void printPreOrder(Node * root){
    if( !root)
    printf("%i,", root->val);

void printHeapPreOrder(Heap *h){

int main(void){
    Heap * h = createMaxHeap();
    //Heap * h = createMinHeap();
    insertInHeap(h, 15);
    insertInHeap(h, 14);
    insertInHeap(h, 13);
    insertInHeap(h, 12);
    insertInHeap(h, 11);
    insertInHeap(h, 10);
    insertInHeap(h, 9);
    insertInHeap(h, 8);
    insertInHeap(h, 1);
    insertInHeap(h, 2);
    insertInHeap(h, 3);
    insertInHeap(h, 4);
    insertInHeap(h, 5);
    insertInHeap(h, 6);
    insertInHeap(h, 7);
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));
    printf("peak: %i\n", peakFromHeap(h));


cheers >.<

  • Steps to be happy. 1- if (man.haveDream()){ 2- man.followDream(); 3- } 4- while(!man.haveDream()){ 5- man.startDreaming() 6- } 7- goto 1;
© 2018: Esteban Perez | Easy Theme by: D5 Creation | Powered by: WordPress