Things I learn, enjoy or care about

"We are what we repeatedly do. Excellence, therefore, is not an act but a habit" - Aristotle

Latest Posts

Sunday, May 2, 2021

Introduction to Event Driven Architecture and Microservices

 Hello there! I've been creating recently a new series of videos on my Youtube Channel talking about Event Driven Architecture and Microservices.


If you are interested don't miss them. Here's a list with the description and links to the videos:


Event Driven Architecture Introduction



Introduction video to Event Driven Architecture (aka Message Driven Architecture or PubSub). 

With this video I start the series of videos regarding Event Driven Architecture, also known as Message Driven Architecture or Publish/Subscribe (PubSub) in the most generic concepts. We start covering the concepts, looking into the pros and cons and some examples of how this architecture works. 

In the next videos in the series I will be covering also additional concepts that relate to microservices and some additional software architecture patterns associated to EDA. At the end of the video you will get a clear idea of what is Event Driven Architecture.

 

The Saga Pattern: Orchestration vs Choreography

https://youtu.be/C0rGwyJkDTU

Learn about the Saga Pattern in Microservices in order to do distributed transactions, comparing Orchestration vs Choreography. 

In this video, the second in the series of Event Driven Architecture, I explain the complexity of doing transactions in distributed systems, specifically in Microservices. Throughout the video I explain how we move from a single system (monolith) to a distributed architecture using Microservices, how to deal with transaction, explain the Saga Pattern with its two variants: Orchestration and Choreography and how they are closely related with Event Driven Architecture (EDA).

 

Sunday, October 11, 2020

Practical Software Architecture Series (part 2): Scalability


Continuing with the Practical Software Architecture Series, this week I'm releasing the second video in the Software Architecture Course covering scalability basics like horizontal vs vertical scaling, CAP theorem and more. 


In this second video of the Software Architecture Course series, I cover scalability basics and important considerations you need to take into account when scaling a system, like Horizontal Scaling, Vertical Scaling and the CAP theorem.

You will learn how to split the load in stateless and stateful services, load balancing, sharding strategies and replication. 

I also introduce some topics like consistent hashing and other relevant topics.

 


 

Don't miss it! 



Sunday, September 27, 2020

Practical Software Architecture Series

 Software Architecture is a topics that I'm really interested about, so recently I started a new series of videos on my Youtube channel to cover them. 

In these series of videos I will be doing an Introduction to Software Architecture in a practical way. I try to condense many topics explained by many great authors and add the practicality needed for people first learning it.

I will be introducing concepts like:

- Architectural patterns.

- Layered Architecture

- Scalability and Scalable Systems Design

- Vertical vs Horizontal Scaling.

- Software quality.

- How to approach a new project.

... and many other topics!

The way I will presenting it is while building an every time more complex/complete eCommerce site.


If curious, don't miss the first video in the series:



Computer Science

Sunday, December 27, 2015

Mochileros por Asia: Presupuesto 2015/2016

This post is also available in English here.

Has decidido que quieres viajar a Asia y ahora toca la pregunta decisiva: ¿Cuánto me costará?

En 2015 mi esposa y yo hicimos un viaje de mochileros por varios países de Asia, incluyendo: China, Japón, Tailandia, Malasia, Singapur, Laos, Vietnam, Camboya e India, que se extendió por algunos meses hasta casi Noviembre. Seguimos los consejos de diversos sitios web sobre tips viajeros y costos, ya que era la primera vez que hacíamos un viaje sin ticket de regreso; revisamos nuestro presupuesto y nos lanzamos a la aventura a ver si nuestra matématica era correcta, sólo dejando un depósito para el ticket de regreso.

Ya que nos ayudaron muchos posts de otras personas, quisimos publicar un post para ayudar a otros también. Abajo mostramos un promedio de los gastos diarios por país, y qué tipo de actividades hicimos con ese dinero, para que tú también saques tus cuentas.

Gastos Indirectos de Viaje

La mayor parte de los costos que encontramos en diferentes blogs en Internet fueron bastante precisos, e igual al final pueden adaptarse de cierta manera al presupuesto de cada persona persona de las cosas que le gustan (o no). Una cosa que generalmente dejan excluidas en los blogs es el transporte entre países y algunos otros gastos como visas, vacunas y seguro de viaje.

En nuestro viaje, gastamos cerca de $21 diariamente en estas áreas, siendo la más costosa el seguro de viaje(World Nomads) que tenía una cobertura extensa. Adicionalmente al seguro de viaje, este monto también incluye: vuelos hacia/desde Asia, transporte entre países, vacunas y roaming internacional antes de empezar a usar SIM cards locales.

Gastos Específicos por País

La mayor parte de las categorías mostradas a bajo son auto-explicativas, excepto quizás Turismo. Esta categoría básicamente incluye las cosas divertidas: atracciones, paseos, tours, entre otros, y (en los casos que aplique) los pagos de visa. Si tienes cualquier pregunta sobre la información en este post, no dudes en escribirla en la sección de comentarios :)

Por simplicidad, hemos incluido todos los gastos relacionados por cada país (incluyendo visa y transporte entre ciudades) en el resumen de cada uno. Todos los costos son por persona.

Para tener un promedio total (que incluye todos los gastos desde planificación del viaje al regreso a casa) tendrías que sumar los Gastos Indirectos con los Gastos Específicos por País. En términos matemáticos:

Gasto Total de Viaje = Gasto Indirecto de Viaje + Gasto Específico por País



Camboya


Gastos Diarios Camboya por Categorías

Día Típico:
Nos hospedamos en hoteles de bajo costo, desayunar en un restaurant, llevarnos snacks para el día, visitar atracciones (cuando era posible, caminando, pero la mayor parte de las veces en Tuk Tuk/Remolque), almorzar/cenar en un restaurante de precios moderados (pizza, pasta, arroz, hamburguesas) en zonas turísticas (los precios los dan en USD), regresar al hotel o tomar un transporte nocturno a otra ciudad.

Algunas veces donamos o compramos alguna cosa para ayudar a los locales, y como era uno de nuestros últimos países, compramos un par de cosas como regalos.

Tips para Ahorrar: Puedes ahorrar dinero en Tuk Tuks y comida. En Tuk Tuks siempre negocia (no seas muy rudo, un par de dólares hace una diferencia para ellos, pero tampoco te dejes), o trata de hospedarte cerca de las atracciones. En cuanto a comida, puedes intentar calles secundarias, buscando comida local, en vez de las zonas más turísticas. No compres nada (comida o regalos) de los vendedores cerca de las atracciones.

Tasa de Cambio Promedio: 1 USD ~ 4000 KHR.

Costo Diario Promedio (USD): $44 (incluyendo la visa y Angkor Wat, si no: $32).



China


Gastos Diarios China por Categoría
Día típico: 
Hospedarse en apartamentos de Airbnb, hacer desayuno y cena en casa (la mayor parte de las veces), comprar snacks para el día, usar transporte público para llegar a todas las atracciones, visitar las atracciones, almorzar o cenar (sólo una comida) en un restaurante de franquicia o en ferias, regresar al apartamento o tomar un tren nocturno a otra ciudad.

Tips para Ahorrar:
Usa los pases de transporte público. En general no vimos grandes diferencias en los precios, pero quizás puedes encontrar mejores ofertas de comida en algunos restaurantes locales. La comida en la calle es económica también, pero siempre mantuvimos la guardia alta para evitar problemas con la comida. Muy poca gente habla inglés, por lo que debes probar y ordenar basado en lo que ves.

Tasa de Cambio Promedio: 1 USD ~ 6 CNY.

Gasto Diario Promedio (USD): $59.



India


Gastos Diarios India por Categoría
Día Típico:
Hospedarse en un hotel, tener desayuno en el restaurante del hotel, contratar un Tuk Tuk (Auto Rickshaw) o tour por el día (exceptuando en ciudades con transporte público aceptable como Delhi), visitar atracciones, almorzar y cenar (normalmente 2 o 3 comidas al día) generalmente en el hotel, regresar al hotel o tomar un tren nocturno a la siguiente ciudad.

Tips para Ahorrar:
Como lo leí en algún lugar, en India, si no pareces Hindú, eres un símbolo de dólar caminante. Siempre negocia. Después de un tiempo sabrás reconocer cuál es el precio real de las cosas.

La comida es económica, pero ten cuidado de la contaminación de la comida. No trates de ahorrar demasiado en hospedaje: hoteles de menos de $20 la noche son realmente sospechosos. Se muy cuidadoso acerca de las opiniones en Internet y trata de revisar opiniones recientes (preferiblemente que no sean de locales).

En las atracciones, evita a los "Guías Espontáneos", o establece un precio inicial cuando empiecen a explicarte algo. Siempre establece un precio y se firme: siempre tratarán de subirlo al final. No caigas.

Mientras puedas evitar transporte privado y/o negociar un buen precio de antemano, debes poder ahorrar más dinero.

Tasa de Cambio Promedio: 1 USD ~ 60 INR

Costo Diario Promedio (USD): $42



Japón


Gastos Diarios Japón por Categoría
Día Típico: 
Hospedarse en hotel de bajo costo o apartamento de Airbnb, desayunar y cenar comida propia en el cuarto, tener algunos snacks para el día, transporte público para llegar a las atracciones, visitar atracciones y algunos eventos, almorzar/cenar tarde en un restaurante de cadena o de bajo costo, regresar al hotel.

Tips para Ahorrar:
Es difícil ahorrar en Japón, las cosas son costosas. Pero nuestra recomendación es tratar de ahorrar en transporte. Compra los pases de transporte que te sean ofrecidos, siempre ahorras dinero. Desde el Japan Rail Pass a pases multidía. Usualmente se pagan solos con dos viajes.

Tasa de Cambio Promedio: 1 USD ~ 115 JPY

Costo Diario Promedio (USD): $79.



Laos


Gastos Diarios Laos por Categoría
Día Típico:
Laos lo visitamos muy rápidamente, pasando no más de una o dos noches en la misma ciudad. Un día típico sería algo como: tener al menos dos comidas al día en restaurantes, la tercera en casa, más snacks para el día, contratar un Tuk Tuk o tour para ir a las atracciones que no están a distancia caminable (y cuando es posible, transorte público), visitar atracciones, y tomar un autobús a la siguiente ciudad.

Tips para Ahorrar:
Como en todos, negociar los precios de los Tuk Tuks, del resto, lamentablemente no tenemos tips adicionales.

Tasa de Cambio Promedio: 1 USD ~ 7500 KIP

Costo Diario Promedio (USD): $38.



Malasia


Gastos Diarios Malasia por Categoría
Día Típico:
Cada ciudad en Malasia tenía una dinámica diferente: algunas podían ser caminadas, otras tenían transporte público y otras requerían transporte privado, por ejemplo. Sin embargo, un día promedio sería más o menos así: hospedarse en hotel de bajo costo, tener desayuno en un restaurante cercano o el hotel, algunos snacks para el día, visitar atracciones (transporte depende de la ciudad, algunas requieren tours), almorzar en un restaurante (muchas opciones económicas), visitar otras atracciones, cenar y regresar al hotel.

Tips para Ahorrar:
La comida por lo general es económica. Incluso en el KLCC en Kuala Lumpur, puedes tener una buena comida por $3. Hospédate cerca de las atracciones y evita los tours.

Tasa de Cambio Promedio: 1 USD ~ 3.75 MYR.

Gasto Diario Promedio (USD): $38.



Singapur


Gastos Diarios Singapur por Categoría
Día Típico:
Hospedarse en hotel de bajo presupuesto, desayuno y cena en el cuarto (preparado por nosotros), snacks para el día, visitar algunas atracciones (como Marina Bay Sands o templos, pero no atracciones en la Isla Sentosa), almorzar en algún restaurante de cadena, ver show nocturnos gratis o de bajo costo y regresar al hotel.

Tips para Ahorrar:
Como Japón, Singapur es un poco costosa. Pudimos bajar los costos en hospedaje mezclándolo con días de transporte (llegamos un día temprano en la mañana y el último día nos fuimos en tren nocturno a Kuala Lumpur).

Hoteles de bajo costo no son muy cómodos y son costosos. Revisa los hostales que tienen buenas recomendaciones.

Tasa de Cambio Promedio: 1 USD ~ 1.33 SGD.

Costo Diario Promedio (USD): $41.



Tailandia


Gastos Diarios Tailandia por Categoría
Día Típico:

Hospedarse en hotel de bajo costo, desayunar (a veces hecho por nosotros, a veces restaurante), ir a las atracciones (la mayor parte de las veces en tours, pero también caminando o usando transporte público cuando era posible), almorzar/cenar en restaurantes de bajo costo (los tours generalmente incluyen un almuerzo, y nosotros teníamos 2 o 3 comidas al día), snacks, algunas fiestas/shows nocturnos/reuniones, y regreso al hotel.

Tips para Ahorrar:
En las islas (como Koh Phangan), si alquilas una moto en vez de transporte privado, puedes ahorrar más dinero. También, si te quedas en la playa, los gastos bajan, aunque normalmente querrás ir a hacer snorkelling o ir a otras islas. En Bangkok, generalmente es fácil llegarle a los lugares en transporte público.

El consejo más importante: ¡Siempre toma taxis con taxímetro! Si por alguna razón no puedes encontrar uno y realmente lo necesitas, negocia el precio de antemano o ten un chófer de confianza. Esta gente se aprovecha demasiado de los turistas.

Tasa de Cambio Promedio: 1 USD ~ 33 BAHT

Costo Diario Promedio (USD): $44.



Vietnam


Gastos Diarios Vietnam por Categoría
Día Típico:

Hospedarse en un hotel de bajo costo, desayunar en un restaurante, snacks para el día, caminar o ir en tour a las atracciones, visitar las atracciones, almorzar/cenar en un restaurante de bajo costo (usualmente 2 comidas diarias, pero a veces 3), regresar al hotel o tomar transporte nocturno a la siguiente ciudad.

Tips para Ahorrar:
Quizás puedes alquilar motos en vez de pagar tours o transporte privado. Apartando eso, no tenemos muchos consejos adicionales.

Tasa de Cambio Promedio: 1 USD ~ 20,500 VND

Costo Diario Promedio (USD): $ 32



Asia Backpacking Español Travel

Backpacking Asia: 2015/2016 Travel Budget

Este post también está disponible en español aquí.

So, you have decided you want to travel to Asia, and now comes the reality check: how much will it cost?

In 2015 my wife and I did a backpacking trip through several countries in Asia, including: China, Japan, Thailand, Malaysia, Singapore, Laos, Vietnam, Cambodia and India, that spanned for a few months until almost November. We took the advice from several websites regarding travel tips and costs, since it was the first time that we did a travel with no return ticket; made our budget and went on the adventure to see how well was our math, and kept only a backup for the return ticket.

Since we received help from other posts, we'd like to share the information so others can be helped as well. Below is shown an average daily expenses summary per country, and we explain the kind of things we did with that money.

Indirect Travel Expenses

Most of the costs we found on the Internet on different blogs were accurate, and you are more or less flexible on the budget depending on what things you want to do (or not). One thing that is usually excluded from other websites is the transportation between countries and other things like visas, vaccines, and travel insurance.

For our trip, we spent around $21 daily on these travel expenses, being the most expensive one the travel insurance (World Nomads) which had an extensive coverage. In addition to the Travel Insurance, this amount also includes: flights to/from Asia to home country, transportation between countries, vaccines, and international roaming before we started using local SIM cards.

Country Specific Expenses

Most of the expenses categories shown below are self-explanatory, except maybe Travel. This category basically means the fun things: attraction tickets, fun rides, tours, etc and includes (when applies) visa fees. If you have any questions about the information posted, please ask in the comments section :)

For simplicity, we included all country-related expenses (like visa and transportation between cities) on each country's summary. All costs are expressed per person.

To get a total average (which includes all the expenses from planning until returning back home) you would have to sum the Indirect Travel Expenses to the Country Specific Expenses. Mathematically:

Total Travel Expenses = Indirect Travel Expenses + Country Specific Expenses



Cambodia


Cambodia Daily Expenses By Category


Typical Day:
Stay at a budget hotel, have breakfast in a restaurant, grab some snacks for the day, go visit places (when possible walking, but most of the times by Tuk Tuk/Remorque), have budget lunch/dinner (pizza, pasta, rice, burgers) at touristy places (prices are in USD), go back to hotel/take night transportation to another city.

Sometimes donated or bough something to someone just to help them, and since this was one of our last countries, bought a thing or two as gifts.

Saving tips: You can save money on Tuk Tuks and Dining. On Tuk Tuks always negotiate (don't be too hard, a few dollars make a big difference for them), or try to stay close to the attractions. In Dining, you could try secondary streets for local food instead of the main touristy areas. Don't buy anything (food/gifts) from hawkers around attractions.

Average Exchange Rate: 1 USD ~ 4000 Cambodia Riel.

Average Daily Cost (USD): $44 (including Cambodia Visa and Angkor Wat, if not: $32).



China


China Daily Expenses By Category
Typical Day: 
Stay at an Airbnb apartment, have self-made breakfast at home (most of the time), grab snacks for the day, use only public transportation to get to all the attractions, visit attractions, have lunch/dinner (only one meal a day) at a chain restaurant, go back to apartment or take a night train to another city, have a self-made dinner.

Saving tips:
Use public transportation passes. Overall we didn't see big differences on prices, but you might be able to find better dining prices in some local restaurants. Street food is cheap too, but we always kept our guard really up preventing food poisoning. Also very few people speak English, so you will have to try based on a picture.

Average Exchange Rate: 1 USD ~ 6 CNY.

Average Daily Cost (USD): $59.



India


India Daily Expenses By Category
Typical Day:
Grab breakfast at hotel, hire a Tuk Tuk (Auto Rickshaw) or tour for the day (except on cities with acceptable public transportation like Delhi), visit places, have lunch/dinner (2-3 meals a day) usually at hotel, go back to hotel / take a night train to next city.

Saving tips:
As I read somewhere, in India, if you don't look Indian you're a walking dollar sign. Always negotiate, after a while you will get a grasp of what is the real price of things.

Food is cheap, but be conscious about it. Don't try save too much money on hotels, less than 20$ a night are extremely suspicious hotels, be extremely careful about reviews on the Internet and try to check for recent reviews (preferably from non-locals).

In attractions, avoid spontaneous "tour guides", or set an upfront price when they start talking showing you around. Always set a price and stick to it, they will always try to get it up at the end, don't fall for it.

As long as you can avoid private transportation and/or negotiate a good price upfront you should be able to save more money.

Average Exchange Rate: 1 USD ~ 60 INR

Average Daily Cost (USD): $42



Japan


Japan Daily Expenses By Category
Typical Day: 
Stay at either budget hotel or Airbnb apartment, self-made breakfast in room, grab some snacks for the day, use public transportation (use passes) to get to places, visit attractions/events,  have a late lunch/dinner at a chain or budget restaurant, go back to hotel, maybe have another snack before bed.

Saving tips:
It's hard to save in Japan, things are just expensive. But if there was a category you could focus, we would recommend transportation. Get all the passes you get offered, you will always save money. From the Japan Rail Pass to multiday passes. Usually they get paid with 2 trips. 

Average Exchange Rate: 1 USD ~ 115 JPY

Average Daily Cost (USD): $79.



Laos


Laos Daily Expenses By Category
Typical Day:
We went though Laos pretty quick, spending no more than one or two nights on the same city. So a typical day  would be: having at least two meals a day in restaurants, having either breakfast or dinner at home, plus some snacks for the day, hire a Tuk Tuk or tour for attractions not in walking distance (when possible, public transportation), visit attractions, get a bus to the next city.

Saving tips:
Besides negotiating prices with the Tuk Tuk drivers, sadly we cannot give additional tips.

Average Exchange Rate: 1 USD ~ 7500 KIP

Average Daily Cost (USD): $38.



Malaysia


Malaysia Daily Expenses By Category
Typical Day:
Each city in Malaysia had a different dynamic, some could be walked, others had public transportation and others required private transportation, for example. Nevertheless, an average day could go on these lines: stay at a budget hotel, get breakfast at a nearby restaurant or hotel, grab some snacks for the day, visit attractions (transportation would depend on city, some required tours), have lunch (a lot of cheap options), visit other attractions, have dinner (2-3 meals a day usually) and go back to hotel.

Saving tips:
Food is overall cheap. Even at the KLCC in Kuala Lumpur, you can get a nice meal for 3$. Stay close to attractions and avoid tours.

Average Exchange Rate: 1 USD ~ 3.75 MYR.

Average Daily Cost (USD): $38.



Singapore


Singapore Daily Expenses By Category
Typical Day:
Stay at budget hotel, have self-made breakfast and dinner in room, grab snacks for the day, visit some attractions (like Marina Bay Sands, or temples, but not attractions on Sentosa Island), have lunch at a chain restaurant, watch budget/free night attractions, go back to hotel.

Saving tips:
As Japan, Singapore is a bit expensive. We were able to lower down some costs on accommodation by mixing it with transportation days (arrived one day early in the morning, and the last day left for a night train to Kuala Lumpur).

Budget hotels are not very comfortables and are expensive. Check for hostels that have good reviews.

Average Exchange Rate: 1 USD ~ 1.33 SGD.

Average Daily Cost (USD): $41.



Thailand


Thailand Daily Expenses By Category
Typical Day:

Stay at budget hotel, have breakfast (sometimes self-made, sometimes restaurant), get to attractions (most of the time through tours, but walking and public transportation when possible), have lunch/dinner at a budget restaurant (if tour, most of the time lunch was included, usually had 2-3 meals a day), had snacks, occasional party/night show/gathering, back to hotel.

Saving tips:
On the islands (like Koh Phangan), if you rent a bike instead of paying private transportation, you might be able to save more money. Also, if you just stay on the beach, the expenses go down, but usually would like to go diving, or getting to other islands. In Bangkok, you usually have good public transportation.

The most important advice: Always take metered taxis! If by any reason you can't find one and really need it, negotiate the price upfront or have one trusted driver. These people really get a lot of money from tourists.

Average Exchange Rate: 1 USD ~ 33 BAHT

Average Daily Cost (USD): $44.



Vietnam


Vietnam Daily Expenses By Category
Typical Day: 

Stay at a budget hotel, have breakfast in restaurant, grab snacks for the day, walk or get on a tour to attractions, visit attractions, have lunch/dinner at a budget restaurant (2 meals a day usually, sometimes 3), go back to hotel or transportation to next city.

Saving tips:
You can rent bikes instead of paying for private transportation. Beware of the laws. Beside of that we don't have much advice.

Average Exchange Rate: 1 USD ~ 20,500 VND

Average Daily Cost (USD): $ 32



Asia Backpacking English Travel

Saturday, December 12, 2015

Study Guides for your Next Technical Interview

I get commissions for purchases made through some links in this post. The recommendations are my own, and are not sponsored (*).

Over the last couple of years, I have been creating some Interview Study Guides that have helped both improve my coding/technical skills and prepare for interviews in top tech companies. Since I believe these guides might be useful for others I have decided to publish them.

All the guides are free and released under CC-Attribution-ShareAlike License.

All the guides are a work in progress and open for improvements. You can download all the guides from here.

NEW: if you prefer video over text, then don't miss my Youtube Playlist "Before the technical interview" where I cover all the topics presented on these guides (and many others).






Below is a brief summary of each of the guides.



Computer Science Fundamentals


As the name implies, this guide provides a summary of Computer Science Fundamentals, including:
  • Data Structures
  • Algorithms
  • Complexity Analysis
  • Mathematics and Probability
  • Regular Expressions
  • Threads and Locks
The sources range from online resources like Wikipedia, GeeksForGeeks and StackOverflow to formal books including (*):

I find it useful to quickly review different algorithms and as cheatsheet for different CS courses, and most of the interviews at Google, Facebook, LinkedIn, Amazon, and other big tech companies, will make a big emphasis on these topics.

You can download this guide clicking here.

This guide will help you have the concept to solve typical problems like Finding the largest BST in a tree.

Software Development and Architecture

This guide compiles higher level topics like:
  • Object Oriented Design
  • Service Oriented Architectures (SOAP and REST)
  • Scalability and Networking
  • Front End Development
    • How do browsers work
    • How to speed up websites
    • ...and more!
  • Frameworks (specifically Spring)
  • Databases
This guide is a bit less polished than CS Fundamentals, but also includes a wide range of sources from different websites and books including (*):

You can download this guide clicking here.

Code Snippets

This guide is the shortest. It includes short descriptions and code snippets from programming languages I have had some experience with (even if only during a course in college). The code snippets are commented with syntax explanation. The languages in the guide include:
  • Ruby
  • Javascript
  • PHP
  • Prolog
  • Haskell
  • C/C++
You can download this guide clicking here.

Additional Resources

There are a lot of free resources on the Internet you can learn from:




Disclaimer

I (Christian Vielma) have personally created these guides for personal use, to be used as a reference for technical interviews, work, and study. Since I believe these documents might provide value to others, I have decided to make them public.

Most of the contents on these documents have been added from different sources, from freely available resources on the Internet, to books, with additional added content from me. I made my best effort to provide full credit to the original sources, and in no way I'm trying to take advantage of improper quotations. If you believe I have made an invalid reference to a resource, please let me know and I'll fix it.
 

I provide these guides as-is, with no additional guarantees. I'm also releasing it under CC-Atribution-ShareAlike License, so you are free to extend it and update it with proper attribution.

Enjoy!


(*) Disclaimer 2:
As an Amazon Associate I earn from qualifying purchases. Links referring to Amazon are still books that I personally recommend (not sponsored) but I might receive money based on clicks  or purchases. There might also be some ads on the sides or between posts are those are placed by Google based on their recommendations (not endorsed by me).
Big-Oh Computer Science English Interviews Java Programming Study

Monday, April 27, 2015

Desmitificando a Venezuela: El porqué no PODEMOS permitir que se replique el modelo

España parece estar inmersa en una terrible crisis política y económica, y ante la posibilidad de tomar una decisión crucial para su futuro este año, que se asemejan en gran medida a lo que Venezuela ya ha vivido en la historia reciente, quería escribir mi experiencia de la manera más objetiva posible, para que no los tome desprevenidos.

En este artículo trataré de presentar qué ha pasado con Venezuela en los últimos años desde mi punto de vista (usando la mayor cantidad de fuentes oficiales que pueda), por qué España no debe seguir ese camino, y por qué estoy convencido de que siguiendo al partido de Pablo Iglesias, España sólo va a empeorar.

No existe tal cosa como el periodismo objetivo , y yo no soy ni siquiera periodista. Sin embargo, trataré de presentar el artículo con hechos objetivos como la base de mis argumentos.

España Español Podemos Política Politics Venezuela

Friday, September 20, 2013

Find Largest Binary Search Tree in a Tree: Java Solution

The question is simple and fair common:

Given a Binary Tree, write a function that returns the size of the largest subtree which is also a Binary Search Tree (BST). If the complete Binary Tree is BST, then return the size of whole tree. (From: GeeksForGeeks)

Additionally, I'll be returning the root node for the BST. In this case the BST would have to include all its children (i.e.: it must be a BST from a specific node to the leaves).

Algorithm


To find the largest BST in a tree there are different options to traverse the tree: we could take an top-down approach or a bottom-up.

Top-Down

The top-down approach require us to check at each node from the root if the tree starting at that node is a BST. This makes us traverse multiple times the tree to find the bst. Although it stops as soon as it find a BST because it will be the largest. This solution has a time complexity of O(n^2) in worst-case (degenerated tree into list) or O(nLogn) (balanced tree)
 where n is the number of nodes in the tree.

Bottom-Up

A better approach will be bottom-up where we check from the bottom of the tree the nodes to check if the trees created are BST. This makes the evaluation of a BST in O(1) for each node, although we still have to traverse the tree completely, so this approach has a time complexity of O(n) (in fact we have to traverse the tree twice because to get to the bottom nodes we must traverse from the root and then again from the bottom to the top).

Given the implementation is recursive, this has a space complexity of O(n). 

Implementation


Below is my Java proposed solution. For a complete solution (including testing, full comments and printing) check this.

If you are preparing for a tech interview, don't forget to check the Interview Study Guides.




Big-Oh English Java Programming

Tuesday, September 17, 2013

Tips and Solutions for Dell XPS 13 Developer Edition

The Dell XPS 13 Developer Edition comes with Ubuntu 12.04, and even though most of its hardware works perfectly with Ubuntu there are some things that doesn't quite work from the beginning (what a shame).

In this post I present some of the issues that I experienced with this powerful ultrabook and how I solved them.


Bluetooth


At the beginning I couldn't enable the bluetooth but after the first Ubuntu update it worked perfectly.

Additional Tip: if you want to send files from your phone to your computer you should do search and find "Personal File Sharing" in the dash and activate both the checkboxes under "Recieve Files over Bluetooth, as commented by Reza Ghayem in AskUbuntu.

WiFi


By default there are some issues with the stability of WiFi connections. If your WiFi connection is not stable (ie: disconnects and reconnects a lot) you should run the following in a Terminal:

sudo apt-get install linux-generic-lts-quantal

and reboot your computer after that as suggested by Dan Wood in this AskUbuntu post.

Hibernate


Warning: Some people have reported some problems (ruins installation) using this hibernate tip when the Home directory is encrypted. I haven't confirmed this, though.

Although in my case Suspend worked from the beginning, Hibernate didn't so just installing uswusp solves the issue:

sudo apt-get install uswsusp

There are additional instructions suggested here but they weren't necessary. After installing uswsusp you can try hibernating your computing executing in a terminal:

sudo s2disk

If it works then you just have to restart the computer (after waking it up) and check hibernate through the standard options in Ubuntu (right top button-->Hibernate).

And that's it! Just let me know if you have additional hacks needed for Dell XPS 13 Developer Edition or if you had any problem with any of these solutions!
Dell English Linux Tips Troubleshooting Ubuntu

Wednesday, August 28, 2013

How synchronized methods can be ignored

Here is a question:

If an object has a synchronized method A and a not synchronized method B, can both method be called by different threads?

And the answer is:

Only one thread can access synchronized method A at a time (unless there are two different objects and each thread calls method A on different objects). B can be accesed by many threads at any given time, even when A is executing.

At the beginning I was a bit confused about the second part, if that is so, then a class might not be protected against multithreading update if it has at least one non-synchronized method that modifies an instance variable used by a synchronized method. I was right!

Here's is the code to prove it:

If you run this code it will sometimes show final value as 0 and other times value as 1. So when designing a class that should be synchronized take under consideration which methods are you leaving free that can modify instance (or static) attributes.
English Java Multithreading

 

Copyright © Librethinking.
Designed by Templateism. Hosted on Blogger Platform.