Category Archives: geek

Web Server slow down on Windows

I have been programming on a Windows machine my entire career, and have always noticed that PHP takes a rather long time to run on my local machine versus a dedicated server. I never paid much attention to it, thinking that there wasn’t much that I could do to solve the problem.

Lately, I’ve been working with Magento at my new job, and have noticed that it takes an excruciatingly long time to render a page. Due in part to my use of Xdebug, and also due in part to the large and complex nature of Magento.

I finally got sick of the wait as it was reaching a point where I was waiting minutes for a page to render, and I started to look at the processes that were running at the same time as httpd (the web server).  One that stood out–because it was taking nearly 12% of my multi-core processor (which is a lot for a multi-core)–was MsMpEng.exe. This little service is the one that runs the Microsoft Security Essentials scanner.

So basically what was happening was that every time I requested a page, Microsoft Security Essentials decided to hop in and make sure that the server was not doing anything malicious. This in turn caused the server process to slow down, and the response from the server to halt while the scanner scanned the response.

I therefore added httpd, php, php-cgi, php-win, mysqld, and mysql to the list of excluded processes, and let me tell you, going from literally minutes to a just few seconds to load a Magento page is a nice improvement.

So if your server is consistently slow, make sure there are no security programs scanning the processes while they run. It may surprise you the difference it makes.

Interesting code snippet

I was looking into a function to allow me to sort an array of objects in JavaScript, and I stumbled upon this interesting little snippet:

When I first looked at this, I wasn’t quite sure what it did, but as I started to take it apart, it became clear. It’s a very clever little piece of code.

This was part of the return value of the sort function, which, if it returns a 1, sorts ASC, and -1 sorts DESC. This little snippet switches that.

The way it works, is it creates a small two-element array [-1, 1] and then pulls out the n-th element where n is +!!reverse.

It’s the same as writing:

The !! part makes sure that reverse is a boolean, and the + converts it to an int.

Very interesting, and I had to look at it for a second to really figure it out.

Original snippet location:
http://stackoverflow.com/questions/979256/how-to-sort-an-array-of-javascript-objects#answer-979325

UPDATE: After playing with this code, and really looking at it, I’ve decided that this piece of code, while clever, is poor programming.

The reason I think this is for one, it’s not clear what it does at first glance, and secondly, it can be re-written to be both more readable, and less prone to errors.

I rewrote the code to look like this:

The reason I did this was because when I tried to format the previous bit of code to fit my coding style, it broke. Apparently, the + needs to be directly connected to the variable that follows it to get the JavaScript quirk of changing that variable to an integer.

This small difference was enough for me to decide that this bit of code was too fragile and needed to go.

If you’ll also notice, in the original code, reverse was actually set when the sort order was normal (returning 1), and unset when the sort order was reversed (returning -1).  I also fixed this, making the name of the variable match it’s function, thereby making the code even more clear.

Moving…

So I’ve decided that I want to keep my personal site and my professional site more separate, as well as give everyone in the family a matching email address and allow for growth within the family website, so I’ve created welkerfam.net.

Anything that is of a personal nature will be found over there, and all of my more professional/programming things will remain here at the iohelix.

Feel free to head on over and check it out. It’s pretty fresh, and I’m still getting things moved over properly, so I’ll keep a copy here as well for about a month or so until everything has been ported over properly, but it’s up and running.

36 Cube

So I’ve been geeking out over a puzzle that I got for Christmas this year. The puzzle is called 36 Cube.  If you have this puzzle, and haven’t solved this cube, or would like to in the future, or have any other reservations about reading spoilers,

PLEASE STOP READING.

This is not a hints post, and I do not ease you into a solution slowly. This is a post about how I solved the puzzle and some interesting facts about the puzzle I found out afterwards when I began to dive deeper into the solution set. As well as the programming that went with it.

If you would like some proper hand-holding, please see How to solve the 36 Cube puzzle – hints & solution for hints (and samples of the program that got me started down my path).

AGAIN, IF YOU DON’T WANT SPOILERS, PLEASE STOP READING!
Continue reading

hacking iTunes paths

so unless you’ve been living under a rock, you know that we’ve moved to Slovakia.  during the move, I was unable and unwilling to pack my computer up to bring with us. it was just too large to be feasible. the next best thing was to backup my digital life onto an external hard drive–which chelsea so conveniently gave me for christmas–and bring that with us instead. one problem with this is that, as with every other time that I had to wipe my hard drive, I would be forced to re-import my entire iTunes library into iTunes, and if you’ve ever tried to import an iTunes library, it’s better than starting from scratch, but it sucks. playlists don’t sync properly, especially if they are based on other playlists. and the add date for all your songs becomes the same date, which I use in many of my playlists (recently added, etc.) but I think I found a solution to my problems…

Continue reading

leap second added at end of 2008

for everybody who will be celebrating the coming new year, make sure you don’t start (or end) your new year’s countdown early.

the international earth rotation and reference systems service (IERS) has announced that a leap second will be added at the end of 2008, making 2008 one second longer than it should be.

so either start your countdown at 11, or end your countdown at -1, either way…

enjoy the extra long year!  (it has both a leap day, and a leap second)

thoughts on proprietary file formats

so we got a new camcorder for christmas (mrs. claus was nice enough to bring one by for us), and I broke it out, started using it, got it home, and tried to hook it up to the computer…  well, that failed with a cryptic error message, but no big deal, the memory card is easily removed, and the camcorder conveniently came with a USB card reader. so i plugged that in, attached it to the comp, and tried to open the files with my favorite in-a-hurry audio/video player, VLC

nope. try again.

Continue reading

“i told you so” just doesn’t sound strong enough…

Microsoft Internet Explorer is about to ruin your day.  Read the story for more info:

http://news.bbc.co.uk/2/hi/technology/7784908.stm

Done reading?

Now, do yourself a favor and grab one of these:

Linking to specific moments in a YouTube video

A co-worker of mine pointed me towards this entry in a blog.

It talks about linking to a specific time in a YouTube video. I’ll repeat here in case you don’t want to link offsite.

Have you ever recieved links to videos that say something like “It gets really good around 1:47″, or something similar?

Now you can link to a specific moment in that video by putting the time as follows in your link: #t=1m47s

What this does, is when somebody goes to that link, it not only starts at the given time, but it doesn’t buffer all the stuff that comes before it, so you don’t have to wait for the part you’re interested in.

For instance, try the following link:
http://www.youtube.com/watch?v=OP1-5uxZffE#t=5m45s (SFW)

That’s just awesome.

new browser

being a web developer, i try to keep up with what’s going on in the browser realm of the interwebs. today saw the release of the new Google browser: Chrome.  a new browser release is nothing new, but the fact that Google has, for quite some time, been the main ‘internet’ company, providing everything from search engine and page cache, to email, web documents, and calendar, all online, makes this browser release something to look at.

Continue reading