Hoe je vooral geen e-mails moet sturen

Vandaag kreeg ik een e-mail van een persoon die we niet nader gaan noemen. Laten we het erop houden dat het iemand is die in de jaren 90 is blijven steken.

Wil jij dus ook e-mails versturen als een aap uit de glorietijd van msn? Gebruik de template hieronder!

 

Beste [naam verkeerd gespeld],

[inhoud]

[naam afzender]*
[firma naam]
[job titel]
[telefoon]
[fax]
[e-mailadres]*
[website]*

Nieuw!
Like ons op FB en maak kans op prachtige prijzen! [link naar fb]

Denk even aan het milieu voor je deze e-mail afdrukt.

=======
E-mail gescand door PC Tools – geen virussen of spyware aangetroffen.
(Email Guard: 9.0.0.912, Virus/Spyware Database: 6.21090)

http://www.pctools.com/

=======
Deze e-mail en zijn bijlagen zijn STRIKT vertrouwelijk en uitsluitend bestemd voor het gebruik van de bestemmeling. Tenzij u de bestemmeling bent of de persoon verantwoordelijk voor de afgifte van dit bericht aan de bestemmeling, dient u zich te onthouden van elke bekendmaking, reproduktie, verspreiding of elk ander gebruik van dit bericht. Indien U dit bericht per vergissing heeft ontvangen, wordt u vriendelijk verzocht ons onmiddellijk telefonisch op de hoogte te brengen [telefoon] en deze e-mail en haar bijlagen definitief te vernietigen.

 


Alle velden aangeduid met een * zijn uiteraard de exacte gegevens waarmee je die e-mail verstuurd. Het is dus best wel handig dat je in je signature herhaalt, want we weten allemaal dat mensen nogal snel durven vergeten!</sarc>

 

 

Rails test database not resetting correctly

I have no idea why, but so far I’ve had this problem twice. My specs suddenly start failing for no apparent reason. When digging deeper, it seems my test database is not reset before starting the tests. Therefor quite a few validations fail because of unique constraints. The following code cleans the test database up.

rake db:test:prepare

Select a single column with active record

I have an ‘Image’ model and I needed to select only the ‘id’ column as an array.

ids = Image.pluck(:id)

You can easily combine this with a where clause.

ids = Image.where(field: 'value').pluck(:id)

Check the official documentation.

Convert latin1 tables/fields to utf8

I had some screwup which made all my tables/fields latin1. That sucks, because I didn’t want to manually correct this. I found the following lines of code that fix this problem.

mysql --database=marlon -B -N -e "SHOW TABLES" \
| awk '{print "ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"}' \
| mysql --database=marlon &

Also note that if you’re converting from some other obscure character set it’s best to first convert to binary and then convert to utf8, making sure you won’t lose data in the conversion.

How to fake ajax requests with cURL

If you need to fake ajax requests you can do this in the console (on Mac).

curl -H 'X-Requested-With: XMLHttpRequest' -d "my=var" http://localhost/en/my/page

Delete all tables in a MySQL database

I was looking for a script to delete all tables in a MySQL database without having to drop the database.

mysqldump -u [username] -p --add-drop-table [database] | grep ^DROP | mysql -u [username] -p

/cc @davelens

MacOSX maximize any window

I’m a keyboard man and I want to know as many useful shortcuts as humanly possible. I got a great tip from Dave Lens on how to configure MacOSX to bind cmd+m to maximize almost any window.

Blimp

Omdat ik altijd op zoek ben naar uitdagingen en je niet om 18u ineens stopt met ‘developer’ te zijn, ben ik in te huren als freelance developer.

Je kan bij mij terecht voor onder andere:
- websites
- webapplicaties
- maatwerk voor Fork CMS

Heb je andere vragen? Wil je even samenzitten om je project te bespreken of ben je op zoek naar advies? Contacteer mij geheel vrijblijvend.

- www.blimp.be
- twitter (@bauffman)
- linkedIn

Changing filename case in Git

I have a file named ‘filter.php’ and I renamed it to ‘Filter.php’, but Git doesn’t notice this. Instead I needed to do something like this:

git mv filter.php filter.php2
git mv filter.php2 Filter.php

It looks stupid, but it works like a charm!

Filtering files and directories in zend studio projects

Zend Studio adds some files and directories to every project. I have no problem with that, but I don’t wish to see these files. You can add an exclude filter in the project properties (richtclick an open project).

The default view (showing all files)

Right click the project and then click ‘properties’.

The settings under resource >resource filters

Click the add button.

Add the regex rule to exclude every folder/file that starts with a dot

If you do all this you should get the following result.

Filtered results

Do note that for some strange reason the ‘.project’ file will always be shown. Probably some internal reason, but I couldn’t find why that is.