SASS Color function comparison

So I’ve been working with SASS a lot lately, and was looking into replacing all the instances of scale-color($color, $lightness: 20%) with lighten($color, 20%), as it’s a more compact syntax and seems like it should do the same thing. But as I was doing that, I noticed that the colors that were being generated were not quite the same, and in some cases, wildly different. So I’m going to explain the differences between lighten and darken vs scale-color .

Continue readingSASS Color function comparison”

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:

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.

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,


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).

Continue reading “36 Cube”

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 “new browser”

webhost issues

my site went down about a week and a bit ago, so i tried to contact my hosting company and find out what was going on.
I went to the website, no notices there, went to the forum which has been removed, tried to submit a service ticket which i couldn’t do due to lack of a password for the system, and finally tried to call the 800 number which was blocked from my area code. all this took about 2-3 days, all of which saw no return of my website.

i finally found a regular number that i called and got in touch with an actual person and found out that 16 of the servers that this company owned got hacked and had all the data erased. no backups, no data, no nothing.

they finally got in touch with us (4 days later) and let us know what had happened.

i finally got a password for the support ticket system and submitted a support ticket for my website to be reinstated.
i must admit it was a very prompt reply, but the information they had given me was completely wrong, it was for another user and another site. I let them know they had messed up and they never replied. i told them again…   nothing. i finally wrote them a nasty little note and they promptly responded in kind.

i finally got my corrected information and got my site uploaded, but whenever i tried ta access it it would redirect to another website totally unrelated to my own.

it is still having issues, but my site is back up (thanks to backups i had made a week before the attack), my mail is finally working, but there are still some small issues with the site.

so…  long story short…   don’t host your site through webhostplus. their service sucks.

damn my a.d.d.

so i’m trying to make a php game (commanders) from scratch and it’s not going quite as fast or as easy as i’d hoped. there are a lot of little things that you have to plan for when coding an application from scratch, no matter what it is, that will bite you in the ass.

when i first got the idea for this game, i thought “i’ll get the game part of the script working and the rest will be easy”.  nope. first off, i have to get the game part working…  it’s not. not quite. secondly, i get distracted by other things WAY too easily. and thirdly, i really have no idea where i’m trying to take this.

i started off with an overly simplistic plan. not on purpose, but because i have no experience coding anything from scratch, after writing a preliminary few hundred lines of code, and trying to test that code, i began to realize that my storage methods (both within the database, and during code execution) were grossly underestimated. it took an almost complete rewrite of the existing methods and all the code that goes with it to get to a point where the game will actually progress the way that i want it to.

but now that i’ve got the game almost working, there are other issues that are creeping in that i wasn’t ready for. for instance, the game that i am creating is actually a port from a real life board game (Power).  the trouble with this is that issues that are trivially easy for a person to deal with are intricately difficult for a computer to deal with. i’ll spare you the details, sufice to say that my code is becoming much longer than i had planned. porting form a real board game also has the added benefit of having the rules already written, or at least most of them, but the ones that aren’t written are the ones giving me the troubles. what should i do if this situation happens?  what about this other situation?

another issue i have to deal with is myself. when i get in one of those moods, as i’m sure most of you have, where the juices just aren’t flowing, we’ll call it “coders block”, i turn to other items that may not be necessary to the project. i’ve also started another (albeit much smaller, simpler) game (battleship) from scratch which is progressing much faster and therefore holds my interest better. this is bad. even though the new project is nearing completion, i know that i am the type of person who will never think of anything as “completed”.

and on top of all this i am still working on webchess 2.0 (which finally had a beta release not too long ago).

so i now have three projects i’m actively working on, my job, and a freaking network+ test to take on monday.

and i have to spend more time with my wife, who is probably feeling pretty left out at the moment.

so here’s my time division:

  • my job (30%)
  • my projects (30%)
  • eating and sleeping (30%)
  • studying (10%)
  • my wife (110%)

if it weren’t for my a.d.d., i’d think i have a real problem.

(note: i’m not officially diagnosed with a.d.d., but most everybody i know would love some ritalin)

PHP scripts and games

So I’ve been adding a few RPGs and other games to the site and have had to edit those scripts quite a lot more than I should have to to get them to work on my site. Don’t get me wrong (especially if you happen to be a creator of one of those scripts), I love the games, and they have MANY good features in them, but it amazes me how much people code to their own setup. One example (and the most annoying because it breaks the script immediately), is the use of PHP short tags ( <? ). These little things are the bane of my existance.

There are four ways that you can let the server know that you are about to use PHP.

  • PHP Long tags ( <?php ...code... ?> )
  • PHP Short tags ( <? ...code... ?> )
  • ASP style tags ( <% ...code... %> )
  • Script tags ( <script language="text/php"> ...code... </script> )

Lucky for me, I’ve never seen the ASP tags, and have only rarely seen the Script tag, but the short tags are almost as popular as the long tags. Especially when using the shorthand notation for the echo command ( <?= ).

My server at home is set up to be very strict in it’s handling of tags, it only allows the PHP long tags, and for good reason. When using a PHP script with XML, the XML tag ( <?xml ) confuses the PHP parser into thinking it’s a PHP short tag with the unknown entity ‘xml’ following it.

Another thing I see people use often, is Registered Globals. These are extremely handy at saving yourself some keystrokes, but that’s about the only thing they are good for. Registered Globals take variables from a SuperGlobal and place it in the normal variable scope. An example would be an HTML form with a field called ‘name’.  When you send this form, a variable in PHP called either _POST or _GET is created based on which method is used to send the data. To get at the data the user sent, one must call $_POST['name'].  If Registered Globals is turned on, all one needs to do is call the variable $name and there ya go. This practice is not very safe and causes more headaches then they save in keystrokes.

All of these issues, plus some more obscure ones, are why people should not code to their own particular setup, but should code with certain standards that are applicable everywhere.

  • PHP Long tags are ALWAYS accepted by the server.
  • The _POST and _GET variables are ALWAYS available to the script.
  • The HTTP_XXXXX_VARS are NOT always available, as of PHP5 they can be disabled.
  • Even the _ENV and _SERVER vars are not always enabled.

So when you go out to write your first bit of code, or even continue work on a project you’ve been working on for years, think of the other people who may be using your script who may not have the same setup as you, and they may not have access to their php.ini file to change those settings. And don’t try to skirt your way around it by running the ini_set function either. That’s almost like putting a virus on someone else’s computer. Just don’t do it.

new job and web standards

so i got a new job working for a local independent graphic designer / printer and its pretty nice. i get to work when i want, at my own pace, from home, doing what i love, and get paid for it. the only thing about it that really sucks is that i’m doing web design and as any semi-serious web designer that works for clients will tell you, coding for cross-browser compatibility SUCKS !!

i mean, why can’t all the browsers stop the damn browser wars and come to an agreement on what will and will not be supported? it seems that the w3c has been doing a good job with stating what should be standard and what should not be standard, and most browsers do a pretty god job following those standards.

except one. microsoft’s internet explorer, the number one used browser on the planet. it works the way it wants to work, and getting your site to look the way you want it to in internet explorer is like trying to teach a four year old how to fly a plane. they may get some things right, but most of the time, they budge things up so bad, you have no idea what they are trying to do. and then all of a sudden, they don’t want to do anything anymore. it is the most annoying thing on the planet, because fixing one thing breaks another and when you get it all looking good in internet explorer and then go back and open up the same page in firefox (my personal favorite and most likely the favorite browser of any self-respecting web designer / aficionado) it looks totally whacked and nothing is where it is supposed to be.

and that’s not even considering the dinosaurs out there, who just absolutely have to have thier netscape communicator 4.75, which has almost no current standards support and what it does support (obsolete and completely annoying things like ‘blink’) it supports badly or is no longer a web standard.

but that’s okay, i figure anybody using web browsers older than the wheel are probably used to things looking all messed up, or they are too computer illiterate to care.

i eagerly await the release of internet explorer 7 (which has taken several years, because microsoft, in all thier wisdom, thought, “we have the monopoly on web browsers, why fuck with it?”. that is, until firefox started taking thier precious users and microsoft just HAS to have the monopoly) because that will mean (hopefully) that interent explorer will finally have decent web standards and png support and i won’t have to keep writing several versions of the same page just to get it to look right everywhere. (but hopefully it will still be subject to the same css hacks, so in case it does mess something up, i wont have to rewrite everything to fix it.)

now all we need is to kill off the dinosaurs and we’ll be all set.

moonshine skin finished

now you have no excuses for not using my skin on your desktop.

the skin has a clock with the background of the clock being the current phase of the moon. the skin works on both light and dark backgrounds, and is super easy (no editing required) to install. so there ya go, no excuses.

you can still download rainmeter from rainy’s site: download
and you can get my new skin from here: download

here is a preview image of the clock