Thursday, June 13, 2013

A simple way to detect mouse-click on a page element and opening a popups

document.onclick = document.getElementsByTagName('td').onclick = function(e)
{
  if (e.target.tagName.toLowerCase() == 'td' && e.target.parentNode.id != '')
  {
    document.getElementById('popupbg').style.visibility = "visible";
    document.getElementById('popup').style.display = "inline";
    document.getElementById('popupresults').style.display = "inline";
    /* On this line you can put some logic for getting values and sending them to some PHP script
    For example 'e.target.parentNode.id;' can be used as SQLite table row variable for
    SELECT/INSERT/DELETE queries
    Another example is using 'document.getElementById('popupresults').innerHTML' for visualising
    the answer of the PHP script */
  }
};

This small snippet works on Firefox and Chrome (not tested on IE and Opera) and does the following:
  • detects the tag of a clicked element
  • checks if its parent has an id (usefull for AJAXing values from some HTML table to PHP) and sends the data using your home-brew AJAX function
  • reveals divs that hold popup data (div 'popup', div 'popupbg' for disabling clicking on background elements, div 'popupresults' for visualising the PHP answer; all of them can use 'display: none' or 'visibility: hidden' CSS attributes as default visual state)

Wednesday, March 20, 2013

Vintage3D.org - cool site for benchmarking old videocards

Vintage3D is a web-site, dedicated to remember and find new information about first generation of gaming 3D cards.

Short review from the creator:

This page is to remember and find new information about first generation of gaming 3D cards. What is first gen? Well there are many definitions, common one would probably define three early generations of early 3d gaming chips: first geometry accelerators like Millennium or Imagine 128 II, than first texture mappers like Gaming Glint or Virge and finally "mature" architectures like Verite and Voodoo. I want to cover all of this range from very first accelerators (if possible) to anything released before Voodoo2. From there on 3d chipsets were having more and more comprehensive reviews and are therefore well known. I want to show barely tested chips in extensive collection of real games. The benchmark suite currently consist of around 40 games from 1996 to 1999 and 2-3 artificial benchmarks. Reviews are not done from user perspective. I am trying to examine and compare performance, which means no proprietary APIs. Cards are tested with latest or best available drivers and in a system saturating video accelerators with power unreachable at that time. In the future I might build a low end rig to examine performance in budget PC. Main purpose is to learn about chips which where not reviewed extensively in ways we are used to now. In fact, information about gaming performance of most first generation cards is remembered almost only through word of mouth. I am not professional hardware reviewer, neither graphics technology expert, but I will try to do my best to reveal real capabilities of vintage 3D cards.
My benchmarking practices are definitely not the best. I don't run the tests more times unless the results seems off. I simply don't have enough time. Also most of the old boards lack the option to disable vsync despite trying various tweakers. Because of this I run all the tests with vsync, unless the application itself can disable it. This shouldn't be much of a problem with some high speed CRT, but I have only LCDs now. Therefore 75 Hz is used. Still the results have value, since vsync is almost always on by default and most of users don't change video settings. The performance corresponds with user experience, however speed differences between cards can be skewed.
 

Thursday, March 14, 2013

Today is a great day ...

Just faced a problem that pushed me to the dark side. Long story short my small project tracking system on OpenWRT router doesn't work anymore cause important for it php extension sqlite can't use the database file. Some lock-ups due to newer libsqlite3 version which is not compatible with php 5.4 version for OpenWRT, but required for subversion-server. I don't know what to say more (lost at least 1-2 hours to understand what's the problem), but installed the original firmware and did the right thing - got a new 'real' server based on Ubuntu Server 12.10

Sunday, February 24, 2013

Fixing the 'SQLite compiled ...' problem on OpenWRT

Some users maybe noticed that after installing subversion server on their OpenWRT device (mine is Tp-Link TL-WR1043ND with ATTITUDE ADJUSTMENT (bleeding edge, r31214)) they cannot import or export files to it due to old libsqlite3. So, to fix it, just update the library with the following commands:
opkg update
opkg upgrade libsqlite3

Then stop and start the server with:
/etc/init.d/subversion stop
/etc/init.d/subversion start

There you go - no more sqlite error when transferring files :)

Important: It is possible to face the 'General error 5: database is locked' even when svn server is removed. Probably the reason is somewhere in PDO and usage of newer libsqlite3 version ... Doh

Friday, February 1, 2013

The SQLite Amalgamation and your C++ app are friends ...

... NOT!

  The amalgamation is a single C code file, named "sqlite3.c", that contains all C code for the core SQLite library and the FTS3 and RTREE extensions. This file contains about 110K lines of code (65K if you omit blank lines and comments) and is over 3.8 megabytes in size.

Corresponding to information from http://www.sqlite.org/crew.html , we can find that around 36666.666...7 lines (averaged) from the code are dedicated to each one of the devs. I don't know if there are more devs working on SQLite and I don't care too much, but have a question - we are in year 2013, so why not "sqlite3.cpp"? And why not implemented SOCI library as part of SQLite API?

Now I'm going to think how to embed sqlite3 dll in the executable. Wish me luck!
Edit: One simple solution to statically link sqlite library is to add the files from amalgamation package to 'include/sqlite/' dir of your IDE, add file sqlite3.c to your project and add '#include <sqlite/sqlite3.h>' into 'main.cpp' or whatever source file you choose in your project.