Archive

Archive for the ‘English’ Category

“Don’t you dare waste your fucking time”

February 9th, 2010

The lovely and amazing performance poet Gabrielle Bouliane performs for the audience at the Austin Poetry Slam.

This would be her last public performance.

Gabrielle was diagnosed with Stage Four Cancer shortly before this video was filmed. Our dear sister fought hard, but she ended her fight January 29, 2010. She was surrounded by family and friends, and her passing was in a very quiet, peaceful room full of love and affection. She was so brave.

Please share this video with everyone you know. I am sure it would tickle her to no end to have this video get as viral as a video can be. Tell the world.

Bunny up!

English, Life ,

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 , , , , ,

Seeing is not believing

October 22nd, 2009

Can you see the squares marked A and B are the same shade of gray?

No way I can believe that, can you?

See the proof on Professor Edward’s page:

Proof of Checkshadow illusion.

English

Rails 2.3 BacktraceCleaner and TextMate

September 23rd, 2009

Start from Rails 2.3, it includes a new class called BacktraceCleaner:

Many backtraces include too much information that’s not relevant for the context. This makes it hard to find the signal in the backtrace and adds debugging time. With a BacktraceCleaner, you can setup filters and silencers for your particular context, so only the relevant lines are included.

Here’s how it works:

bc = BacktraceCleaner.new
bc.add_filter { |line| line.gsub(Rails.root, ”) }
bc.add_silencer { |line| line =~ /mongrel|rubygems/ }
bc.clean(exception.backtrace) # will strip the Rails.root prefix and skip any lines from mongrel or rubygems

Which is simple, great and smart, well, most of the time.

If you are a hardcore TextMate fan, like me, and you like using command+R to run your ruby code/test, you will find you can’t open files by clicking the backtrace list links on the result window. Actually, you still can, but instead of opening the file you want, it opens a new window with a empty new file.

The reason is simple, BacktraceCleaner has a default filter “line.gsub(Rails.root, ”)”. It removes your project path from file full name.

Solution is simple too:

  1. Remove “add_filter   { |line| line.sub(“#{RAILS_ROOT}/”, ”) }” from “vendor/rails/railties/lib/rails/backtrace_cleaner.rb”
  2. Add “Rails.backtrace_cleaner.add_filter { |line| line.sub(“#{RAILS_ROOT}/”, ”) } unless RAILS_ENV == ‘test’” to “config/initializers/backtrace_silencers.rb”

That’s it. Is it a bug for Rails, or not?

English, Ruby, TextMate

Did You Know 4.0

September 18th, 2009

This is another official update from XPlane to the original “Shift Happens” video. This completely new Fall 2009 version includes facts and stats focusing on the changing media landscape, including convergence and technology.

Anyway, if you don’t know, you should know!

English , , ,

Less is better, than tail

July 27th, 2009

I’ve been using tail to watch my log files for years:

tail -f log/production.log

It works great all the time, until you want to search for something, then you have to ctrl+c and open the file in less or vi.

Maybe there is a better way? After some googling, I found less is the answer:

less +F log/production.log

less +F works exactly like tail -f, with more:

  • Simply press ctrl+c to switch to editing model, so you can scroll backward and using any more/vi command, such as /pattern to search
  • Press shift+f again to switch back to tail model

Anyway, just run man less to find some more information.

English, OS X , ,

The Internet in One Graphic

July 21st, 2009

Thinking

June 23rd, 2009

If you think you are beaten, you are

If you think you dare not, you don’t,
If you like to win, but you think you can’t
It is almost certain you won’t.

If you think you’ll lose, you’re lost
For out of the world we find,
Success begins with a fellow’s will
It’s all in the state of mind.

If you think you are outclassed, you are
You’ve got to think high to rise,
You’ve got to be sure of yourself before
You can ever win a prize.

Life’s battles don’t always go
To the stronger or faster man,
But soon or late the man who wins
Is the man WHO THINKS HE CAN!

Walter D. Wintle

English

Why we need upgrade to iPhone 3G S?

June 22nd, 2009

Here are the reasons beside of the awesome 3m camera:

iPhone OS 3.0 Feature iPhone iPhone 3G iPhone 3G S
Cut, Copy & Paste
Landscape keyboard
Spotlight search
Parental controls
Shake to shuffle
Voice Memos
Peer-to-peer connectivity1 2
MMS3  
Stereo Bluetooth  
Internet tethering4  
Video recording    
Compass    
Voice Control    
Accessibility    
Nike + iPod    

Notes:

1. Peer-to-peer connectivity requires compatible applications, which can be downloaded from the App Store when available.
2. The original iPhone does not support using Bluetooth for peer-to-peer connectivity. It can use Wi-Fi and cellular data networks for peer-to-peer connectivity.
3. MMS is not available in all areas; fees may apply. See your carrier for availability.
4. Internet tethering is not currently offered in the United States and some other countries. See your carrier for availability.

Apple, English, iPhone , , ,

WWDC 2009

June 11th, 2009

I believe you already noticed the twitter updates on the sidebar. Yes, I am attending WWDC 2009 this week. It is a great conference and I believe you’ve already got the news from it too.

Just a day before I came here, I’ve launched a website for this event:

http://wwdc2009.com

Here’s how it works:

  1. I create a new twitter account @2009wwdc
  2. I use this account to follow all the people who attend this conference, not the one who just talk about this
  3. I’ll follow people who will tweet the important things, especially the kind of people who don’t care NDA that much. :D
  4. Server will automatic pick up who I follow and collect all their tweets and stats
  5. Tweets are searchable on the site
  6. Will archive the site couple of weeks after the conference ends

If you want to know more about WWDC 2009, it is the site you should go.

Enjoy!

Apple, English, iPhone , ,