Archive

Archive for the ‘Mac’ Category

TextMate Sql Formatter Command

October 27th, 2009

Recently, I am doing some heavy database migrations, so I spend a lot of time on playing with SQL again. It’s fun as always. But there are some SQL files are quite long and messy. There is no problem on running, but it’s really painful to look at and do any changes.

So I went out and tried to find any SQL Formatters. There are quite a few and I’ve tasted them as many as I can.

At the end, I found myself really enjoy using Instant SQL Formatter from Gudu Software. It has a free online sql tidy tool and it’s very powerful:

Instant SQL Formatter is a free online sql tidy tool, actually, it not only can beautify your sql but also can turn your formatted sql into html code, so you can post coloured sql code in your blog, forum,wiki and any website easily. In addition to beautifying SQL code, this sql tool can translate SQL code into C#, Java, PHP, DELPHI and other program languages. Another useful feature is find out all database objects such as table, column, function in sql by selecting output format to list database object.

Here is the Free online Tool and here are some examples you can see. Quite impressive! To format your SQL, you just need paste the sql in the textarea, choose the database and output format then press “Format SQL”, you’ll get the result right away.

Every SQL file looks great now. But after tens of copy & paste and copy & paste between TextMate and browser, it feels not as smooth as I want. I think I should find a better way.

Gudu software does provide some desktop version even add-ins, sadly there are all Windows based. It’s not a option for me.

After reading the page source of their free online tool, here is the result:

#!/usr/bin/env ruby

require 'net/http'

url = 'http://www.dpriver.com/cgi-bin/ppserver'
url = URI.parse(url)
http = Net::HTTP.new(url.host, url.port)

query = "<sqlpp_request><dbvendor>mysql</dbvendor><outputfmt>SQL</outputfmt><inputsql>#{ENV['TM_SELECTED_TEXT']}</inputsql><formatoptions><keywordcs>Uppercase</keywordcs><identifiercs>Lowercase</identifiercs><functioncs>InitCap</functioncs><lnbrwithcomma>after</lnbrwithcomma><liststyle>stack</liststyle><salign>sleft</salign><quotechar>\"</quotechar></formatoptions></sqlpp_request>"

header = {
  'Referer' => 'http://www.dpriver.com/pp/sqlformat.htm',
  'User-Agent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Firefox/3.0.1'
}

resp, data = http.post(url.path, query, header)

puts resp.error! unless data
formatted_sql = data[/<formattedsql>.*<\/formattedsql>/m].gsub(/<\/?.*>/, '')

puts formatted_sql

Download TextMate SqlFormatter Command

How to install?

After save to your own disk, unzip it, just open those tmCommand files and add them into your TextMate. The shortcut key has been set to Command+Shift+F for now.

As you can see there are two tmCommand files. The “SQL Formatter – Stack” will format you sql with every fields has its own line, the “No Stack” one will put all the fields into one line. Try them and you’ll see the difference.

How to use it?

Open TextMate,  select the SQL query you want to format and press Command+Shift+F. The beautiful formatted SQL will replace the selected SQL “instantly”!

Requirement?

The command is using free online Instant SQL Formatter, so the internet is required.

What’s next?

As I said before, SQL Pretty Printer is really powerful. I really should create a complete TextMate Bundle instead of just one command. But before doing this, I should get the permission from them now.

Any update will be posted here, hopefully soon.

Enjoy the SQL Formatter Command and stay tuned for more.

Database, English, Mac, OS X, Ruby, TextMate , , , , ,

TextMate Shortcuts Desktop

August 23rd, 2009

I’ve been using this TextMate shortcuts Desktop Wallpaper for two years already, it’s really helpful, no matter how long have you used TextMate. And, did we missed anything new about TextMate in the past two or three years? I don’t think so.

Snow Leopard is here already, but we still know nothing about TextMate 2.

Download ↓

TextMate Keyboard Shortcuts Desktop Wallpaper 1280 x 800

TextMate Keyboard Shortcuts Desktop Wallpaper 1920 x 1200

Source: Scott Boms

Apple, Mac, OS X, Ruby, TextMate , , , ,

Coda is on sale for three days!

May 27th, 2009

Coda is one of my favorite Editor/Site Manager/Terminal tools. It has everything I need for the web development.

Coda

Anyway, even I get no benefits from promoting them, I still want you to know:

Yes! Coda, Transmit, CandyBar, and Unison are 50% off. It’s never happened before, and it’ll probably never happen again. Serious.

  • Prices are only valid from 12:01 AM PST May 27th to 11:59 PM PST May 29th.
  • Enjoy these apps today and lock in a discount towards any future paid updates.

Enjoy!

Apple, English, Mac, OS X , , , ,

WWDC 2009, I am coming!

April 24th, 2009

Just bought my ticket for WWDC 2009!

WWDC 2009 Count Down

Today is the last day for early bird price (Saving $300). I got it in Canada for CAD $1699. Really not cheap.

Funny story, I thought I can buy it cheaper in US store, but it turns out even worse. The final price will have tax be added onto original price USD $1295, which will be USD $1414 in total. And USD $1414 is about CAD $1728 as of today.

Look forward to it!

WWDC 2009

Apple, English, Mac, OS X, iPhone , ,

MacHeist 3 Bundle

March 25th, 2009

Just bought mine, you should get it before it’s gone! Believe me.

MacHeist 3 Bundle

Apple, English, Mac, OS X, Software ,

iHome -Releasing your Home Button and more

February 22nd, 2009

if you want to feel the power of the capacitive touchscreen we’re using, why not use the iphone exclusively without the home button?  Apple did not provide a way to do so, but now we got it!

Usage

  • Slide Area

  • Home State

1. Short slide from right to left -> Jump to the first page of your apps, just like single press on Home button
2. Long slide from right to left -> Open iPod Control Dialog if it’s playing, like double press on Home button
3. Short slide from left to right -> Open Power Dialog, which includes Lock, ReSpring, Reboot, Power Off and other options
4. Long slide from left to right -> Lock Screen
5. Long press 5 seconds to trigger Screenshot

  • Application State

1. Short slide from right to left -> Open Exist Dialog, which includes back Home and iPod control if it’s playing
2. Long slide from right to left -> Quit from the current app, like single press on Home button
3. Short slide from left to right -> Open Power Dialog, which includes Lock, ReSpring, Reboot, Power Off and other options
4. Long slide from left to right -> Lock Screen
5. Long press 5 seconds to trigger Screenshot

Requirement

  • Jailbroken iPhone
  • Cydia

Links

Author mj(马骏)’s Home page

iHome 0.2 Release page (in Chinese)

Bug Report page (in Chinese)

Apple, English, Mac, OS X, iPhone ,

Mini vMac – Mac Plus emulator for iPhone

February 22nd, 2009

Features

  • 4MB Mac Plus
  • Full screen or scrolling
  • Full simulated keyboard
  • Sound

Requirements

  • Jailbroken iPhone or iPod Touch
  • iPhone OS 2.x
  • Mac Plus ROM image
  • Mac disk images

More Links:

Mini vMac

Source Code

Apple, English, Mac, iPhone

Time to say Goodbye to QuickSilver?

January 12th, 2009

QuickSilver is our favorite application on the Mac. The great developer of this awesome tool – Nicholas Jitkoff has made it opensource and went to work for google more than a year ago.

Today, the same Nicholas Jitkoff from Google has introduced The Quick Search Box. Which I would believe is a replacement for QuickSilver from now on.

The good things are:

  1. Same awesome developer and more
  2. Still opensource
  3. Google

Go ahead grab it for yourself at: http://code.google.com/p/qsb-mac/

Some tips:

  • If you have hard time on adding Google Account, please try capitalizing the first letter of your username and domain name, such as ‘Libin.Pan’ and ‘@Gmail.com’

Apple, English, Mac, OS X, Software ,

25 Years of Mac

January 12th, 2009

25 Years of Mac: From Boxy Beige to Silver Sleek (WIRED MAGAZINE: 17.01)

25 Years of Mac.
Click on the image to see the full-sized timeline of Apple products.

Apple, English, Mac ,

Mac Giving Tree rewards you with free applications

December 25th, 2008

Hope you can see this before it’s gone.

At least you should get 1Passwd for free for today here. It was the first software I’ve bought after I’ve been maced.

English, Mac, OS X, Software