Thoughts about React Native after working with it

react-native-800x450.png

I faced the following challenge in January:

  • Porting a complex webapp to native Android and iOS. The web-app to be ported is written in ReactJs+Redux. Besides most of its business logic is in a pure ES5 javascript library.

So in this situation, React Native (“RN” from now on) seemed like the way to go as we wanted to have a working prototype in a month and it should be maintained in both Android and iOS without extra resources.

Continue reading Thoughts about React Native after working with it

My AMD Hackintosh OpenCore triple boot in same disk notes

A few notes about the main points I learnt installing triple boot into my new PC:

  1. When picking the hardware components, search for success stories related to such components so that you make sure they’re compatible and someone has already prepared configuration you can work on instead of building the setup from zero. E.g Non APU Ryzen (without G) + Gigabyte X570 + Radeon RX580
  2. Be aware that if you want to use Hackintosh as your only OS, intel will be easier and better supported, e.g docker with hypervisor, Adobe suite… My idea is using Linux, leaving OSX option for Xcode and Windows10 for gaming and win-only software.
  3. OpenCore is currently the only option for AMD, do not lose time reading about clover. See this video as an intro, not enough to get into action but you’ll get a general idea: https://www.youtube.com/watch?v=l_QPLl81GrY
  4. You can lose data quite easily, e.g touching partitions, so make sure you backup if needed.
  5. Make sure you read this guide carefully, it’s more precise and updated than the video: https://dortania.github.io/OpenCore-Install-Guide/
  6. This guide is also quite interesting: https://github.com/alkalim/ryzen-catalina
  7. Once you’ve seen the video and read the guide you’ll be ready if you understand these topics: Boot USB, STDT, ACPI, KEXT, UEFI, config.plist, SMBIOS
  8. If you find someone who already succeeded with your same CPU + Motherboard (e.g lucky me!) it will be way more easier to setup, as you might avoid the pain of testing different kexts and configs) but you still need to make sure you understand what you’re doing (previous points). Otherwise your Mac install menu will appear in Russian and you’ll have to figure out why that happens and how to reset NVRAM.
  9. You need to installs OSs in this order: Windows, Linux, Mac (3 pendrives). Both Windows and Linux need to be running in UEFI mode, and once both are running like that, you’ll need to resize the UEFI partition to at least 200MB as it’s a Mac requirement. (EFI created by default by Windows is 100MB…)
  10. You also need a Gparted USB so that you can create the Mac partition with the free space that you left after installing Windows and Linux, you’ll use HPFS+ but in Mac install partitions tool you’ll need to enable journaling for it (File > Enable Journaling) and convert it to APFS. Otherwise it will complain about lack of “firmware partition” (UEFI) even though you had already prepared it.
  11. In the middle of the installation it will reboot without warning and restart going on the installation from the disk.
  12. If the latest Realtek kext does not work for you, e.g unable to configure NIC on installation, try with v2.2.2, it did the trick for me.
  13. Once successfully installed you typically need to do a few postinstall things:
    1. Just in case Windows update messes up with opencore boot loader make sure you install BootStrap.efi in BIOS. That way you’ll always have the “OpenCore” option in BIOS.
    2. You need to update the hard disk UEFI partition. If you prepare the USB BOOT MAC drive with gibmacos you might not have an EFI partition there, you just need to mount the EFI hard disk partition manually, delete its EFI folder and drop the one you have in the USB BOOT.
    3. If OpenCore is unable to detect Linux, make sure you installed it in UEFI mode, e.g in Linux mint picking the UEFI partition as boot partition.

Enjoy!

Other links:

https://github.com/ivmos/config/tree/master/ryzentosh

https://github.com/sergeycherepanov/homebrew-docker-virtualbox

Designing Data-Intensive Applications Book: Chapter 1 Summary

I start a series of blog posts with summaries about this interesting book: Designing Data-Intensive Applications

51gP9mXEqWL._SX379_BO1,204,203,200_.jpg

What is a data-intensive application?

It s an application where raw CPU power is rarely a limiting factor and the problems are the amount of data, the complexity of data, and the speed at which it changes. It is built from standard building blocks that provide commonly needed functionality.

In this chapter, we see the fundamentals of what we are trying to achieve.

Continue reading Designing Data-Intensive Applications Book: Chapter 1 Summary

Google Photos API, how to use it and why it will probably disappoint you

photos_96dp

 

Recently I needed to close a Google Apps account, and I tried to migrate albums programmatically.  I’ll document here the needed steps and explain why this Google API is useless for most of us:

First you need an app token, you can get it from Google Console on https://console.developers.google.com. There you need to register your project and associate API from the library.

You should now have both client_id and client_secret so you can fetch the code quite easily with a OAUTH2 flow:

#!/bin/sh

$client_id = "foo"
$client_secret= "bar"

scope="https://www.googleapis.com/auth/photoslibrary+https://www.googleapis.com/auth/photoslibrary.sharing"

url="https://accounts.google.com/o/oauth2/auth?client_id=$client_id&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=$scope&response_type=code"

echo $url

If you open such output URL with a browser you’ll get the $code and with such code, you can just fetch the tokens.

$code = "lol"
curl --request POST --data "code=$code&client_id=$client_id&client_secret=$client_secret&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code" https://accounts.google.com/o/oauth2/token

With the refresh_code you can already do what you need, here you have an example kotlin script I worked on https://gist.github.com/ivmos/860b5db0ffeeeba8ffd33adebfaaa094

But finally, I just did it manually zooming out from web client. It happens that Google just offers consents that allow you to manipulate photos and albums created with your own app, so you can’t move around photos between albums created by the official too. This means you cannot organize your library automatically unless you just need to work with photos you would upload with your own app…

 

 

My 2019 Coursera courses

2019 was an awesome year for me, mainly because I became father 🤗 but I also found time to keep my learning habit 🤓, something very important after 15 years since my first job in the field. So I’d like to list and elaborate on the Coursera courses I did and why:

  • Conflict Resolution Skills (cert): a good introduction, something essential even if you’re in an individual contributor position but critical in management.
  • Kotlin for Java developers (cert): a great course in order to jump from Java to Kotlin. We’ve been increasingly using Kotlin at work (even for microservices!) so I found it was a good way to review the language in general.
  • Programming Languages, Part A (cert): getting into functional programming was something I wanted to do for a long time, I did some Haskell at uni but that was ages ago and I knew typical few things used in JavaScript or Kotlin but using a pure FP language is a very different thing.
  • Programming Languages, Part B (cert): Part A used SML, this other part used Racket which was a bit parenthesis nightmare at first but it turned to be very fun as I practiced implementing a little programming language something I hadn’t done since university,

If you have a recommendation of any online course for 2020 please leave a comment 🙂

HOWTO see Google Calendar events in yearly view

245px-google_calendar

It turns out I already have booked a few events for 2019 so I wanted to have a yearly view of everything I have. I was disappointed to see that current Google Calendar yearly events view is useless as It’s just empty. There are lots of comments about this issue in this Google productforums entry.

Captura de pantalla 2019-01-12 a las 13.07.50.png
:S

Captura de pantalla 2019-01-12 a las 13.15.33.png
Ron Irrelavent is absolutely right

So I did some search to look for solutions and I found these 2:

  • Google Calendar Plus extension
    • I haven’t even tried as I’m tired of Chrome extensions but seems to work.
  • Visual-Planner project
    • A bit ugly but it works and it’s open-source so this is what I’m using. You can use it without installing it here (you just need to OAUTH to your gmail account). Only drawback is that it does not display names for multi-day events, as a workaround you can create a single event for the first day e.g “Flight to London”

Captura de pantalla 2019-01-12 a las 13.13.09.png
This is something ¯\_(ツ)_/¯

Let me know if you have better alternatives.

I also hope Google implements this..  Hello Google PMs? 🙂

A Tech Lead HOWTO

I’ve been working in a Tech Lead role position for something more than 2.5 years. Some notes I can write here that would have been useful for me and hopefully for someone reaching this page:

  1. Read this HN question comments: https://news.ycombinator.com/item?id=10395046
  2. Create a roadmap, parallel to the team projects. Make sure you have a long-term plan in mind.Having-a-Social-Media-Game-Plan-Higher-Profits.jpg
  3. Your team needs to fulfill the projects maintaining a good working environment, otherwise, they’ll burn out soon. The opposite is true too, it does matter having the happiest team if projects don’t evolve as they should.Happy_minions.jpg
  4. Be patient, start just with little improvements as you understand your area. Avoid revolution feeling, people don’t like too many changes at the same time.
  5. Coding is probably not the most important thing you’ll do for your team. First months it will feel awkward but you’ll get used to it once you understand your responsibilities.
  6. Understand your area top-down, from architecture to code so you’ll probably won’t be an expert in every repo but you probably should be an expert of how everything glues together, how the architecture works and how it should evolve.
  7. 1:1s are one of the most important things you’ll do, make sure most of the 1:1 time is just informal, the projects sync part should be just the first 5 minutes. Try fixing calendar events for them.1-1s.png
  8. Overcommunicate: tell important things to the team as a group and repeat it again in each 1:1 and see if your message is being understood. Always ask for the opinion, especially in 1:1s, your mates will often help you to do things better.
  9. Be data driven, make sure you can see the state of everything with data, you should not need to do ad-hoc queries or launching dirty scripts to gather important health data. Your important telemetrics and KPIs should always be available to be reviewed. However, if you find yourself checking a metric a lot for certain thresholds, just create an alarm!Data-driven-business.jpg
  10. You’ll need to keep caring about your craftsmanship and it will be more difficult than ever as you won’t be coding most of the day. However, you should make sure you keep improving technically, not just growing in soft skills. Try maintaining pet-projects, courses and try to contribute to team code in small priority tasks from time to time.
  11. Be involved in code reviews and read every pull request if possible, that’s where you’ll feel how good work is evolving. However, avoid micro-manage, especially to senior mates, just be a helpful safety net if needed. Avoid commenting in CRs if you have nothing important to say, avoid the “here comes the boss comment” syndrome.03
  12. Detect any block and tackle it with most urgency. It’s one of your main responsibilities. Ask for blocks in every standup.
  13. Be the tech proxy for your team so that they can focus on their tasks. Be ready to be interrupted, learn how to optimize context changes. Actually, make sure your team understands you’re approachable and they can ping you if any problem without waiting, you’re there to be interrupted at any time if needed.
  14. Supervise estimations. Avoid being always dummy conservative, think carefully about risks and if any high risk then yes, be conservative with estimation. But if you’re estimating a task your team already did in the past, it should be pretty straightforward (and perhaps should be automated?)
  15. Try introducing and welcome changes to how things are done but be careful about when those changes are applied as if they impact a project, it can be difficult to justify. Related to this, avoid taking the easy route of just saying always “NO” to new things just to avoid risks, as your platform should evolve as part of your plan.main-qimg-fbef4b8b75dbb14bf216652c98ef2232
  16. Measure technical debt, buy it consciously and fight it as part of your plan with priorities.
  17. Improve your soft skills. You’ll be more time talking to people than to your IDE.
  18. Be always constructive with feedback, as a criticism without action points to follow is not a solution.
  19. Be the Toxic-comments goalkeeper. Try favoring a positive environment. However, don’t confuse toxic comment with a constructive critic.24293_1.jpg
  20. Tech Lead position is quite prone to workaholism. Go home! Read this post by Rafael López: https://badoo.com/techblog/blog/2017/04/11/leads-go-home-and-take-your-reports-with-you/

 

Good luck!

About Learning How to Learn course

I’ve just finished the Learning How to Learn course and I wanted to summarize some key ideas for myself and also encourage any reader to follow the course. If you’re a successful learner lots of the ideas will be familiar to you, no Coca-Cola formula disclosed but I think it will be valuable for you listening to them in a more elaborated way and you might also learn some new things. I really enjoyed this course.

  • Focused versus diffused mode of thinking.

You’ll learn how you need to work both modes of thinking, both are important and key for success.

If you just try to learn in the focused mode you might have trouble trying to work creative ideas, link ideas to others that would seem unrelated at first and creativity in general.

When you’re in the focused mode it’s like distractions do not exist, all your CPU is dedicated to a single task, it let us focus on the information we’re working on being very efficient processing it and memorizing what we need. However, often you need to see a bigger picture as big as you might need, you start focused on a problem that seems to have no solution and you leave your mind fly and start touching related ideas, like zooming out from the problem, that’s when sometimes “magic” happens and you understand something relevant to the problem that you weren’t able to see just being focused on the problem. This is the diffused mode.

This is what happens when you manage to find a solution to a problem after having a walk, after sleeping, while you’re moving your chair around instead of keep staring at the code… I’ve seen this often in cases where you are trying to fix a bug and you’re in that moment where you think “This cannot be happening, it’s impossible”. Then is when you go to the kitchen or start looking at the sky or go home and keep thinking about the problem at the gym, and at some point, you realize that there’s something you had missed that could actually be the problem and it is!! I think this is also related to the rubber duck debugging as it lets you change to diffuse mode thinking while you explain the problem to a mate.

More about focused vs diffuse mode.

  • Procrastination.

This a topic I’ve been interested in for some time. Some ideas I already knew are explained like trying to start with tasks you don’t like first so that you get an “energy boost”, trying to focus on process instead of product so that you enjoy with the routines and avoid thinking too much about long-term goal and trying techniques like Pomodoro.

It explains a nice analogy, saying that you do lots of things in zombie mode, and you usually don’t feel procrastinate doing them, you feel that you need to procrastinate when you know that you need some effort, even if it’s a task about something you want. Thinking about the product enforces procrastination. The good news as it’s said in the course is that once you start, the “pain” stops and you can try things like pomodoro in order to advance.

ahh-procrastination.jpg

  • Learning

It’s explained how important practice is, the importance of testing yourself (like in an exam) and how productive it is versus just relearning the material. Actually, it talks about the risk of over-learning that you can avoid testing yourself soon so that you know whether you’re already ok with the subjects. Related to that there is an interesting concept called Einstellung.

It also explains the “interleaving technique”, something I already knew but never applied too well but might try to do better in the future: it’s about learning a subject and reviewing it like exponentially in time so that your brain saves the information in the “hard disk” instead of just “RAM” (or even L2 cache). As I’ve said I’ve typically studied a subject for some time and moved on to another instead of keeping reviewing the learned subject before the current one.

The course also talks about the importance of memorizing and practicing, understanding is not enough, it’s like the eureka moment is good but you need the practice to be able to work with the concepts and having there in your mind long term.

It also explains that sleeping is very important so that your brain can organize what you’ve learned and you can be in good shape the next day. It explains that there are some metabolic processes that block you’re learning and you need rest in order to control them. It also explains how important it is recalling for learning. This is something that my father did great, I remember how he asked me each lesson and that was key for learning, it was not that when being asked or being tested you’re only checking whether you’ve learned, you’re actually learning at that moment and enforcing consolidating concepts in your brain.

The course also explains the concept of “chunking“: you study some concept or idea, you understand it, practice and link it to other concepts, like a part of the puzzle. You can memorize a concept but it will be useless, it will be a variable that is GC collected as it’s linked to nothing. Those chunks are formed from small pieces to form bigger ones, and your diffuse mode of thinking can try to find new relations among all of them. That’s what experience is about when you’ve been working on lots of projects in different areas and you see how all of them in some way guide you to new decisions in next projects.

There are other interesting concepts shown related to learning like the “illusion of competence”: when you think you’ve learned something but you’ve just read a lot about it but you haven’t really learned it. They also talke about a related concept that is well known in our profession: The Impostor Syndrome.

It also mentions that some techniques like highlighting text can be worse than just writing some personal notes on the side of the book and writing a map of the ideas. E.g in you’re listening, instead of starting from the top of the paper, just start from the middle, write some ideas, link them…

Finally, it also mentions the importance of metaphors and how you replace some metaphors by better ones.

Practice, practice and practice:

hannanohands

  • Memorization

In a world where all the information is on your smartphone, do we really need to memorize things or we just need to understand?

It happens you can’t learn without some level of memorization, and It has been studied that being able to memorize important things is also positive for creativity. It’s also related to practice, you’ll memorize those things that are important as part of your practice. The course mentions some techniques to help memorizing like the Memory Palace , mnemonics, acronyms…

42be11b56059d244f573bac445e722aa-1-e1475984414241

  • Tips for tests

It also explains some tips for tests. Apart from encouraging good sleep before exams it promotes checking first all the questions to see the whole picture and starting from a difficult exercise but jumping to an easier one if you’re blocked after one minute. This practice surprised me as I think I’ve always started doing the easy ones and then going for the trickiest ones but their explanation made sense as that way your brain is already working on the difficult ones at the same time you’re working on the easy ones, just encouraging your diffuse mode I guess…

  • Some interesting resources

You can explore more about this course contents in this mindmap by Rodolfo Mondion who has also written about this course:

The course is also very good pointing to valuable resources, e.g:

 

 

 

 

 

 

Analyzing FastestWebsiteEver

Checking https://github.com/diracdeltas/FastestWebsiteEver was on my TODO list. Let’s see some details in Wireshark and review some TCP/IP details.

Captura de pantalla 2017-09-30 a las 3.19.38.png

You can check http://packet.city/ if you want to avoid setting up the service yourself.

So you open Wireshark and you start capturing. Visit http://packet.city and you can use a Wireshark filter for the resolved IP for packet.city.

Captura de pantalla 2017-09-30 a las 2.11.30.png

The project states that it is “the greatest website to ever fit in a single TCP packet”.

Is it true? Let’see what it needs: I can see 9 packets and some details.

First 3 packets (handshake)

Captura de pantalla 2017-09-30 a las 3.03.49.png

Like any normal TCP connection we start with a 3-way handshake:

  • First, my laptop sends a SYN packet with an Initial Sequence Number which can be seen 0 in Wireshark but that’s actually a relative over a random. This is my laptop requesting proof that its message can get through.

Captura de pantalla 2017-09-30 a las 2.28.14.png

  • The server needs to send an ACK packet (to prove SYN received) and its own SYN (to prove it can reach the client). We can see it’s actually done in the same sent packet: SYN-ACK

Captura de pantalla 2017-09-30 a las 2.30.49.png

  • My laptop receives the SYN-ACK: as its an ACK it knows it can send a packet to the server and as its a SYN it knows that the server needs an ACK, so it sends such ACK.

Captura de pantalla 2017-09-30 a las 2.35.54

  • Once the server receives that ACK handshake has finished and the channel is considered feasible. However it might have been like, but this is the minimum to start trying to communicate.

Packet #4 (GET)

We’ve finished with the 3 first packets. The fourth one is the GET request.

Captura de pantalla 2017-09-30 a las 2.41.10

Captura de pantalla 2017-09-30 a las 2.48.50.png

Notice that Push flag is enabled (PSH) and also ACK as with any exchanged packet during the communication.

In HyperText Transport Protocol we can see the sent HTTP request:

Captura de pantalla 2017-09-30 a las 2.52.48

#5 and #6 packets

Captura de pantalla 2017-09-30 a las 3.04.41.png

Packet #5 is an ACK:

Captura de pantalla 2017-09-30 a las 3.00.10

Next packet is the HTTP GET response:

Captura de pantalla 2017-09-30 a las 3.02.55.png

I guess this is what the project describes as “send response immediately after TCP session init”

I think PSH is enabled because Nagle’s algorithm is disabled as the project describes too.

In Hypertext Transfer Protocol section we can see DEFLATE compression is being used, again exactly as described in README.

Captura de pantalla 2017-09-30 a las 3.13.12.png

See that Response is “200 k” instead of “200 OK”: 1 byte saved there.

Content encoded is 1163 bytes (1547 bytes decoded), far from needing fragmentation:

The maximum would be 1460 bytes for content and 40 bytes for IP and TCP headers.

In this case, the frame is 1292 bytes, TCP segment length is 1226 bytes and HTTP Content-Length is 1163 bytes, in detail:

ethernet_frame

  • Frame header (14 bytes): 7 bytes for preamble, 1 byte for SFD, 12 bytes for source and destination MACs and 2 bytes for packet type (IP) –> 22 bytes (14 ignoring preamble and SFD)

Captura de pantalla 2017-09-30 a las 9.49.08.png

  • IP header (20 bytes): 1 byte for ip.version (4), 1 byte for ip.dsfield, 2 bytes for ip.len (Length), 2 bytes for ip.id (ID), 1 byte for ip.flags (0x02, ip.flags.df (Don’t Fragment  )is set), 2 bytes for ip.frag_offset (Fragment Offset), 1 byte for ip.ttl (TTL), 1 byte for ip.proto (Protocol), 2 bytes for ip.checksum (Header checksum) and 8 bytes for ip.src and ip.dst.

TCP-Header.png

  • TCP header (32 bytes): 4 bytes for tcp.srcport and tcp.dstport, 4 bytes for tcp.seq (Sequence Number), 4 bytes for tcp.ack (Ack Number), 2 bytes for tcp.flags, 2 bytes for tcp.window_size_value, 2 bytes for tcp.checksum, 2 bytes for tcp.urgent_pointer, 12 bytes for tcp.options

Captura de pantalla 2017-09-30 a las 10.17.44.png

  • HTTP (1226 bytes): 15 bytes for “HTTP/1.1 200 k\n”, 21 bytes for http.content_length_header, 26 bytes for http.content_encoding_header, 1 byte of “\n” and 1163 bytes for Content (encoded)

About the HTTP response content, it’s easier seeing the source code in the browser, there you’ll see:

Captura de pantalla 2017-09-30 a las 3.16.04.png

 

Last 3 packets

Finally last 3 packets. Server resets the connection with RST packet. I guess they could use FIN but RST is quicker. More about FIN vs RST.

Captura de pantalla 2017-09-30 a las 3.21.41.png

That’s all 🙂