Free Laundry
-
Apparently a lot of apartment buildings have coin operated laundry machines
in the basement. And guess what? You can order a key to unlock the payment
me...
PHP Promotion
I am two weeks into my PHP Programming college course. I am writing small PHP code snippets in my HTML files now. To run the code on my machine, I decided to install WAMP. This gave me automatic installations of Apache, MySQL, PHP, and so on.
To start with, I am just dropping HTML files with PHP code into the root Apache web server. That way I can access them via localhost using my browser. As soon as I started making changes to my PHP code to fix bugs, I found some annoying behavior. I click refresh in Internet Explorer. However the browser just shows the results from the old PHP code.
I eventually found a work around. I could click the Back button in IE, then the Forward button, and finally Refresh would work. That was just too many steps to see the latest output from my new code. I was using Internet Explorer 9. But I doubt that version had anything to do with the problem.
I emailed my instructor. He told me to see him after class. Doh. There he walked me through some settings to jiggle in IE. Specifically I chose Internet Options from the Tools menu in IE. Then I clicked the Settings button under the Browsing History group. There I clicked the radio button that said "Every time I visit the web page" under the "Check for new versions of stored pages" label.
Turns out the default value of "Automatically" does not check for new versions of stored pages. I found this to be a weird location for such an option. But I am just glad that every time I click Refresh, IE actually does refresh my browser with a new run of my PHP code.
JavaScript Library Performance Penalty
Just checked out a deck by Nicholas C Zakas. He shares his insight in making modern web pages load fast. Apparently this is not rocket science. These days a lot of JavaScript library code is downloaded before the page finishes loading. Not all of that code is required up front. You should just download what you absolutely need on page load. Then grab other JavaScript library code on demand. Why didn't I think of that LOL?
Luckily I do not depend on heavy JavaScript libraries in my own code. Heck. I sometimes don't even use jQuery. Yes that is a recipe for pain. But sometimes you got to roll with just your own code. Makes for a quick page load time. You are in full control.
Making JavaScript Fast
The good folks over at Mozilla have posted many tips on how to make JavaScript fast in Firefox. Many of these ideas can speed up JavaScript on any browser. One interesting point was to avoid a lot of local storage calls. Otherwise your main thread gets blocked slowing everything down. That makes sense. Instead you should access a cache of local storage data that is held in memory. Nice.
XSL Plus Local Links
We are coming to the home stretch of my XML college class. The current topic of interest is the eXtensible Stylesheet Language. At first XSL seemed a bit confusing. Like XML Schema, it was not a simple topic if you don't know what the heck is going on. Luckily we got a few homework assignments that are driving the points home.
My latest chore was to produce a list of unique cities from our big file of XML data. No trouble. I put together a little template that compared the current node to the preceeding ones. Any dups got culled, leaving me with a unique list. Simple to put it in order with too. We also needed to show all the raw data, grouped and sorted by city. Another template took care of that in short order.
Next came what seemed to be the tricky part. The unique city listing needed to be comprised of links that took you to the section in the raw data there people from that city are listed. I figured I needed a link to a local in my HTML file. Just need to generate an ID, and reference that ID. And what better a way to generate these anchors? XSL templates of course.
I wonder how some of my other classmates are doing. Some of them got stuck in the XML Schema assignments and never came out. I just hope they know their HTML. It is a requirement for this course.
My latest chore was to produce a list of unique cities from our big file of XML data. No trouble. I put together a little template that compared the current node to the preceeding ones. Any dups got culled, leaving me with a unique list. Simple to put it in order with
Next came what seemed to be the tricky part. The unique city listing needed to be comprised of links that took you to the section in the raw data there people from that city are listed. I figured I needed a link to a local in my HTML file. Just need to generate an ID, and reference that ID. And what better a way to generate these anchors? XSL templates of course.
I wonder how some of my other classmates are doing. Some of them got stuck in the XML Schema assignments and never came out. I just hope they know their HTML. It is a requirement for this course.
Almost a Hoodie Ninja
I just read some info on the Hoodie library. This thing claims to let you write web apps quick. One fun thing was that it stores stuff locally, and can work even if you are online. A lot of the sample code looked positively simple. Can this possibly work? I don't know. But it has my interest.
Then I came to the following declaration:
Hoodie is currently a developer preview. Some features are missing, some things might change, there's a lot of optimization to be done. Don't use this for production.Oh snap. That did not instill confidence. I guess it is nice to get an early look at what they might have going. But I don't fool around much. I write code that I want to ship now. Perhaps I should wait and see how Hoodie pans out. Too bad. It seemed pretty cool.
elementFormDefault
I was working on creating a compound XML Schema document. There was a main xsd file which imported two other xsd files. The problem was in my instance file. I tried to used a prefix for some tags. This worked for tags that were global in the imported xsd files. However the local elements with prefixes did not validate. What the heck?
At first I thought I specified the namespace incorrectly. That lead to nowhere but more problems. I was stumped. When in doubt, do some Googling I always say. In fact, I went back to some example code that I found in a prior Google search. There were some differences between my code and the examples.
I decided to trace down one specific difference. The XML Schema in the examples had an elementFormDefault="qualified" on the top level schema element of the xsd file. As soon as I added that attribute with the qualified value, my problems were solved. I should have known this was related to my issue. Hello? I am trying to qualify local elements with a prefix (to indicate the namespace).
I had seen this attribute before. Just had no idea what it meant. Just goes to show that you need to work through some examples to gain true understanding. I wonder if anyone else in my XML college class is figuring this stuff out?
At first I thought I specified the namespace incorrectly. That lead to nowhere but more problems. I was stumped. When in doubt, do some Googling I always say. In fact, I went back to some example code that I found in a prior Google search. There were some differences between my code and the examples.
I decided to trace down one specific difference. The XML Schema in the examples had an elementFormDefault="qualified" on the top level schema element of the xsd file. As soon as I added that attribute with the qualified value, my problems were solved. I should have known this was related to my issue. Hello? I am trying to qualify local elements with a prefix (to indicate the namespace).
I had seen this attribute before. Just had no idea what it meant. Just goes to show that you need to work through some examples to gain true understanding. I wonder if anyone else in my XML college class is figuring this stuff out?
Compound Schema Document
I went to my XML college class last week. We were talking about using namespaces in XML Schema. The instructor showed me a compoud XML schema document. It referenced multiple namespaces, importing different xsd files. Fair enough. Then he showed me the corresponding instance file. Now this thing was referencing the multiple xsd files as well. WTF?
So I asked why both the instance and main xsd file needed to reference the other xsd files. That did not seem to make much sense. It seemed like overkill. My instructor told me that a lot of things in XML Schema don't make sense. In fact, he told me that it might make more sense if I drank some whiskey. LOL.
Okay. My instructor is good in that he usually backs up class presentations with some homework. I was struggling to get this to work. It needed to display in a browser with some CSS. That part worked fine. Then I needed this to validate in XML Spy. Oh oh. I tried to follow the handouts. But things were just not working.
When I get into trouble like this, I use Google to find web sites to help me dig myself out. I found a great resource from Liquid Technologies. They show how to make a compound schema document. That document references the other XSDs. The instance document only needs to reference the main xsd file. Now that made a whole lot more sense. There was also Definitive XML Schema, although those examples were including other xsd files.
P.S. The funny thing is that I actually own a paper copy of Definitive XML Schema. The book set me back 60 bucks. It is some dry reading. However being able to Google a specific topic from the book seems strong.
So I asked why both the instance and main xsd file needed to reference the other xsd files. That did not seem to make much sense. It seemed like overkill. My instructor told me that a lot of things in XML Schema don't make sense. In fact, he told me that it might make more sense if I drank some whiskey. LOL.
Okay. My instructor is good in that he usually backs up class presentations with some homework. I was struggling to get this to work. It needed to display in a browser with some CSS. That part worked fine. Then I needed this to validate in XML Spy. Oh oh. I tried to follow the handouts. But things were just not working.
When I get into trouble like this, I use Google to find web sites to help me dig myself out. I found a great resource from Liquid Technologies. They show how to make a compound schema document. That document references the other XSDs. The instance document only needs to reference the main xsd file. Now that made a whole lot more sense. There was also Definitive XML Schema, although those examples were including other xsd files.
P.S. The funny thing is that I actually own a paper copy of Definitive XML Schema. The book set me back 60 bucks. It is some dry reading. However being able to Google a specific topic from the book seems strong.
Beware JavaScript Math
I am getting heavy into my latest JavaScript project. I am writing a rogue-like game for the web browser. The dungeon is a two dimensional representation. Therefore I am using 2D arrays. That's fine, because JavaScript natively supports them. I am drawing all kinds of ASCII art for the layout of the maze for the dungeon.
For some shapes, I need to do some math to come up with the coordinates. This is nothing fancy. I just iterate through some loops, and do some computations such as add/subtract/multiply/divide. In the middle of development, I found the browser complaining about my computations. What was up?
Some debugging showed me that although my operands were whole numbers, they got converted to a fractional output when I divided. Then I would use the result as an index into an array. That did not turn out too well. Turns out I had to do truncation of the decimal portion using the Math.ceil() function.
There was one other HTML gotcha I encountered late last night. I am using a proportional font to make sure all the cells of the dungeon lined up. However I was having some trouble with the spaces. I thought I would be saved by the proportional font. However I had forgot that the browser ignores the whitespace, trimming batches of spaces down to a single space. I needed to add the non-breaking space entity in there to preserve the spaces.
For some shapes, I need to do some math to come up with the coordinates. This is nothing fancy. I just iterate through some loops, and do some computations such as add/subtract/multiply/divide. In the middle of development, I found the browser complaining about my computations. What was up?
Some debugging showed me that although my operands were whole numbers, they got converted to a fractional output when I divided. Then I would use the result as an index into an array. That did not turn out too well. Turns out I had to do truncation of the decimal portion using the Math.ceil() function.
There was one other HTML gotcha I encountered late last night. I am using a proportional font to make sure all the cells of the dungeon lined up. However I was having some trouble with the spaces. I thought I would be saved by the proportional font. However I had forgot that the browser ignores the whitespace, trimming batches of spaces down to a single space. I needed to add the non-breaking space entity in there to preserve the spaces.
JavaScript Arrays
I am taking a week off from work to do some training. This will be an independent study. Time to put my JavaScript studies to work on a real project. I needed to represent the floor space of a dungeon. Easy enough. I would just roll out a two dimensional array. I am sure I had done this before. So I kicked out some JavaScript code:
var my_2D_Array = new Array(Array());
Slick right? I got an array of arrays. In other words, I should have a two dimensional array. Wrong. When I tried to run my code, it bombed when trying to access elements in this array. What was up? It took a while to figure it out. I should have just made sure I fully understand two dimensional array.
The outer array will be the container for the rows in my array. I need 25 rows total. Therefore I need to add two items to that outer list. In my code, I was only added one item to the list. Thus I was only getting one row. I needed to add 25 different arrays to my outer array. I did this with a loop. Then I was good to go.
Since the out array contains the rows, I need to use the vertival y value to index into the outer arrray. Some my code will look like this:
my_2D_Array[y][x] = 'x';
Yeah. That looks a bit weird. Don't you usually access 2D arrays like arr[x][y]? Well not in JavaScript. I also had a little trouble getting my fonts to appear monospaced. But that is a story for a future blog post.
var my_2D_Array = new Array(Array());
Slick right? I got an array of arrays. In other words, I should have a two dimensional array. Wrong. When I tried to run my code, it bombed when trying to access elements in this array. What was up? It took a while to figure it out. I should have just made sure I fully understand two dimensional array.
The outer array will be the container for the rows in my array. I need 25 rows total. Therefore I need to add two items to that outer list. In my code, I was only added one item to the list. Thus I was only getting one row. I needed to add 25 different arrays to my outer array. I did this with a loop. Then I was good to go.
Since the out array contains the rows, I need to use the vertival y value to index into the outer arrray. Some my code will look like this:
my_2D_Array[y][x] = 'x';
Yeah. That looks a bit weird. Don't you usually access 2D arrays like arr[x][y]? Well not in JavaScript. I also had a little trouble getting my fonts to appear monospaced. But that is a story for a future blog post.
Validation
I am taking a semester long college course on XML. This week we covered Document Type Definitions. I wrote up a DTD for my XML file. Now I was tasked with validating the XML file against it. The browsers did not seem to provide any help. The teacher said we should grab a free copy o XML Spy and get to work.
I tried for a while. All I could find was a 30-day evaluation copy of XML Spy. It seems they used to offer a free scaled down version of the software. I can't find it any more. It was called XML Spy Home Edition 2006, or something of the sort. Altova really wants me to buy a copy of their software.
The problem is that XML Spy costs either $1000 or $500, depending on whether you opt for the enterprise or professional version. I need something more like a lite version. Better yet, I could go for an educational version. No such thing seems to exist. So I checked out the free alternatives. A student has to eat. And you can't eat if you spend a grand on XML validation software.
First up we have XML Copy Editor. This program is released free of charge under the GNU IGPL license. When you first bring up the program, it looks to have a very minimal interface. It almost feels like something you might role out yourself. Next I tried XMLPad. The thing wanted to reboot my computer on install. That was strange. I decided not too, but then the program displayed weird error messages. It has a better user interface than XML Copy Editor.
I have to say that XML Spy seems to have the most intuitive messages when something goes wrong with validation. I also like that it automatically detects when the file you have open gets changed on the disk. You get prompted to reload the file. Not ready to shell out 500 clams for the thing. I don't even know if it is worth having my company buy a copy for me.
Maybe the hard core thing would be to develop a version for myself. That will take a massive amount of time and effort. However the benefit would be that I would be close to an XML expert when I was done.
I tried for a while. All I could find was a 30-day evaluation copy of XML Spy. It seems they used to offer a free scaled down version of the software. I can't find it any more. It was called XML Spy Home Edition 2006, or something of the sort. Altova really wants me to buy a copy of their software.
The problem is that XML Spy costs either $1000 or $500, depending on whether you opt for the enterprise or professional version. I need something more like a lite version. Better yet, I could go for an educational version. No such thing seems to exist. So I checked out the free alternatives. A student has to eat. And you can't eat if you spend a grand on XML validation software.
First up we have XML Copy Editor. This program is released free of charge under the GNU IGPL license. When you first bring up the program, it looks to have a very minimal interface. It almost feels like something you might role out yourself. Next I tried XMLPad. The thing wanted to reboot my computer on install. That was strange. I decided not too, but then the program displayed weird error messages. It has a better user interface than XML Copy Editor.
I have to say that XML Spy seems to have the most intuitive messages when something goes wrong with validation. I also like that it automatically detects when the file you have open gets changed on the disk. You get prompted to reload the file. Not ready to shell out 500 clams for the thing. I don't even know if it is worth having my company buy a copy for me.
Maybe the hard core thing would be to develop a version for myself. That will take a massive amount of time and effort. However the benefit would be that I would be close to an XML expert when I was done.
Subscribe to:
Posts (Atom)