程式碼顏色凸顯 用於 office

原由:

時常有需要做投影片裡面都會放到程式,有很多工具可以做,只是都是單純 html,而貼到 PowerPoint 上就會有一些跑掉,

找到最適合的工具是 highlight ,他支援的很完整,語言、樣式,還有介面完善的GUI與API。GUI部份其實很完整了,但是因為他是用 pre 包覆的,所以貼到 Office 換行跟空白都會有些跑掉。而且輸出到剪貼簿的格式也不是 html,要自己在存成 html 來複製再貼。

他另外也有一個類別給 PHP 跟 Python,內部實做其實只是用 pipe 去發指令收回應。

所以我寫了個小程式整理一下輸出的結果,讓貼到 Office 後格式儘量不要跑掉…。

隨便做的說明:


轉換結果範例:

 1 //Examle
 2 public class Fibonacci {
 3     public static long fib(int n) {
 4         if (n <= 1) return n;
 5         else return fib(n1) + fib(n2);
 6     }
 7 
 8     public static void main(String[] args) {
 9         int N = Integer.parseInt(args[0]);
10         for (int i = 1; i <= N; i++)
11             System.out.println(i + “: “ + fib(i));
12     }
13 }

程式網址:

Syntax highlight for Office

Google Storage Python API

到 Google Storage 申請帳號,過兩天收到認證信,開通以後填入信用卡帳號,就可以開始使用了,

先到 key management 申請一個 key ,然後抓 http://code.google.com/p/gsutil/ API 的函式庫,

然後用 Python 2.5 ~2.7 執行 gsutil ls 他就會幫你產生 .boto 設定檔 填入 剛申請的 key 跟 secret,就可以按照範例執行程式了。

#!/usr/bin/python

import StringIO
import os
import shutil
import tempfile
import time

import boto

# Read developer keys from the ~/.boto config file.
config = boto.config

# URI scheme for Google Storage.
GOOGLE_STORAGE = 'gs'
# URI scheme for accessing local files.
LOCAL_FILE = 'file'
now = time.time()
CATS_BUCKET = 'cats-%d' % now
DOGS_BUCKET = 'dogs-%d' % now

for name in (CATS_BUCKET, DOGS_BUCKET):
# Instantiate a BucketStorageUri object.
uri = boto.storage_uri(name, GOOGLE_STORAGE)
# Try to create the bucket.
try:
uri.create_bucket()
print 'Successfully created bucket "%s"' % name
except boto.exception.StorageCreateError, e:
print 'Failed to create bucket:', e

css 定位模型

最近覺得自己講話、描述越來越不清楚,所以想找幾個曾經沒足夠能力用口頭來描述的概念,用文章的方式重整一下自己的條理。

今天的主題是 css 定位模型,主要範例為此網站 http://www.barelyfitz.com/screencast/html-training/css/positioning/

他內容有十個 tab 幾乎將所有較可能發生的情況都舉了一次例子,所以是一個適合說明的範例。

我想要用兩種方式描述,一種是整理成簡短適合口頭介紹 定位模型的解釋。

另一種是完整定義清楚的解釋。 Continue reading…

Fronteers 2010 Conference

前端工程師的會議,有很多關於網頁設計的技術分享,雖然已經2011了…

http://vimeo.com/16670431

This is a compilationvideo of The Fronteers 2010 Conference. Fronteers 2010 took place on Thursday 7th and Friday 8th of October, in Pathé Tuschinski in Amsterdam.

I record all 14 sessions and put them online for you to watch. See links below:

Thursday 7th of October 2010:
The Design of HTML5 by Jeremy Keith
vimeo.com/​15755349

JavaScript like a box of chocolates by Robert Nyman
vimeo.com/​15758849

Vector Graphics for the web by Brad Neuberg
vimeo.com/​15773144

A CSS3 Talk by Håkon Wium Lie
vimeo.com/​15775937

Progressive Downloads and Rendering by Stoyan Stefanov
vimeo.com/​15981041

CSS Workflow by Jina Bolton
vimeo.com/​15982903

Reusable Code, for good or for awesome! By Jake Archibald
vimeo.com/​15984466

Friday 8th of October 2010:
Real-World Responsive Design by Stephen Hay
vimeo.com/​15986231

The State of HTML5: inaugural Address by Paul Irish
vimeo.com/​15988666

Creating lifelike design with CSS3 by Meagan Fisher
vimeo.com/​15991551

High Performance Javascript by Nicholas Zakas
vimeo.com/​16241085

HTML5 Accesibility: is it ready yet? By Steve Faulkner & Hans Hillen
vimeo.com/​16243415

The renaissance of Browser Animation by Cameron Adams
vimeo.com/​16246110

Reasons to be cheerful by Chris Heilmann
vimeo.com/​16249024

For an overview of all the sessions:
vimeo.com/​channels/​fronteers10

For more information:
fronteers.nl/​congres/​2010