• golang

    What I have learned from Gopher exercises 01 (csv quiz game)

    I’m not sure whether this blog post will benefit anyone but me, but I’m trying to put what I have learned from gopher exercises in writing (I’m not even sure whether I’ll be doing the same with the rest of the exercises). and I thought I’ll publish it as a blog post instead if just keeping it in my local drive The exercise you can find the exercise here: https://courses.calhoun.io/lessons/les_goph_01 in a nutshell, we want to build a small command line application that will show quiz questions to the user and expect responses. And then show the user how may answers they got right. The questions are supposed to be…

  • Laravel testing 101

    The Laravel Testing 101 ebook is launched and ready!

    I am extremely excited to announce the availability of the Laravel testing 101 ebook! I have spent countless hours working on this ebook over the last months and I hope that it will help you learn how to add tests to your Laravel CRUD applications. You can get your copy for just 19.99$ (limited time only): https://leanpub.com/laraveltesting101   you can also sign up here to get 3 free chapters: https://laraveltesting101.com/ Please let me know any feedback by tweeting at me (@djug) or simply emailing me (my first name at gmail).

  • Laravel,  Laravel tips

    How to set up your local projects to contribute to Laravel (or any PHP library) : a practical guide

    Let’s imagine this scenario: You are working on a Laravel application, and you found a bug either in the framework itself or in one of the third party libraries you are using. You edit the code inside your project, or maybe you installed a fresh copy of Laravel and library that has the issue, and you edited the code there. You saved the changes, but when you went to your terminal to commit the changes, GIT just ignored what you did. You start wondering “What’s happening here?”.   The first solution that might pop up in your head could be to read the “How to contribute” of the framework or…

  • Laravel,  Laravel testing 101

    [Laravel Testing 101] Writing tests for guest user functionalities on a Laravel CRUD application

    This is an excerpt of my upcoming ebook Laravel Testing 101. If you haven’t read the previous chapters yet (available for free here: Adding Tests to your Laravel CRUD Application: Where to Start? and here: What should we be testing in a [laravel] CRUD application?), please do so before reading this one. Now that we have a better idea about the functionalities we should be testing in our Laravel application, let’s start with testing what a guest can do, since it is less complicated than what a logged in user can do. As we discussed I the previous chapter, here are the functionalities related to guests that we have in…

  • Laravel,  Laravel testing 101

    What should we be testing in a [laravel] CRUD application?

    This is an excerpt of my upcoming ebook Laravel Testing 101. If you haven’t read the previous chapter yet (available for free here: Adding Tests to your Laravel CRUD Application: Where to Start?), please do so before reading this one.   Now that you understand that you should be looking at tests from a different angle, and that we should test mainly controllers, you might start to ask, “… but what should I be testing exactly?” In this chapter, we are going to answer this question and describe what we will be testing in the rest of the ebook. But first, let’s get the demo application the book is built…

  • Laravel,  Laravel tips

    [Laravel tips] How to redirect users to a specific URL/route when the validation fails

    If you are using Form Request to validate your forms before you persist them in the database, when the validation fails, the user is usually redirected back to the same page that initiated the request. For instance if you are on /new-article page, after you submit the article you are creating, the user will be redirected back automatically to this very same URL if the data she entered failed to pass the validation. This is the desired behavior in majority of the cases. Lately, I was working on a form where I needed to redirect the user back to another route. I was working on an application where we have…

  • Laravel,  Laravel testing 101

    Adding Tests to your Laravel CRUD Application: Where to Start?

    This is an excerpt from my upcoming ebook Laravel testing 101 Imagine you are working on a Laravel side-project or you just joined a team working on a Laravel application, and it currently doesn’t have a single test. You want to change that, and add tests to the application. If you find yourself in this situation, you might not even know where to start. “Should I unit test everything? Should I just test the most critical parts of the application?” You might even find yourself asking “Why do I need tests in the first place?” I am writing an ebook to answer all these questions for you, and this is…

  • Tutorial

    [Laravel tips] How to temporarily change a laravel environment variable without updating the .env file

    Imagine the following scenario: you are working on a laravel application that dispatches some jobs to a queue. You notice in your log file that a specific job is throwing an exception, but you can’t debug it directly (with dd() for instance), since the job is consumed by a worker elsewhere. One way to debug this issue would be to change the QUEUE_DRIVER environment variable in your .env file to sync, debug, and then revert back the change after you finish. Or imagine that you have a test database and you need to run the migrations on it first, and you’d need to update the .env file to use the…

  • Uncategorized

    [PoC] Partially random passwords: or how to protect users passwords from keyloggers with partially random passwords

    One of the issues we all face when we login to some online accounts especially on public computers, or on any computer that we do not own, is that there is always a risk to get our passwords stolen especially with keyloggers. If a hacker gets a “copy” of your password, she can log in to your account and do whatever she wants. As always, using 2 factor authentication can mitigate this issue, since the hacker needs to access your phone as well. But what if using 2FA is not an option, and we want to protect the user even in this case, can we detect,when the hacker tries to…

  • Tutorial

    [PoC] Password-Based user roles and triggers/actions (or how to use different passwords for multiple roles for the same account)

    We have all seen a movie or two where a villain forces some innocent people, to give him the password to access her ultra secret account (a nuclear facility, or a Swiss bank account), the villain ends up getting access to the account and transfers all the money to his own account, or launch a nuclear weapon. We have also all heard about authorities in some countries that force their citizens or even visitors to hand them their social media accounts and passwords. Usually the “victims” don’t have any choice and they end up providing their passwords. One way to prevent this is maybe to activate multi level authentication on…