I was contributing already but since the 2th of May I started my radio space, also streamed in Twitch, google Podcast, Apple, Spotify… in Radio America Barcelona.
My space is named The New Digital World (“el nou món digital”) and I talk about tech news, technology, videogames and handy tricks.
This content is in Catalan language only, so I added to the blog as ending in [CA]
New Projects: Erasure Code
For my university thesis I’ve been creating an Erasure Coding solution that allows to encode and distribute the files seamlessly across an universe of Servers in different cloud providers, balancing the disk space used, super easy to use, and resilient to disaster and recovery.
I created my project, named Erasure Code www.erasurecode.com as Open Source, so all size of companies will be able to benefit from this technology, only available to multinationals until now.
I hope this will help tons of companies and startup, hopefully scientific startups, to save costs and focus more in their business and to make a better world.
Explanations about redefining reserved keywords like print or exit as a variable.
Style modification to add lines over the line number and over the Footnote.
My health
My health is improving.
Thanks to my self discipline, following a good diet, taking the medicines… I’ve seen an spectacular improvement since I was sent urgently to he hospital with risk for my life.
I’ve very grateful that amazing doctors care of me.
I had some ups and downs and downs while pushing to finish my final project for the HDip in Computer Science Cloud Computing, but I managed to complete everything on time.
I had to travel to visit amazing specialists, and had to pay the expensive treatments, however everything worked and my health has improved drastically. I am very happy to count with additional source of income, like the teaching programming and my technical books, which helped me to be able to deal with all these sorts of unexpected expenses. I appreciate every single sale of my books, as it made me feel useful and appreciated when I was a bit low, and the nice details some of the readers had. Thanks.
Firewall
I’ve keep blocking in the Firewall any IP and that network coming to the blog from Russia and Belarus. I’ve blocked millions of IP Addresses so far.
I’ve also blocked the traffic coming from CSP when I detect an attack and the IP belongs to them. Most of the attacks were coming from Digital Ocean, after your-server.de and hetzer.de and finally Amazon. Curiously some attacks came from IPs from Microsoft.
I’ve blocked all these ranges of IPs, hundreds of thousands.
Despite blocking all these IPs from CSPs, the number of visitors keeps growing.
At the end my blog is for Engineers and for people, I don’t have interest in bots, and I don’t get any revenue from ads (I never added ads) so I’m perfectly happy with having less visitors, but being humans that find help in the blog.
Recently a colleague was asking me for advice on their design of error handling in a Python application.
They were catching an error and raising an Exception, inside the except part of a method, to be catch outside the method.
And at some point a simple logic got really messy and unnecessarily complicated. Also troubleshooting and debugging an error was painful because they were only getting a Custom Exception and not context.
I explained to my colleague that I believed that the person that created that Exception chain of catch came from Java background and why I think they choose that path, and why I think in Python it’s a bad idea.
In Java, functions and methods can only return one object.
I programmed a lot in Java in my career, and it was a pain having to create value objects, and having to create all kind of objects for the return. Is it a good thing that types are strongly verified by the language? Yes. It worked? Yes. It made me invest much more time than necessary? Also yes.
Having the possibility to return only one object makes it mandatory having a way to return when there was an error. Otherwise you would need to encapsulate an error code and error description fields in each object, which is contrary to the nature of the object.
For example, a class Persona. Doesn’t make any sense having an attribute inside the class Persona to register if an operation related to this object went wrong.
For example, if we are in a class Spaceship that has a method GetPersonaInCommand() and there is a problem in that method, doesn’t make any sense to return an empty Persona object with attributes idError, errorDescription. Probably the Constructor or Persona will require at least a name or Id to build the object…. so in this case, makes sense that the method raises an Exception so the calling code catches it and knows that something went wrong or when there is no data to return.
This will force to write Custom Exceptions, but it’s a solution.
Another solution is creating a generic response object which could be an Object with these attributes:
idError
errorDescription
an Object which is the response, in our example Persona or null
I created this kind of approach for my Cassandra libraries to easily work with Cassandra from Java and from PHP, and for Cassandra Universal Driver (a http/s gateway created in year 2014).
Why this in not necessary in Python
Python allows you to return multiple values, so I encourage you tor return a boolean for indicating the success of the operation, and the object/value you’re interested.
You can see it easily if you take a look to FileUtils class from my OpenSource libraries carleslibs.
The method get_file_size_in_bytes(self, s_file) for example:
def get_file_size_in_bytes(self, s_file):
b_success = False
i_file_size = 0
try:
# This will help with Unit Testing by raisin IOError Exception
self.test_helper()
i_file_size = os.path.getsize(s_file)
b_success = True
except IOError:
b_success = False
return b_success, i_file_size
It will always return a boolean value to indicate success or failure of the operation and an integer for the size of the file.
The calling code will do something like this:
o_fileutils = FileUtils()
b_success, i_bytes = o_fileutils.get_file_size_in_bytes("profile.png")
if b_succes is False:
print("Error! The file does not exist or cannot be accessed!")
exit(1)
if i_bytes < 1024:
print("The profile picture should be at least 1KB")
exit(1)
print("Profile picture exists and is", i_bytes, " bytes in length!")
The fact that Python can return multiple variables makes super easy dealing with error handling without having to take the road of Custom Exceptions.
And it is Ok if you want to follow this path, but in my opinion, for most of the developers up to Senior levels, it only over complicates the logic of your code and the amount of try/excepts you have to have everywhere.
If you use PHP you can mix different types in an Array, so you can always return an Array with a boolean, or an i_id_error, and your object or data of whatever type it’s.
Getting back to my carleslibs Open Source package, it is super easy to Unit Test these methods.
In my opinion, this level of simplicity, brings only advantages. Including Software Development speed, which is good for the business.
I’m not advocating for not using Custom Exceptions or to not develop a Exceptions Raising strategy if you need it and you know what you’re doing. I’m just suggesting why I think most of the developments in Python do not really need this and only over complicates the development. There are situations where raising exceptions will be a perfectly useful or even the best approach, there are many scenarios, but I think that in most of cases, using raise inside except will only multiply the time of the development and slow down the speed of bringing new features to the business, over complicating Unit Test as well, and be a real pain for the Junior and Intermediate developers.
The Constructor
Obviously, as the Constructor doesn’t return any value, it is perfectly fine to raise an exception in there, or just to use try/except in the code that is instancing the objects.
This is a document previous to a live code review session.
It has the information to prepare for the upcoming code review session, where I plan to share the lessons learned, decision I took, mistakes I did, refactors I had to overcome, and tentatively we will refactor code in order to add some Unit Testing.
History
I used to play sudoku with my family, so from time to time I do by myself.
Once I found a sudoku that was impossible and it happened that it was a typo from the newspaper, so, when I found another impossible sudoku I wanted to know if it was me, or if there was a typo or similar, so I decided to write a Sudoku Solver that will solve the sudoku for me.
Tomorrow 23th of April is Sant Jordi (Saint George), the patron of Catalonia, and the Catalan traditional celebration consist in this day women gifting a book to the men they love and men gifting a rose to the women they love.
I created a voucher for all my Python books, so, since during 23th of April you can acquire the four books per $10 USD in total.
I also started to block entire ranges of Ip’s from Digital Ocean, as many attacks come from Servers in their infrastructure.
Despite blocking tens of thousands of Ip Addresses, the number of visitors keep growing.
My Health
Thanks to my strict discipline I managed to recover super well and I’m healthier than before and guided by the satisfied doctors we removed two daily medicines.
I started a new medicine that is for the final phase of my recuperation, which doctors expect to be completely. In fact I’m much more healthier than I was before going to the hospital.
Humor
Will AI take the world?Sadly, true history. The responsibility to deliver is from all of us.
So, I was working on a project and i wanted to test how long a file can be.
The resources I checked, and also the Kernel and C source I reviewed, were pointing that effectively the limit is 255 characters.
But I had one doubt… given that Python 3 String are UTF-8, and that Linux encode by default is UTF-8, will I be able to use 255 characters length, or this will be reduced as the Strings will be encoded as UTF-8 or Unicode?.
So I did a small Proof of Concept.
For the filenames I grabbed a fragment of the translation to English of the book epic book “Tirant lo Blanc” (The White Knight), one of the first books written in Catalan language and the first chivalry novel known in the world. You can download it for free it in:
from carleslibs.fileutils import FileUtils
from colorama import Fore, Back, Style , init
class ColorUtils:
def __init__(self):
# For Colorama on Windows
init()
def print_error(self, s_text, s_end="\n"):
"""
Prints errors in Red.
:param s_text:
:return:
"""
print(Fore.RED + s_text)
print(Style.RESET_ALL, end=s_end)
def print_success(self, s_text, s_end="\n"):
"""
Prints errors in Green.
:param s_text:
:return:
"""
print(Fore.GREEN + s_text)
print(Style.RESET_ALL, end=s_end)
def print_label(self, s_text, s_end="\n"):
"""
Prints a label and not the end line
:param s_text:
:return:
"""
print(Fore.BLUE + s_text, end="")
print(Style.RESET_ALL, end=s_end)
def return_text_blue(self, s_text):
"""
Restuns a Text
:param s_text:
:return: String
"""
s_text_return = Fore.BLUE + s_text + Style.RESET_ALL
return s_text_return
if __name__ == "__main__":
o_color = ColorUtils()
o_file = FileUtils()
s_text = "In the fertile, rich and lovely island of England there lived a most valiant knight, noble by his lineage and much more for his "
s_text += "courage. In his great wisdom and ingenuity he had served the profession of chivalry for many years and with a great deal of honor, "
s_text += "and his fame was widely known throughout the world. His name was Count William of Warwick. This was a very strong knight "
s_text += "who, in his virile youth, had practiced the use of arms, following wars on sea as well as land, and he had brought many "
s_text += "battles to a successful conclusion."
o_color.print_label("Erasure Code project by Carles Mateo")
print()
print("Task 237 - Proof of Concep of Long File Names, encoded is ASCii, in Linux ext3 and ext4 Filesystems")
print()
print("Using as a sample a text based on the translation of Tirant Lo Blanc")
print("Sample text used:")
print("-"*30)
print(s_text)
print("-" * 30)
print()
print("This test uses the OpenSource libraries from Carles Mateo carleslibs")
print()
print("Initiating tests")
print("================")
s_dir = "task237_tests"
if o_file.folder_exists(s_dir) is True:
o_color.print_success("Directory " + s_dir + " already existed, skipping creation")
else:
b_success = o_file.create_folder(s_dir)
if b_success is True:
o_color.print_success("Directory " + s_dir + " created successfully")
else:
o_color.print_error("Directory " + s_dir + " creation failed")
exit(1)
for i_length in range(200, 512, 1):
s_filename = s_dir + "/" + s_text[0:i_length]
b_success = o_file.write(s_file=s_filename, s_text=s_text)
s_output = "Writing file length: "
print(s_output, end="")
o_color.print_label(str(i_length).rjust(3), s_end="")
print(" file name: ", end="")
o_color.print_label(s_filename, s_end="")
print(": ", end="")
if b_success is False:
o_color.print_error("failed", s_end="\n")
exit(0)
else:
o_color.print_success("success", s_end="\n")
# Note: up to 255 work, 256 fails
I tried this in an Ubuntu Virtual Box VM.
As part of my tests I tried to add a non typical character in English, ASCii >127, like Ç.
When I use ASCii character < 128 (0 to 127) for the filenames in ext3/ext4 and in a ZFS Pool, I can use 255 positions. But when I add characters that are not typical, like the Catalan ç Ç or accents Àí the space available is reduced, suggesting the characters are being encoded:
Ç has value 128 in the ASCii table and ç 135.
I used my Open Source carleslibs and the package colorama.
These are used for increasing your stats or weapons stats.
When you die you’ll lose the runes.
You can recover them if you go to the place where you died. You’ll see them shining on the floor. The place you died is marked on the map.
You’ll not lose things like the map, flowers you picked, etc…
You don’t lose your stats.
Horseback mount
After you get the Spectral Steed Whistle bind it to your belt through the inventory or pouch. It looks like a golden ring.
Then you’ll be able to summit it by selecting it (keypad down changes the item selected from the belt) and pressing X.
If you jump over some special spinning wind zones you’ll fly to very high distances.
You can run/sprint!
That’s something I didn’t see in the controls and I was being killed many many times, so I figured it out there has to be a way to sprint.
You can run by pressing the dodge button, B in XBox. Press B and hold it and move to any direction.
You can also use it when you are mounting Torrent, your horse.
Rolling dodges some attacks
Some attacks are avoided by rolling.
Mentioned by my friend Cian O’Brien.
Weight
You can have many items with you, but when you equip them the weight is important.
If you equip too much you’ll be unable jump or roll.
You can have several weapons with you and just equip what you need at each moment (before engaging combat).
Golden runes
You’ll find golden runes that will be kept in your inventory. They are consumables and you can use them to get instant amount of fragments.
Summon Ashes spirits
You’ll find spirits that you can summon in points of interest and to fight bosses.
Flasks
You can balance the number of flasks you have, and increase the number of them by using golden seeds at the sites of grace and the amount of life they replenish if you have the sacred tears.
Sort Chest
At the sites of grace you can sort your chest, and move things from your inventory to the chest and vice versa.
That’s ideal for reducing the items you carry until the appropriate moment to sell the goods.
Chests protected by soldiers in cars
You will find some cars protected by soldiers or big monsters.
It took me many time to realize that in the back of them they have a chest.
Jump and open the chest. Good weapons will become handy at an early stage.
Use the shield
Pressing LB if you have the shield on the left hand will raise the shield and keep it lifted.
This will protect you from incoming attacks.
I killed many enemies and bosses without using the shield, and it was a bit of a pain.
Sekiro style, dying and dying. Raising the shield I was able to beat impossible-to-beat-before bosses easily.
Head Skull
There are head skulls in the map, with bright eyes.
If you crack them hitting with your weapon, you’ll get a golden rune.
You can sell the golden runes to merchants or use them at any time and you’ll get runes. You may have a treasure enough to level up and you may not known.
You don’t loss the golden runes when you die.
Cycling items in your bag
You can bind several items to your back and cycle them pressing the down key on the pad.
If you bind the healing potion to the first slot in your bag if you hold down the cycle key it will always go back to the first item (thanks Cian!)
My friend Michela says: Carles I suggest if i may put the ring in backup pouch because if you map on the menu where healing potions are you risk to call the horse when u wanna heal
If you press and hold Y you’ll see the actions that you have mapped in the pouch. So, it’s also a quick way to access these.
Eliminating groups
Will restore a flask, so you will be able to use another crimson tears. This is capped to your max number of flasks.
Torch
You can buy a torch and use it. Useful for caves and dark places. Equip it as a weapon and just select it.
Traveling to the Round Table
When the requirements are met and you travel to the round table, you can go back by opening the map and zooming out. You’ll see then the round table.
Craft bombs
You can craft bombs if you have recipients to hold them.
Bombs are very useful against some bosses.
In order to craft you’ll need to buy a crafting kit.
Medallions
Michela also recommends: Bosses use to drop medallions. You can equip them in the medallion/s slot.
Use Magic
Once you have a spell you can go to a site of grace and select Memorize Spell.
Then with the up path you can switch.
You need to have a casting tool in any hand and press the attack button for that hand in order to perform the sorcery.
I found my first staff in the Sellia Crystal cave, after killing several of these digging blue crystal enemeies, which is a zone where you travel after you open a chest in a cave in Dragon-Buirnt ruins which you access going down stairs in the runes that have the zombies, where the big dragon is. It’s the Digger’s staff.
The centipedes in that area are very hard but I found them very vulnerable to fire bombs that you can craft and to throwing curved knives that you can buy in merchants.
After you defeat a boss in a cave next to a gigantic plant, you can become Sorceress Sellen’s protegee and she will teach you magic (she sell scrolls).
You can give her the academy scroll, IDK if this is good or bad.
Show glinstone projectiles without aiming
You don’t need to have the focus over an enemy. If you’re looking at the right direction you can just shoot using your staff, and the projectile will go to the enemy automatically.
Use Incantations
You can use incantations, that are another type of spell.
For doing incantations you need a Sacred Seal.
You can buy one in the two commerce women in the round table.
I discovered this after 82 hours of gameplay.
The incantations are based of faith.
Kick stairs
Like in Sekiro Shadows die Twice, after you get to certain parts you will be able to kick a stair so you’ll not need to do all the round to get to a boss.
Try different weapons
Different weapons have different behavior that you may find very convenient.
I recommend you to try different of them.
Some shields parry, which means that if you press the LT action button in the precise moment an enemy attacks, they will become vulnerable for a moment. You can then perform a critical with RB.
Great Runes
When you defeat one of the mega bosses, the demi gods, you will get a great rune.
You can use the great runes after restoring their power (only once) in a tower.
Then you equip a great rune in a site of grace.
They grant some buffs, but to get the most of them you have to use a Rune Arc.
These are dropped by rats and big rats.
Using a Rune Arc when having a Great Rune active gives you buff, like increased stats, until you die. Then you need another Arc.
I used an Arc for the first time when I was level 77.
Hashes of war can be duplicated
The hashes of war give special effects to the weapons. To be honest I have been afraid of using it and ruining a good weapon effect, or losing the ash.
But Ashes of war can be duplicated if you have the proper ingredient, in the smith in the Round Table.
I found the first nomadic merchant selling one of these ingredients just after South Raya Lucaria Gate, coming back after traversing the seal, from Main Academy Gate, just walking through the seal, without examining it, and after killing some packs of wolves.
I found this at level 77…
After 120 hours played I was level 83.
After 150 hours played I was level 111 and I had not yet used a single Ash of war.
Some attacks can be charged
Some attacks, like Loretta’s great arrow, can be charged by holding the fire button.
When it’s fired at its max charge level, it will deal more damage for the same FP cost.
Don’t roll over poison
In some caves you’ll find poison or rott on the floor. Don’t roll over trying to advance faster. That will cover your clothes with the poison and the disease will continue after you leave the infected zone. Just run or walk.
Plants in the caves allow you to level up the spirit ashes
The plants that are in the caves, allow to level up the spirit ashes.
I created this little video to show how to use the Web Developer Tools to check if jQuery AJAX request is being made.
This is to help beginners in their journey learning to program Front End.
Please be aware that the page I used makes their own calls for marketing purposes. I cleared several times the history to show what is the real AJAX request we are doing.
Note: The recording program did not capture correctly the mouse position and this video has no sound.
Normally you can try your HTML and JavaScript from your browser, opening the HTML file. However there are Security restrictions when it applies to AJAX requests or trying to access a local file from the browser.
You’ll need to run your JavaScript from an HTML page server from a Web Server. You can install apache if you use Linux, or WAMP if you use Windows or MAMP (Mac Apache MySQL PHP) if you use Mac or if you know how to you can create a Docker Container.
When you’re programming and your code does not trigger, pay attention to errors:
I’m Catalan. In 1936 the fascist military leaded by franco raised in arms against the elected government of the Spanish Republic. The Italian and nazi German fascist in power bombed the Catalan population. Hundreds of thousands of innocent citizens were assassinated and millions of Catalan and Spaniards had to exile. The sons of those that were ruling with the dictator have been insisting in naming it a “civil war”, but it was the military lead by a fascist, revolting against the legitimate Republic and ending a democracy.
The dictatorship lasted until 1975, when the dictator died in the bed. The effects of the repression never abandoned Catalonia, and nowadays in Catalonia people is still detained by the Spanish police for talking the Catalan language in front of them, and our Parliament decisions are cancelled by the Spanish courts, for example to force the exit of a President of Catalonia that they didn’t like, or to force the Catalan schools to teach 25% of the time in Spanish attacking the Catalan teaching system.
During WW2 millions of Jews were mass murdered, also people from all the nations were assassinated.
Russian population suffered a lot also fighting the nazis.
Now we have to see how Russia’s army is invading Ukraine and murdering innocent citizens.
That’s horrible.
I know Engineers from Ukraine. Those guys were doing great building wealthy based on knowledge and working well for companies across the world. Now these people are being killed or Engineers, amongst all the brave population, are arming themselves to fight the invasion. Shells destroy beautiful cities and population are starving, and young soldiers from both sides will never be seen again by their mothers.
Let music play in solidarity with Ukraine. First is a Catalan group. Second is a famous Irish band in this epic song dedicated to the brave International Brigades, volunteers that fought the fascism in Spain and in Catalonia trying to make a better world.
The Blog
I’ve updated the SSL Certificate. The previous one I bought was issued for two years, and I renewed as it was due to expire.
Honestly, my ego was flattered. It is a lot of reputation.
Although in the past I got an offer from another monstrously big editorial to publish world wide my book Python 3 Combat Guide and I also rejected, and an offer from a digital learning platform to create an interactive course from this same book.
I’ve rejected it again this time.
If you are curious, this is what I answered to them:
Hi XXXX,
I'm well, thank you. I hope you are doing well too.
Thanks for taking the time to explain your conditions to me.
I feel flattered by your editorial thinking about me. I respect your brand, as I mentioned, as I own several of your titles.
However, I have to refuse your offer.
Is not the first time an editor has offered to publish one or more of my books. For all over the world, with much higher economic expectations.
I'll tell you why I love being at LeanPub:
1- I own the rights. All of them.
2- I can publish updates, and my readers get them for free. As I add new materials, the value is maximized for my readers.
3- I get 80% of the royalties.
4- If a reader is not happy, they can return the book for 60 days.
5- I can create vouchers and give a discount to certain readers, or give for free to people that are poor and are trying to get a career in Engineering.
The community of readers are very honest, and I only got 2 returns. One of them I think was from an editorial that purchased the book, evaluated it, and they contacted me to publish it, and after I rejected they applied for the refund.
I teach classes, and I charge 125 EUR per hour. I can make much more by my side than the one time payment you offer. The compensation for the video seems really obsolete.
Also, I could be using Amazon self publishing, which also brings bigger margins than you.
So many thanks for your offer. I thought about it because of the reputation, but I already have a reputation. I've thousands of visits to my tech blog, and because of the higher royalties, even if I sell less books through LeanPub it is much more rewarding.
Thanks again and have a lovely day and rest of the week.
Best,
Carles
The provisioning in Amazon AWS through their SDK is a book I’m particularly proud, as it empowers the developers so much. And I provide source code so they can go from zero to hero, in a moment. Amazon should provide a project sample as I do, not difficult to follow documentation.
Teaching / Mentoring
As I was requested, I’ve been offering advice and having virtual coffees with some people that recently started their journey to become Software Engineers and wanted some guidance and advice.
It has been great seeing people putting passion and studying hard to make a better future for themselves and for their families.
I’ll probably add to the blog more contents for beginners, although it will continue being a blog dedicated to extreme IT, and to super cool Engineering skills and troubleshooting.
For my regular students I have a discord space where we can talk and they can meet new friends studying or working in Engineering.
Free Resources
This github link provides many free books in multiple languages:
Zoom can zoom the view. So if they are sharing their screen, and font is too small, you can give a relax to your eyes by using Zoom’s zoom feature. It is located in View.
My health
After being in the hospital in December 2021, with risk for my life, and after my incredible recuperation, I’ve got the good news that I don’t need anymore 2 of the 3 medicines I was taking in a daily basis. It looks well through a completely recovery thanks to my discipline, doing sport every day several times, and the fantastic Catalan doctors that are supporting me so well.
Since they found what was failing in me, and after the emergency treatments I started to sleep really well. All night. That’s a privilege that I didn’t have for long long time.
Humor
Sad but true history. How many super talented Engineers have been hired and then they were given a shitty laptop/workstation super slow? That happened to me when I was hired by Volkswagen IT: gedas. I was creating projects for very big companies and I calculated that I was wasting 2 hours of my time compiling. The computer did not had enough RAM and was using swap.