Archive for September, 2010

Postgresql: Postgresql Commands Cheat-Sheet

Sunday, September 19th, 2010

PG Tools

  • pg_dump dbname > backupfile: Backup as a sql file
  • psql dbname < backupfile : restore


su - postgres
psql mydb

Create Db

su - postgres
createdb DBTest

PSQL Commands

  • h : SQL help
  • ? : psql help
  • q : quit
  • l : show databases
  • d : show tables
  • d tablename : show columns
  • c dbname : connect to db
  • ! : switch to OS shell mode (very useful on Mac OS where you start on the SQL shell)

SQL Commands


Backup & Restore Database

Backup:  $ pg_dump {source_db} -f {dumpfilename.sql}

Restore: $ psql -d {desintation_db} -f {dumpfilename.sql}

Note: on Mac OS X, the command prompt need to be started from the application folder or from pgAdminIII, and then, type “!” to switch to command shell, and then, go to /Library/PostgreSQL/8.4/bin to find the psql and pg_dump scripts

How to backup and restore postgresql

Related Links

CSS: iPad / iPhone Back button in CSS3

Saturday, September 18th, 2010


<button href="#" class="back"><span></span>Back</button>


.button {
	color: #fff;
	text-decoration: none;
	display: inline-block;
	padding: 4px 10px;
	-webkit-border-radius: 5px;
} {
 background-image: -webkit-gradient(linear, left top, left bottom,
	 color-stop(0.5, #303749),
	 color-stop(0.5, #121a2e),
 border: solid 1px rgba(79, 79, 79, 0.75);
} {
	background-image: -webkit-gradient(linear, left top, left bottom,
		color-stop(0.5, #4286f5),
		color-stop(0.5, #194fdb),

.button.back {
    position: relative;
    padding-left: 5px;
    margin-left: 8px;

.button.back > span{
       display: block;
       height: 20px;
       width: 20px;
       background-image: -webkit-gradient(linear, left top, right bottom,
              color-stop(0.5, #303749),
              color-stop(0.5, #121a2e),
       border-left: solid 1px rgba(79, 79, 79, 0.75);
       border-bottom: solid 1px rgba(79, 79, 79, 0.75);
      -webkit-transform: rotate(45deg);
      -webkit-mask-image: -webkit-gradient(linear, left bottom, right top,
              color-stop(0.5, transparent),
       position: absolute;
       left: -10px;
       top: 2px;


Source: Create Back & Next Buttons with CSS3

Mobile: Touch and Mobile HTML / h Frameworks

Friday, September 17th, 2010
(feel free to add more in the comment, I will add them here)

JavaScript: Generate UUID and GUID

Thursday, September 16th, 2010
function S4() {

   return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
function guid() {
   return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());


'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
    return v.toString(16);

Source: Stackoverflow: How to create GUID and UUID in Javascript



Math.uuid() // RFC4122 v4 UUID

Math.uuid(17) // 17 digits, base 62 (0-9,a-Z,A-Z)

Math.uuid(5, 10) // 5 digits, base 10

Math.uuid(8, 16) // 8 digits, base 16

CSS3: Transition Callback and detecting transition support

Wednesday, September 15th, 2010

Transition end callback

     function( event ) {
         alert( "Finished transition!" );
     }, false );

Note: on the newest Firefox use “mozTransitionEnd”

Source (Stackoverflow)

Detecting if browser supports transition

    var div = document.createElement('div');
    div.innerHTML = '<div style="-webkit-transition:color 1s linear;-moz-transition:color 1s linear;"></div>';
    cssTransitionsSupported = ( !== undefined) ||
 ( !== undefined);
    delete div;

Source (Razorfish)

iOS: NSURL with UIWebView

Wednesday, September 15th, 2010

Loading from a file from the Main Bundle (in a folder)

NSString *urlString = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"web"];
NSURL *url = [NSURL fileURLWithPath:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[webview loadRequest:urlRequest];

Loading from a URL

NSString *urlAddress = @"";

//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];

//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the request in the UIWebView.
[webView loadRequest:requestObj];

CSS: Css3 Gradient with Stops generator

Monday, September 13th, 2010

CSS3 Gradient Generator

Pics: Tileable Icy and Watery Phothoshop Patterns

Monday, September 13th, 2010

Icy and Watery Patterns

Pics: Tips and Tutorials links to build a color palette

Saturday, September 11th, 2010

OSX: Mac Color Picker as an App and HTML HEXA color extension

Friday, September 10th, 2010
  • Start AppleScript Editor (Applications -> AppleScript Editor)
  • Enter text “choose color” in the script
  • Save file as “” (select “Application” as file format)
  • Installa HexColorPicker from LuckySoftware
  • Double click on the
Source: Mac OS Hints – Make the OS X Color Picker into an Application
Note: while this is a nice little trick, go to Utilities > DigitalColor Meter (very cool tool which makes this little trick useless)