Posts

Building A Completely Serverless PyPI Repository On AWS

Image
So maybe you're a team focused on Python and you've been looking into the best ways to deliver your packages to other members of your team or even to production environments. You start having thoughtful debate about the issu *skip forward* you realize that pip might be your best option; everybody knows how to use pip , it works perfectly with virtual environments, does dependency management, it's basically awesome. But then reality hits you; In order to use pip , you need a PyPI repository to host your code and you don't want all your team's hard work to be out on the public PyPI repository  for obvious reasons. So you start looking around learning how to build a private PyPI repository and you stumble upon  PEP 503 -- Simple Repository API . Huzzah! You finally figured out how this thing works but then you go like Oh man, so I have to get a machine, install web server software on it, go through all the trouble of setting it up and using best practices, an...

Binding Class Attributes In Python (Part 2)

Image
Hello everyone, sorry I haven’t blogged for a while but I was busy with other matters and barely managed to allocate enough time over the weeks to write this article. My last article was about how you can use Python to bind to class attributes together so that updating one automatically updates the other. I also demonstrated how we used this method in a college project to implement a MIPS processor by defining each block, defining its inputs and outputs (in terms of inputs) and then, using the demonstrated method, tell Python that the output of this block is connected to the input of the other block and just letting everything evaluate itself automatically. This was, by far, the most viewed article on my blog, so if you haven’t read this article, I recommend you go do that now, just follow this link . The old article also contains a lot of essential background which is required for understanding this article, so if you want to make the most of this article, read the old one firs...

Binding Class Attributes In Python

Image
You can also read this article from my LinkedIn here . If you’re not interested in my personal motivation to do this, you can skip right to the Essential Python Background section. Introduction During my last semester, my friends and I were studying a course called Computer Architecture . This course covered topics concerning how a computer processor works and how it is built and wired up internally. As a project, we were asked to build a software simulator that should be given input in the same manner a computer processor is given input, and then it produces the same output as the processor. After a lot of discussion, and despite facing some opposition, we decided that Python was the right tool for the job. The thing is, we had something in mind, that would make the whole process a trivial piece of cake but that something was not offered by default in Python. We had to build it ourselves. I was given the task of making this magic happen and I will explain what this magic wa...

Using Squid, Apache and Python To Develop a Captive Portal Solution

Image
You can also read this article from my LinkedIn from this URL  https://www.linkedin.com/pulse/using-squid-apache-python-develop-captive-portal-solution-peter-emil When I was a student in high school, I was always fascinated with captive portals. It always felt like a super-secret powerful thing to redirect someone’s traffic to a website of my choice. Despite having this weird fascination, I never knew that this was called a captive portal until I went to my network security internship. During my internship, I was introduced to lots of concepts but never really learnt how to combine the ones I need to produce something like a captive portal page. Before we dive into this article you must first Have squid installed and configured as a transparent proxy. There are lots of guides on the internet that will i ns truct you on how to complete this step. Have Apache (or similar) installed and configured to use CGI (in our case, for a python script). [OPTIONAL] Have a local...

Bypassing VOIP ISP block in Asterisk

Image
This is an article I shared before on my LinkedIn profile a while ago, but I decided to re-share it on my blog with minor changes. You can find the LinkedIn article here . Introduction I was a new guy to Asterisk. I set up my users, my dialplan and everything seemed fine, until I wanted to let my users connect to my server from the internet. I set up port forwarding on my router, but when I tried to connect from an internet device, nothing would happen. Living in Egypt, I discovered that my ISP is blocking SIP. Attempting to use SIP over UDP port 5060 (which is the default) always resulted in failure. I decided to change the port number, tried again but to no avail. I also tried SIP over a random TCP port but it still did not work. I concluded that my ISP blocks SIP using deep packet inspection. So I did some research, read some RFCs (Request for comments) and I will share here the concepts I learnt and how they helped me get over these restrictions. Please know that thi...