Posts

Redis smooth throttling

Image
This might be an edge case and not even complicated, but I thought I'd share it. So, I had this use case recently where I needed to throttle email send out speed, while allowing to control it on admin panel. However, the difference from the usual case was that you don't enter for example how many emails to allow per minute or second, but you enter over how long the hole process should be done. So, for example, send all ~1k emails over 1 hour. Luckily, laravel has redis throttling built in. We can utilize it like so: <?php Redis :: throttle ( 'key' ) -> allow ( 1000 ) -> every ( 3600 ) // 1 hour -> then ( function () { /* send */ }, function () { /* release */ }); But, here lies the problem. In this case it will send all that 1000 emails as fast as possible. It might take only a couple of minutes. If you have more than 1k emails, the queue will wait for the remaining time, do nothing, and then after 1 hour will send a bunch of

Surround yourself with smarter than you

Image
I want to express my thought a little bit on how important are the people you surround yourself with. If you ever took interest in growth and high performance or you are a high performer, you probably already new this. We also all heard of saying: tell me what your friends are, I'll tell you who you are. Yes, that is true. Now you can make two conclusions out of this: You should think of where you are in your life. If not, think of what people surround you. Are they where they want to be in their lives? Do they strive to become the best versions of them selves? Even if you are where you want to be or are working on that, the people around you are either pushing you towards greatness or holding you back. Use this to your advantage. Loose bad influence friends and find the ones who will teach you and inspire you. Now, I was talking about high performance and inspiration, but the title mentions smart people. Well, those who reach the hight in their lives are smart. From a

Fast PHPUnit tests

Image
Testing your software is an important process. If you don't test, then you're falling behind your colleagues and cause a potential danger to your and your company's reputation and money. So, if you haven't started already, start now. Don't worry, it only looks confusing at first, but once you get used to it, you won't imagine working without testing. Your end-goal is to feel uncomfortable if you push untested code. Nonetheless, this post is about how to make PHPUnit tests faster. Since I'm mainly a Laravel developer, I will focus on this framework. However, everything can be easily adapted to use on other frameworks as well. It is nothing new or revolutionary, but I still sometimes see people running tests the hard and slow way. So here are the things you can do to speed up your tests. Use SQLite Many still use MySQL database for their tests. This is might look fine with a few tests, but as your application grows running your tests becomes a very l

Taking Laravel certification exam

Image
So... I had recently taken a Laravel certification exam and would like to share my experience and maybe help you decide on taking it as well :) First of all, I would like to thank HELIS for giving me this opportunity. I remember when the news about this certification came out, our Laravel team decided to go for it and we spent a month or two preparing for it. Each weak we would gather in a meeting room for some presentations on chosen topics. One or two teammates would prepare some slides with sample code and we would discuss it after presentation. We even took our own created exams :) However, even though vouchers have been ordered, it took quite some time to get emails telling that we can now take the exam. This certification is still new and was only in beta at first, but now they are rolling out emails to everybody. They still don't have yellow pages with a list of certified developers, but are working on that. I was interested on what will be the process of certifica

Faster composer

Image
Hey fellow coders! This short post is for PHP developers. We have a wonderful tool composer , which helps us manage our dependencies. However, we sometimes need to install the whole framework with many packages which might take quite some time. You are lucky if you did this before and have most of the packages in cache, but that is not always the case :) hirak/prestissimo package comes to the help! You install it globally and installation time will be reduced up to 10 times! Creating a new Laravel project without parallelisation and no cache: Doing the same with hirak/prestissimo installed: Easy to install and joy to use. Try it out :)

My .bash_aliases

Image
Hey, fellow developers! So this post is more for IT people, but for other I will explain what aliases are. Bash is a terminal shell - basically a framework which can interpret your commands, execute them and give the output. Bash is only one of shells like sh , zsh , fish , kzsh , tcsh , etc. Being a developer involves quite a lot of work with a terminal, thus typing many commands a day. Typing a command takes time. Moreover, when you have to type it many times in a row or in a short period of time, it might get really annoying (at least for me 🙂). However, there is a way to speed it up and ease the typing - aliases. Aliases allow you to name a certain longer command and run it next time just by typing the name. So without further due, here is my list current aliases: Docker alias dr="docker-compose run" alias de="docker-compose exec" alias db="docker-compose build" Composer alias c='composer' alias t='c test'  -

My YouTube subscriptions

Image
I have to admit. I'm kinda addicted to YouTube. It's like a never ending stream of knowledge and fun. However, lets be honest - it's a real time eating machine. Hours will fly by as minutes while you are exploring the wonders of online videos. YouTube can help you discover and learn a lot of new things, but you better be very careful with the content you choose to watch and making a decision to click on that next video. I used to be subscribed to like a hundred of channels. Some were really great and others... Well, lets just say I probably seen like one or two videos from them. So, one day as I caught myself wasting time on random videos the nth time, I have decided to clean everything up (Facebook also didn't got away, by the way, and was cleaned up from various useless page subscriptions). I will share what channels survived my cleanup with a short description about them. I hope you will find something worth your time as well. Be Inspired This channel is g