sarathonline.com/blog | Trouble viewing this page? Give Feedback .
Try my blog on: Ajax Version
Search

Friday, June 17, 2011

MySql Copying Table Structures.

Some times you need to copy only table structures across databases. This article describes two ways of doing it.

If the whole database schema need to be exported, mysqldump is very effective. A --nodata flag will dump all tables' schema.

Like this.

mysqldump --nodata -p -u username databaseName

But if you want to copy a specific table, individually, you could use "create table like" feature. You could create it even from a different database. However it must be on the same mysqld instance.

Like this.
create table newtable like oldtable;
--Or from a table in other database
create table mytable like otherdatabase.tablename;

Tuesday, June 14, 2011

Developing Userscripts for Chrome (caveats)

To develop Chrome extensions, crx is the best way. But the user scripts that are developed in general for Greasemonkey can also be delivered for Chrome, if a few easy rules are followed.

1. @required and @resource don't work.

By default, atleast for now, These two Userscript metatags donot work on Chrome. If you need to load a js file, instead of using @required - try to use document.createElement. Similarly with @resource.

2. Some GreaseMonkey helper methods don't work or are restricted.

Methods with GM_ prefix from userscript api may not work. Particularly, unsafeWindow, GM_registerMenuCommand, GM_setValue, or GM_getValue are not supported. GM_xmlhttpRequest will work but not only on the same domain.

3. @includes are not shown while installing.
This may not be a deal breaker for developers, but sure is for users. The patterns used in @include is not shown while installing. Instead a generic message is shown as below. This message may scare the users away.

image

To over come this, add @match and show the @include pattern there. The message window pics up the domain portion of the pattern.

image

This actually can be used maliciously. A developer may install a script with a different include pattern and show a different match pattern, there by luring the users to install a malicious script. Although Chrome follows the @include pattern to add script to the page. Just the installation window pops open with @match pattern. Please use this for responsibly.

Here is comments from The Chromium source that explains the reasoning, valid/invalid patterns @match can take:
// Examples of valid patterns:
// - http://*/*
// - http://*/foo*
// - https://*.google.com/foo*bar
// - file://monkey*
// - http://127.0.0.1/*
//
// Examples of invalid patterns:
// - http://* -- path not specified
// - http://*foo/bar -- * not allowed as substring of host component
// - http://foo.*.bar/baz -- * must be first component
// - http:/bar -- scheme separator not found
// - foo://* -- invalid scheme
// - chrome:// -- we don't support chrome internal URLs
//
// Design rationale:
// * We need to be able to tell users what 'sites' a given URLPattern will
//   affect. For example "This extension will interact with the site
//   'www.google.com'.
// * We'd like to be able to convert as many existing Greasemonkey @include
//   patterns to URLPatterns as possible. Greasemonkey @include patterns are
//   simple globs, so this won't be perfect.
// * Although we would like to support any scheme, it isn't clear what to tell
//   users about URLPatterns that affect data or javascript URLs, so those are
//   left out for now.

Sunday, June 12, 2011

Google: Green Fleet.

Here is one company committed to Green alternative fuels and reducing carbon foot print. Google is no less a real life research lab. Plugin Electric cars are the fastest way to remove dependency on oil. They may eventually become energy hogs (if everyone will buy these), but for the moment, they are a viable solution. Advances in renewable energy may make electric even cheaper, easy to produce - until then, its only time for ideas.. like these..



Wednesday, June 08, 2011

Reduce Yahoo mail neo header space for more room


<


The newer Yahoo mail beta (neo) really is a faster UI. However, The large header with room that is unused is a let down.  This one time, it appears that, Yahoo did not take into account the importance of real estate on top of the page, hitting User Experience. Reduce Yahoo mail neo header space for more room by installing SarathOnline's "Spacier Yahoo Neo" userscript below

Install YNeo UserScript
by SarathOnline

Before:
image

After:
image


The user script is fairly simple. You could install it in Firefox as a Greasemonkey script. Or install it on chrome directly. If you are new to UserScripts, follow these instructions to install them on your browser.

Be assured, it has no malicious code. All it does is install a correcting css to the document. The css file is located here.  And the script itself.
(function(){
var d=document,sid='__sar__yneo', fn='http://www.sarathonline.com/dyn/sfs/userscripts/ymail/yneo.css';
if(d.getElementById(sid)) return;
var s=document.createElement("link")
s.setAttribute("rel", "stylesheet")
s.setAttribute("type", "text/css")
s.setAttribute("href", fn)
s.id=sid
d.getElementsByTagName("head")[0].appendChild(s);
})();

Monday, June 06, 2011

Installing Userscripts in Firefox, Opera, Chrome

Want to install a userscript on your browser. Go no further. Here are simple instructions and caveats for installing Userscripts in Firefox, Opera, Chrome. If you want to author your own scripts, here is a beginner's tutorial.

Thursday, June 02, 2011

Writing your first UserScript, Template as a beginner's tutorial

UserScripts are fun, useful and often productive. A lot of sites have small improvements you think could add a lot of value. And just because you are not the author of the site, you need not give up. With some basic javascript skills, you could write a userscript, install it on your browser, and make the site behave.

© SarathOnline.com 2000-'11