Scripting is often part of our jobs, and the data we’re using in our scripts is regularly provided to us in spreadsheets. There are a couple different ways to get this data into an array, so we can iterate through it:
Inheritance is one of the primary tenets of object-oriented programming languages, but each language implements it at least slightly differently. I’m coming from a background in Python, and it took me a bit to understand the different ways objects can extend or inherit behavior in PHP. Here is what I have learned!
extends keyword in PHP is inheritance as I knew it — one class inherits behavior from another, but can extend and modify it. The PHP docs are here. Classes at all levels of this hierarchy can be instantiated.
In addition to adding new behavior, subclasses can modify…
Arrays in PHP…Because there are no hashes/dicts
I’m brand new to PHP. Every other language I’ve worked in has had the concept of a hash/dictionary/object, separate from the concept of an array/list (though, yes, lots of names for the same general idea…I’m going to use the word
dict going forward, but I also mean the
Object, etc. that you’re familiar with).
So I was pretty surprised to learn that the concept of a dictionary doesn’t exist in PHP. They’re useful, and they’re way more time-efficient than arrays in some use cases. So…how does this work?
If you’re being blocked by Medium’s paywall, this article and all its links are also available here.
I’ve been writing about (and working in) Django for almost five years now, and I’ve written a lot about specific pieces of implementation. But as I’m about to move into a new role that won’t be using Django anymore, I want to take a step back and look at how it all fits together.
Encryption is a huge part of modern software engineering. This is true both of data within our own systems, but also encryption of data we send or receive with network requests, to ensure the security of data in flight and the validity of data received from other services.
Most modern languages have libraries or built-in functionality that can be used to implement encryption for us, so knowing the ins-and-outs in depth isn’t necessarily a prerequisite of working in parts of your system that use encryption. …
I had never heard the word “idempotent” when I started at my first software job. I had a liberal arts education and had been working in nonprofit and school management before my career change. I suspect I’m not alone in this total lack of awareness of the concept! So let’s talk about it.
It means you can do the same thing with the same inputs any number of times, and it won’t change the end result.
This is easy to achieve when we’re talking about data retrieval — retrieving data doesn’t change the data itself. But it gets a little…
When many of us are first taught to program, we’re told something along the lines of “programming is a set of very specific instructions that a computer follows in a specific order.” And this is true, sort of. It’s true, but it’s incomplete. What that statement ignores is that when we’re programming for the web, we’re usually dealing with more than one computer.
Multiple computers run our application servers. We use microservices. We have databases and background tasks and message busses and scheduled jobs.
These are the high-level things I wish someone had told me when I first graduated from…
I’m mot going to do a deep dive into cookies and their use in the web on the whole. If you think an introduction like that would help you understand this post better, here is one place you might start.
The very high-level that will apply to what we’re going to talk about here is this:
No matter how hard we try to get our data model correct (and even if we’ve done so!) sometimes by the time we need to use it, either for a public-facing API or an internal one, we need things to look a little different. Django Rest Framework(DRF) has some useful tools for allowing us to build serializers based on our models that differ somewhat from how we’ve defined things internally.
For our example, we’ll say we have a data model that looks, in part, like this:
name = models.CharField(max_length=255)
item = models.ForeignKey(Item)
Unless a website is static, it almost certainly connects to other cloud services such as databases or caches that are hosted on servers other than the ones on which main application is running. Connection strings are used to identify where to find the server running the service, what type of driver to use (Postgres, Redis, AMQP, etc.), and what credentials to access it with.
At first glance, they can look like nonsense and be difficult to parse, but the good news is, there’s a logic behind it all! …