small logo

melfneerg.com

 - 'cos life is like that


[Blog]  [Pictures]  [Links]  [About
About the Author
Tudor Davies

author Tudor is a techie turned manager who fights like mad to keep his tech skills honed and relevant. Everything from web hosting, networking, *nix and the like. Constantly developing and co-ordinating with others to make the web a better (and easier to use) place.

No updates

Monday, 19th Feb 2018  Posted @ 17:24

I haven't updated this site in some time.

It isn't retired as such, I just don't think I've got as much to say as I used to.

Tweet


Cisco ASA vs SMTP

Wednesday, 16th Apr 2014  Posted @ 08:39

Had a weird problem at work over the past couple of days.

We currently run a tiered mail cleaning system for some of our customers and we are in the process of retiring one of the tiers as we have improved the efficiency and resilience of the front end.

This meant that instead of mail being sent from the front end to the back end and then to the customer mail server, it goes to the customer mail server directly from the front end. We did the switch over and saw traffic flowly quite nicely.

And then the outgoing queue started growing. Gradually. And only with large emails (.5Mb+). So we reversed the change and started investigating.

Some crafty google searching led to this page. So I jumped on the customers managed ASA and checked the inspection profiles. ESMTP was enabled. Once change request later, it is disabled, the front end server is pointed to the customers mail server again and all email (regardless of size) now gets delivered.

Under ASDM, it can be disabled by Configuration -> Firewall -> Service Policy Rules -> inspection_default -> Rule Actions - uncheck ESMTP -> Apply

[ 1 comments : Add | Read ]

Tweet


Kint

Wednesday, 9th Oct 2013  Posted @ 10:56

Having recently come across Kint, I have pretty much fallen in love with it.

Adding into your system is a matter of downloading it and then sticking it somewhere useful.

It is then invoked in my setup using:
if($stage=='development'){
$host = 'localhost';
require 'assets/php/kint/Kint.class.php';
}


I then place this at the end of my code:
if($stage=='development'){
// remove the $GLOBALS from the array
$arrays = array_diff(get_defined_vars(),array(array()));
Kint::dump($arrays);

// dump the other stuff
Kint::dump($_SERVER);
Kint::dump($_POST);
Kint::dump($_GET);
Kint::dump($_COOKIE);
Kint::dump($_FILES);

// show where I came from
Kint::trace();
}

This gives a nice, easy to read dump of all the stuff going on in my scripts - very nice :)

[ 1 comments : Add | Read ]

Tweet


Selling stuff...

Wednesday, 14th Aug 2013  Posted @ 09:59

It is time to say good bye to my old web hosting kit. We are relocating the office in the next couple of months and there will not be space for it in the new premises plus I have moved everything onto VPS around the 'net providing me will resilience and far better response times.
My dev box and firewall I will be keeping (but relocating to a new DC where I shall have unlimited bandwidth (huzzah!) but the main lot is now up on eBay.
A lot of kit for not a lot of money. Proceeds raised from that, selling an unused laptop or 2, a load of unused IDE hard disks, some PS2 5" screens, some RAM and a decent graphics card will go towards a new spangly specified DJ laptop.

[ 1 comments : Add | Read ]

Tweet


Build it and they will come

Thursday, 25th Jul 2013  Posted @ 08:46

After reading this article it got me to thinking not only about startups but also about developing internal applications.

How much of what we as programmers produce is actually used?

My direct line manager (henceforth known as "Mecontent"), for example, requests multitudes of features for any application he sees as required (and also fails to recognise that he is the worst offender when it comes to feature creep and creating technical debt). The main issue is that generally the apps he wants are not used by him but by other in the company, so plenty of things that we build are never used.

There is a prime example of this in our current internal CRM system - there is a button in the ordering system called "Create Manual Order" - a feature requested by Mecontent. It took almost 2 years for someone in the dept that would create manual orders, to ask "What is this button and when did that appear?"

This has made me rethink some of the features I have been planning for a couple of web apps I have been working on (one of which could actually work pretty well and give me a salary). I think they are damn useful features but would they be used?

Maybe the answer is closer cooperation with beta testers. Get the MVP up and running and let select individuals loose on it. Then guage what parts they use, what they like/dislike and ask them what is missing (not what they would like).

Suggestions / thoughts?

[ 1 comments : Add | Read ]

Tweet


Super Resilient Email

Thursday, 18th Jul 2013  Posted @ 14:16

So then. I have lots of domains - ranging from gTLDs through to DynDNS supplied ones and lots of email accounts. This means that I get a lot (and by a lot, I mean a lot) especially as some of my email accounts have been running since 1996 (UUNet/Pipex).

I also have several VPS, a couple of hosted domains and my own servers with stuff hosted on them.

Anyhoo, what I really wanted was a single place where all my email would end up regardless of which domain it was sent to. So this is what I did:

Step 1
Setup postfix on 3 of my VPS'.
Configured each one with virtual_alias_domains and virtual_alias_maps (example below):
/etc/nginx/main.cf
virtual_alias_domains = example.com, example2.com, etc
virtual_alias_maps = hash:/etc/postfix/virtual

/etc/nginx/virtual
@example.com [email protected]
@example2.com [email protected]

Run postmap against the virtual file and restart postfix.

Essentially I have (on all 3 servers) put a forward on all and any email for a domain to my gmail account.

Step 2
Create round robin DNS entries on at least 1 domain
A mx2.example3.com x.x.x.x
A mx2.example3.com y.y.y.y
A mx2.example3.com z.z.z.z

Step 3
Change the MX entries for every domain to point at mx2.example3.com

Thats it. Its completely fault tolerant - if one of the VPS' goes down or the company goes belly up, I just need to amend a single entry for mx2.example3.com but mail will continue to flow using any of the other servers that is still responding and all my mail ends up in a single place (gmail).

I just need to import my IMAP folders into Gmail and I am done :)

[ 1 comments : Add | Read ]

Tweet


Moving

Wednesday, 17th Jul 2013  Posted @ 07:46

So I have moved this site onto a VPS server.

It used to be hosted on my own kit in the office where I work but we are relocating in the next few months and I dont think that there will be space for me to have my own environment.

Thats not too bad, as 2 of the 4 servers are no longer in use (the old mail and NAS servers are not used anymore) so it will now be a process of moving the sites one by one across to this VPS and then making sure they are backed up regularly!

[ no comments : Add ]

Tweet


How not to design a database (or code...)

Tuesday, 11th Jun 2013  Posted @ 10:30

We have a portal system at our office which was programmed some time ago and we are slowly going around fixing some of its problems.

Todays lesson - how not to design a database table.

SQL Server: mySQL
Scripting language: PHP
Requirement: Log particular information about who did database updates.
Data: who, when, what

You would think that would be simple enough, yes?
Apparently not.. Here is the table definition:

CREATE TABLE `logs` (`id` int(10) NOT NULL AUTO_INCREMENT, `user` text NOT NULL, `date` text NOT NULL, `time` text NOT NULL, `message` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
and here is a sample piece of data:
(140077, 'someone', '18/10/2011', '1318927714', 'UPDATE qrel SET qty='12', ftype='0', bprice='11.60', sprice='13.80' WHERE id='9597'')
Erm, erm! What? I mean seriously WTF?!? Where to start?

1 - Our usernames are only 8 characters long, so "text" is a bit of an overkill. Ideally, it would be INT that linked to the id of the user in another table, but I really dont think that was though of at any point.

2 - A column called "date" - defined as "text". Fairly sure that could have been a column defined as "date".

3 - A column called "time" - again defined as "text". Fairly sure that could have been a column defined as "time".

But it gets worse, the "time" field is actually storing unixtime! So it could have been 1 column defined as "datetime" but no - lets frig it all in the code and store it as ruddy text!

And don't even get me started on indexes. On the page to view the logs, there are 2 filter field - who and when. Neither of which are indexed (and if they were they would have to be FULLTEXT under the existing schema)!!!

I havent even looked at the code yet, cos I'm getting a little scared.

I despair sometimes, I really do :)

[ 1 comments : Add | Read ]

Tweet


Nest your jQuery .loads...

Tuesday, 4th Jun 2013  Posted @ 09:08

I was having a nightmare loading some information using jQuery into a webapp.

This works:

function getTransactions() {
var oAccount = document.getElementById('account').value;
$('#transtable tbody').load('api.php?action=gettransactions&account=' + oAccount);
$('#balancetable tbody').load('api.php?action=currentbalance&account=' + oAccount);
}
However, the first request was taking 6-7ms but the second request was always taking 1.01s regardless of the order I put them.

So I did some googling around and decided to nest the requests:
function getTransactions() {
var oAccount = document.getElementById('account').value;
$('#transtable tbody').load('api.php?action=gettransactions&account=' + oAccount, function () {
$('#balancetable tbody').load('api.php?action=currentbalance&account=' + oAccount);
});
}
Now both requests complete in 8ms!

[ no comments : Add ]

Tweet


Remote Debugging

Friday, 12th Apr 2013  Posted @ 23:41

One of my websites was reporting spurious results when being sent a specific query. Regardless of the information being sent by the client, it was always sending back the same limited set of results.
I was DJ'ing at the time, so was limited in the resources available - but I did have my Android tablet.
So I fired up ConnectBot and SSH'd into one of the boxes. To start debugging, I did:

tcpdump -A -v dst port 80
This confirmed that the client was sending the correct information, so it was the script on the server at fault.
I added a
print_r($string)
in the ajax handling script and saw that the same array was being used, regardless of the information was being received - somethng was indeed awry.
I added an echo to print the received data and nothing... Hmmm!
A quick look at the code which interprets the ajax sent to it and there it was: 2 underscores when there should have been one.
Quickly fixed and then replicated to the other servera in the cluster and all fixed.

[ 1 comments : Add | Read ]

Tweet




layout and initial css based on the Qtractor page