How to set up a local web domain on WampServer

How to set up a local web domain (i.e. VirtualHost) on WampServer

When working on a website, it is not uncommon for developers to locally host websites on their own computers first, as it is often a good idea to run and test your website before you publish it online, so that you avoid having your live website run into errors and bugs.

If you are a Windows user, one of the several local web hosting softwares you have available to you is WampServer, which normally runs on the localhost URL when it is started up.

Fun fact: Wamp stands for Windows, Apache, MySQL and PHP. It is a play on the term LAMP (where L stands for Linux, and the rest of the letters mean the same as those in Wamp), as almost all web servers in the early days of the web ran on such a set-up. Today, LAMP stacks are still widely used to host many websites.

While running on localhost gives us the benefit of using root-relative URL paths, it still has a distinct drawback — it is a hassle to run multiple websites off the localhost URL, as it will still cause the aforementioned root-relative URL paths to break.

Fortunately for us, it is possible to set up what I call “local domains” on WampServer, so that you can use URLs outside of localhost to access your websites on WampServer.

Continue reading
CodeLobster IDE, a free PHP, HTML, CSS and JavaScript / TypeScript editor

CodeLobster IDE — A free PHP, HTML, CSS and JavaScript / TypeScript editor for web developers

If you’re just starting your foray into the world of web development, you’re probably wondering what kind of code editor or Integrated Development Environment (IDE) to use. In most other branches of coding, like application or games development, you’re probably only going to deal with 1 or 2 programming languages concurrently. In web development, however, you’re almost always going to be dealing with at least 3 languages concurrently, so it’s going to feel very different from almost any other branch of coding.

Especially if you’re new to web development, having to deal with so many languages in one go (and having to be familiar with the native libraries of each of the languages) can be rather overwhelming, and the developers of CodeLobster IDE seem to understand this very well.

Continue reading
Create a Farming RPG in Unity - Part 15

Creating a Farming RPG (like Harvest Moon) in Unity — Part 15: NPC Interaction

This article is a part of the series:
Creating a Farming RPG (like Harvest Moon) in Unity

Ever wanted to create a game like Harvest Moon in Unity? Check out Part 15 of our guide here, where we go through how to create a dialogue system and create the relationships with other characters aspect of the game. You can also find Part 14 of our guide here, where we went through how to set up scene transitions.

A link to a package containing the project files up to Part 15 of this tutorial series can also be found at the end of this article, exclusive to Patreon subscribers only.

To view this content, you must be a member of Terresquall Patreon at $5 or more
Already a qualifying Patreon member? Refresh to access this content.
Enumerations in Java explained (using Pokémon as an example)

Enumerations explained (using Pokémon as an example)

What are enums anyway, and what are they used for? Well, just think of it as yet another tool in your handy Java toolbox of things you can consider using to improve your efficiency and organisation of your program.

In this article, we are going to explore what enums are, and how they can be used in Java, by considering a piece of Java code that uses enums to recreate the type effectiveness system found in Pokémon.

Continue reading

Content begins after the advertisement:


Why doesn't vertical-align: middle work?

Why doesn’t vertical-align: middle work? How to vertically-centre elements in HTML and CSS

If you are new to working with CSS, you may find that the language comes with its fair share of quirks that can be frustrating, such as the text-align attribute not always working at horizontally-aligning your content.

In a similar way to text-align, the vertical-align attribute doesn’t always work at aligning your content vertically. Take the following HTML code for example:

Continue reading
Fixing the e.indexOf is not a function error

Fixing the “e.indexOf is not a function” error on your website

If you have a WordPress site that was built before August 2020 (when WordPress 5.5 decided to stop supporting jQuery Migrate), or if you manage a site that recently weaned off jQuery Migrate, you might run into errors where the parts of your site that run on Javascript stop working.

When you open the Developer tools of your browser (that’s the F12 key for most browsers), you might also see an error message that looks something like this.

Uncaught TypeError: e.indexOf is not a function
    at S.fn.load (jquery.min.js?ver=3.6.0:2:84932)
    at headings.min.js?ver=3.19.4:1:2579
    at headings.min.js?ver=3.19.4:1:2706
Continue reading
Create a Farming RPG in Unity - Part 14

Creating a Farming RPG (like Harvest Moon) in Unity — Part 14: Currency and Shop System

This article is a part of the series:
Creating a Farming RPG (like Harvest Moon) in Unity

Ever wanted to create a game like Harvest Moon in Unity? Check out Part 14 of our guide here, where we go through how to set up the currency and shop system. You can also find Part 13 of our guide here, where we went through how to set up the main menu and generate obstacles.

A link to a package containing the project files up to Part 14 of this tutorial series can also be found at the end of this article, exclusive to Patreon supporters only.

To view this content, you must be a member of Terresquall Patreon at $5 or more
Already a qualifying Patreon member? Refresh to access this content.
Setting up a virtual Postfix mail server — Part 4: Setting up a Sender Rewriting Scheme (SRS)

Setting up a virtual Postfix mail server — Part 4: Setting up a Sender Rewriting Scheme (SRS)

In the previous part of this tutorial series, we set up DKIM, DMARC and rDNS on mail server to make emails from our mail server more deliverable, as these protocols make it less likely that other mailboxes will flag our emails as spam.

With that set up, we can now turn our attention to something else. Currently, any incoming mail to one of your domain emails will fail the SPF check for the domain.

Gmail SPF Softfail
To see this, you will have to view the email's message source. You can do that with most mail clients; here's how to do it for Gmail.
  1. Why SPF fails for incoming emails
  2. Installing and configuring PostSRSd
    1. Installing PostSRSd
    2. Configuring PostSRSd
  3. Configuring Postfix
  4. Starting PostSRSd
  5. Conclusion
To view this content, you must be a member of Terresquall Patreon at $5 or more
Already a qualifying Patreon member? Refresh to access this content.

Content begins after the advertisement:


Why is calling setters in Java constructors discouraged?

Why is calling setters from constructors discouraged in Java?

In Java, coders are discouraged from calling setter functions in class constructors. Even though doing so can sometimes reduce the amount of repeated code.

Consider the following class:

Unit.java

public class Unit {
	protected int health;

	public Unit(int hp) {
		// Prevents health for being set to 0 or less.
		if(hp <= 0)
			throw new IllegalArgumentException("Health must be more than 0.");
		health = hp;
	}

	public void setHealth(int hp) {
		// Prevents health for being set to 0 or less.
		// Repeat of the code in the constructor.
		if(hp <= 0)
			throw new IllegalArgumentException("Health must be more than 0.");

		health = hp;
	}

}

Instead of doing the check twice across 2 functions to ensure the incoming hp value is correct, it might occur to some coders that we can call the setter within the constructor instead, to reduce the amount of repeated code:

Unit.java

public class Unit {
	protected int health;

	public Unit(int hp) {
		// Prevents health for being set to 0 or less.
		if(hp <= 0)
			throw new IllegalArgumentException("Health must be more than 0.");
		health = hp;
		setHealth(hp);
	}

	public void setHealth(int hp) {
		// Prevents health for being set to 0 or less.
		// Repeat of the code in the constructor.
		if(hp <= 0)
			throw new IllegalArgumentException("Health must be more than 0.");

		health = hp;
	}
}

This, however, is discouraged, because (according to textbooks) setters like setHealth() can be overriden by child classes, creating unexpected or buggy behaviour in these child classes.

Continue reading