DeutschEnglish

Submenu

 - - - By CrazyStat - - -

22. April 2015

HTML5: why is my comment a ‘bogus comment’!?

Filed under: Uncategorized — Tags: , , , , — Christopher Kramer @ 12:52

I checked the validity of an HTML5 document (using the HTML Validator extension for Firefox, which I highly recommend) and found an error about a “bogus comment”. The comment looked normal:

<!–– some comment ––>

Then I read the HTML5 specification and found out that the bogus comment state instead of the “normal” comment state is entered if after “<!”, the parser cannot find two dashes. I remembered that I had copied the comment from the web and not typed it myself, so I deleted the –– and typed them manually. Looking closely, you can see the difference:

<!–– some comment ––>
<!-- some comment -->

After that, the bogus comment error was gone.

So the reason was that the – signs were not “normal”, but some other characters for longer dashes that look similar. So whenever you see a “bogus comment”, try to type the comment tags yourself…

Hope this helps somebody.

Recommendation

Try my Open Source PHP visitor analytics script CrazyStat.

13. March 2012

sqlite.js: SQLite for Javascript!

Filed under: DBMS,JavaScript — Tags: , , , , , — Christopher Kramer @ 12:01

I just found something quite cool which I thought might be interesting to some of you.

Alon Zaka created emskripten, a LLVM-to-JavaScript converter. It can convert LLVM-bytecode such as provided by compilation from C/C++ code into JavaScript. This approach seems quite cool and it already proved to produce some cool results:

He converted the SQLite-library, which is written in C, into JavaScript. You can find (and fork) the project on github or just try the demo.

The first thing that I was curious about was: How does it store the database file? Well, it creates a new database when you do SQL.open(). But you can pass data to SQL.open(data) to start with a pre-filled database. So I think using this library would normally look like this:

  1. fetch the initial database from the server (e.g using AJAX). At least DB schema and some important data.
  2. open the database with SQL.js
  3. do some operations on the database, mostly SELECTs probably
  4. maybe fetch some more data using AJAX from the server when needed
  5. maybe send some data to the server to save changes using form or ajax

So this would mean we move some more stuff to the client. It would allow us to use SQL on the client side just like we do on the server-side. So we could use the same queries for javascript-based clients on the client and for html-only-clients on the server. (But exposing SQL-queries used in the server might make SQL injection as easy as never before…)

I see two other interesting ways of using this:

  1. In combination with HTML5 local storage – this would allow to store a persistent client-side database that could be accessed using SQL. Sounds pretty cool and the main usage scenario of SQL.js for me.
  2. On the server using node.js – but when I think about it: There are better ways to access a database within node.js, so this is probably only showing that it works, but no real usage scenario.

Tell me what you think about it.