TILs (Today I learned)

I try to keep track of new things I learn.
It's usually something small, possibly irrelevant.
Here is a list of all the things that I have kept a note of. Maybe something would help you as well!

Default Sendmail hostname gotcha

This is a gotcha if you are using anything that hooks up the server’s mail command like mail() function in PHP.

Let’s say your default mail provider for example.com is hosted on a server different than your main application at example.com. Sendmail will use the first hostname in the /etc/hosts file as the default hostname. So if you set the server hostname to example.com and try to send email from the application it will not be delivered properly and will result in a lot of dead.letter(s).

A quick solution to this is to change the line example.com localhost in /etc/hosts to www.example.com localhost and reboot the server. If you take this route make sure you also remove the example.com from /etc/mail/local-host-names.

TFS2012 project administration web interface gotcha

When managing a TFS2012 server you want to assign a user as an Administrator be careful where you do it.

When viewing a team for a Project the web interface provides a quick form in the left sidebar to add a user as an administrator. This only makes them an administrator for that team. Not the project!

You have to go one level up to the Project then to the security tab and add the user to the Project administrators.

LXDE desktop shortcuts names

You can create a shortcut on the desktop in LDXE by right-clicking an item in Menu. If you try an rename the desktop shortcut by simply F2 or right click > Rename it will give you the option to rename but doesn’t actually rename.

The quick way to do it is to right click > open in leafpad (or any text editor)

If you are doing it on the command line, the file is located in /usr/applications/application.desktop.

HyperV naming and file location

If you are using HyperV as your virtualization host this is a small quirk that can cause annoyance. When you are going through the new VM creatation wizard it asks you where to create the new VM. It seems like this is the folder where HyperV will put the XML file that holds details about the VM setup, but it’s not. It actually creates a sub-folder called Virtual Machines inside the selected folder for the XML files and other metadata.

If you are trying to get a naming convention going make sure you include this sub-folder in your convention.

Setup SDL2 with cmake and cLion

So you’re trying to build a really simple SDL2 app. You have CLion installed and CMake all set up. But every time you make the project you get Undefined symbols. Make sure you are

A. Finding the package using find_package(SDL2) B. Linknig the libraries using target_link_libraries(SDLGame SDL2)

Middleman ruby templating for your static site

I was looking for something to build a static site. Something like Hugo works well if building blogs and sites with liner content. I was looking to build a generic site. Kind of like a brocure one.

In comes Middleman. It’s perfect. I could use Ruby HAML, sass (albeit w/ some Gulp tasks). All my RoR knowledge was pretty useful!

rails prepared statement postgres

When using ActiveRecord::Base.connection to use prepared statements with PostgreSQL you have to use $1,$2 etc. not ? like in MySQL.

That means the statements are going to be database specific. So make sure you wrap things up in if...else blocks if you use multiple databases across different environments.

Gotcha about calling a shell command using Python subprocess

So you want to call a shell command from your Python application. There is a really nice library subprocess to do that. It has a lot of different methods that you can call. Most of them take the command and it’s arguments as an array.

The gotcha is about arguments that have spaces and require quotes around them. So for example you want to call the command:

my_cmd --arg1 --arg2="this is an argument"

To do that in the subprocess you convert it to an array such as:

["my_cmd", "--arg1", "--arg2='this is an argument'"]

That’s when you’ll start getting weird issues. The subprocess handles the spaced arguments on it’s own. So it’ll try to sanitize the quptes you just added. The array you pass has to be:

["my_cmd", "--arg1", "--arg2=this is an argument"]

And let the library handle adding the quotes!

vagrant wth virtualbox on windows

I found out that most vagrant boxes provided through Hashicorp Atlas don’t work with HyperV. So if you are using Vagrant on windows make sure HyperV is disabled in the Windows Features.

If it’s not then you will get weird errors about processor virtualization not being compatible.