Ivor O’Connor

March 9, 2013

The Universal IDE: VI with SPF13

Filed under: bash, git, howto, html5, IDE, JavaScript, Linux, mint 14 xfce, php, sqlite, ubuntu, vi, vim, vundle — ioconnor @ 4:08 am

This is a youtube video I made on how to install SPF13 on Linux Mint 14 XFCE. I like learning from youtube videos whenever possible. If in the future I want to install SPF13 and something is not how I remember it I can return to this video. SPF13 makes VI into a universal IDE. It works on most if not all OSs including windows and the mac.  Sure if you are working with something like AIX, HP-UX, or some platform that does not have vim installed SPF13 will not be for you. I’d recommend you put in your base .vimrc commands directly into the .vimrc.local file and use them along with SPF13. Picking and choosing what you find works.

UPDATE 2013-03-08: Insert the following line into your .bashrc file before starting to get full colors: export TERM=”xterm-256color”

Advertisements

April 5, 2009

Starting Skeleton, Template, For Sqlite Google Gear Self-Contained Client Apps

Client side applications using google gears for locally storing SQL data are obviously the future. They allow applications to be run on any operating system without coding user interfaces, learning new languages, or managing SQL database daemons/servers. You can start by running the application off a server. But it’s much better to simply download the web page and run it disconnected from the internet. To start the application in the future you simply click on the html file you downloaded.  It is so cool.

Where are all the example sites describing how to use google gears for client side applications though? I’ve looked for starting point skeletons and have found NONE! I believe it is because the subject is new. So I’m publishing my own skeleton. It can be found at http://ioconnor.atbhost.net/google.gears.skeleton.html. I’ll probably upgrade it as time goes on but my skeleton is quite good already. After you read through Google’s tutorials at http://code.google.com/apis/gears/tutorial.html download my code and use it as a starting point for your own project. Don’t reinvent the wheel!

My skeleton is self-contained. There’s no need to download a set of files or update a registry, run an installation script, etc., assuming your environment is complete.

However if your base environment is not complete no problem. The environment is tested to verify the gears addon has already been installed, that javascript is enabled, and that you have an up-to-date browser. If something is lacking you must click “ok” to acknowledge the problem and then your browser takes you to the URL where  the fix is.

I wish I had this easy to use skeleton a long time ago. It makes client side browser applications using SQL easy!

I’m probably going to make quite a few client side browser applications using this template. Having a free interface, sql database, and programming language across all OS platforms levels the playing field so much it can’t be ignored.

Update 2009.04.08: The code was refined yet again tonight. There’s nothing in it that seems to be lacking that can be done better. However please comment on it if there is something more that could be done…

March 23, 2009

SQLite Humorous Cover-Ups Or?

Filed under: sqlite, Uncategorized — Tags: — ioconnor @ 8:54 pm

http://www.sqlite.org/faq.html#q17

Quality assurance in SQLite is done using full-coverage testing, not by compiler warnings or other static code analysis tools. In other words, we verify that SQLite actually gets the correct answer, not that it merely satisfies stylistic constraints…

Uh huh. They go on to say everything is rosy and no errors or warning messages are seen in their own environments. I wonder who wrote this provocative prose? And why.

http://www.sqlite.org/faq.html#q19

Transaction speed is limited by the rotational speed of your disk drive. A transaction normally requires two complete rotations of the disk platter, which on a 7200RPM disk drive limits you to about 60 transactions per second.

Is this from the same author?

Sure would be nice if there were an estimate of when foreign keys and outer joins can be expected. Surely the foreign key question must be their number one FAQ yet it’s not mentioned anywhere on their site.

October 20, 2008

sqlite3

Filed under: cli, pdo, php, sqlite, ubuntu — Tags: , , — ioconnor @ 12:29 am

Google gears uses sqlite for it’s client side database. I’ve never used sqlite so I went to the sqlite website. I naturally downloaded all their documentation to file allowing me to browse it offline. All companies should provide this ability. However the documentation only covered C/C++ and TCL.

I really wanted to use PHP but decided to use C/C++ because an example from their site was ready to go. I copied their example but could not compile it. First it was simply locating the proper sqlite3.h file. This was just the start of many errors so I gave up. If it does not work straight out of the box on the latest Ubuntu then there is something very wrong. I googled for C/C++ examples elsewhere but without luck.

So I tried googling for PHP CLI examples under Ubuntu. Not much luck but there was something close at http://www.litewebsite.com/?c=49#sqlite3 so I snagged it. Here it is, modified to run from the command line, so I don’t have to search for a half decent starting example again:


#!/usr/bin/php -q

<?php
//# Much of this I got from:
//# http://www.litewebsite.com/?c=49#sqlite3
//# http://www.devshed.com/c/a/PHP/Working-with-Prepared-Queries-with-PDO-Objects-in-PHP-5/
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);

function CountFromPage($page) {
try{
$dbh = new PDO('sqlite:pdoTutorial.sqlite3');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//$dbh->beginTransaction();
$statement = $dbh->query('SELECT name FROM sqlite_master WHERE type = \'table\'');
$result = $statement->fetchAll();
if( sizeof($result) == 0 ){ // No database tables found? (Will need to refine this check for pageView table only.)
$dbh->exec('CREATE TABLE pageView(id INTEGER PRIMARY KEY AUTOINCREMENT, page CHAR(256), access INTEGER(10))');
}

// insert page visit in database with a prepared statement
$stmt = $dbh->prepare('INSERT INTO pageView (page, access) VALUES (?, ?)');
$stmt->bindParam(1, $page, PDO::PARAM_STR);
$stmt->bindParam(2, time(), PDO::PARAM_INT);
$stmt->execute();

// get page views from database
$pageVisit = $dbh->quote($page);
$sqlGetView = 'SELECT count(page) AS view FROM pageView WHERE page = '.$pageVisit.'';
$result = $dbh->query($sqlGetView);
$pageView = $result->fetch(); // store result in array
//$dbh->commit();
return($pageView['view']);
}catch( PDOException $exception ){
//$dbh->rollBack();
die($exception->getMessage());
}

}

if (2 != $_SERVER["argc"]) {
echo "\tWrong number of arguments:" . $_SERVER["argc"] . "\n";
echo "\tProper syntax is: \n" ;
echo "\t\t" . $_SERVER["argv"][0] . " page\n";
} else {
$page = $_SERVER["argv"][1];
echo 'Page "' . $page . '" has been viewed '. CountFromPage($page).' times.'."\n";
}
?>

I stuck it into a file called 1.php in my samba bin directory as my starting point. This way the database can be shared…

Here is the output when run:

~/samba/bin$ 1.php 11
Page “11” has been viewed 1 times.
~/samba/bin$ 1.php 11
Page “11” has been viewed 2 times.
~/samba/bin$ 1.php 12
Page “12” has been viewed 1 times.
~/samba/bin$ 1.php 12
Page “12” has been viewed 2 times.
~/samba/bin$ 1.php 11
Page “11” has been viewed 3 times.

Create a free website or blog at WordPress.com.