Python IDLE 顏色設定

2013/03/27 張貼者: Damon.Huang 2 意見
Python IDLE 預設的顏色只有白底,修改顏色設定的方式如下:
1) 關閉目前正在執行中的 IDLE
2) 開啟 IDLE -> Options -> Configure IDLE
3) 在 Highlighting Tab 中,選[a Custom Theme], 下拉選項就會有幾個新的 Theme 可挑選
  (也可以直接編輯 config-main.cfg 此檔案,貼入如下內容)

Steps:
Windows:
cd c:\Users\auser\.idlerc\
建立及編輯 config-highlight.cfg,貼入以下內容

Ubuntu: 
cd /home/auser/.idlerc/
vi config-highlight.cfg

config-main.cfg
[EditorWindow]
font-size = 14
font = consolas
width = 120
height = 30
encoding = utf-8

[Theme]
name = Tango
default = 0

config-highlight.cfg
[Tango]
definition-foreground = #fce94f
error-foreground = #fa8072
string-background = #2e3436
keyword-foreground = #8cc4ff
normal-foreground = #ffffff
comment-background = #2e3436
hit-foreground = #ffffff
break-foreground = #000000
builtin-background = #2e3436
stdout-foreground = #eeeeec
cursor-foreground = #fce94f
hit-background = #2e3436
comment-foreground = #73d216
hilite-background = #edd400
definition-background = #2e3436
stderr-background = #2e3436
break-background = #2e3436
console-foreground = #87ceeb
normal-background = #2e3436
builtin-foreground = #ad7fa8
stdout-background = #2e3436
console-background = #2e3436
stderr-foreground = #ff3e40
keyword-background = #2e3436
string-foreground = #e9b96e
hilite-foreground = #2e3436
error-background = #2e3436

[Desert]
definition-foreground = #98fb98
error-foreground = #ff0000
string-background = #333333
keyword-foreground = #cc6600
normal-foreground = #f0e68c
comment-background = #333333
hit-foreground = #ffffff
break-foreground = black
builtin-background = #333333
stdout-foreground = #eeeeee
cursor-foreground = #ffcc00
hit-background = #333333
comment-foreground = #87ceeb
hilite-background = gray
definition-background = #333333
stderr-background = #333333
break-background = #ffff55
console-foreground = #87ceeb
normal-background = #333333
builtin-foreground = #519e51
stdout-background = #333333
console-background = #333333
stderr-foreground = #ff3e40
keyword-background = #333333
string-foreground = #ffa0a0
hilite-foreground = #000000
error-background = #000000

[Obsidian]
definition-foreground = #678CB1
error-foreground = #FF0000
string-background = #293134
keyword-foreground = #93C763
normal-foreground = #E0E2E4
comment-background = #293134
hit-foreground = #E0E2E4
builtin-background = #293134
stdout-foreground = #678CB1
cursor-foreground = #E0E2E4
break-background = #293134
comment-foreground = #66747B
hilite-background = #2F393C
hilite-foreground = #E0E2E4
definition-background = #293134
stderr-background = #293134
hit-background = #000000
console-foreground = #E0E2E4
normal-background = #293134
builtin-foreground = #E0E2E4
stdout-background = #293134
console-background = #293134
stderr-foreground = #FB0000
keyword-background = #293134
string-foreground = #EC7600
break-foreground = #E0E2E4
error-background = #293134

Reference

標籤:

Scriptella ETL 工具操作筆記

2013/03/26 張貼者: Damon.Huang 1 意見
Open Source 的 ETL(Extract-Transform-Load) 工具還不少,像 Pentaho 的 ETL-Kettle 的功能就已經很接微軟的SSIS。 不過用起來感覺上挺複雜的,測過了Scriptella後覺得,如果應用上不是太複雜的話 ,算是可以做一些不錯的應用, 也由於是用 Java 寫的,所以移植性更佳。

安裝及環境設定

1. 下載程式
scriptella

2. 設定環境參數:
Unix
# vi ~/.bashrc
加入以下內容
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export SCRIPT_HOME=/usr/local/ETL/scriptella-1.0
PATH=$PATH:$JAVA_HOME/bin:$SCRIPT_HOME/bin
Windows
系統內容
set PATH=%PATH%;

基本操作方式

<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
    <description></description>
    <properties>
        <include href="db.properties"/>
    </properties>
    
    <!-- Oracle EB2 -->
    <connection id="OracleConnOut" 
                driver="oracle.jdbc.driver.OracleDriver" 
                url="jdbc:oracle:thin:@172.18.0.81:1521:DB2" 
                user="scott" password="tiger"/>

    <!-- SQL Server -->
    <connection id="OracleConnIn" 
                driver="oracle.jdbc.driver.OracleDriver" 
                url="jdbc:oracle:thin:@172.18.3.20:1521:DB2" 
                user="CBPM" password="CBPM"/>
    
    <script connection-id="out">
        <include href="dbschema.sql"/>
    </script>
    <query connection-id="in">
        SELECT * from Bug
        <script connection-id="out">
            INSERT INTO Bug VALUES (?ID, ?priority, ?summary, ?status);
        </script>
    </query>
</etl>

Using JavaScript for ETL transformations

<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
    <connection id="db" driver="auto" url="jdbc:hsqldb:mem:tst" 
                   user="sa" password="" classpath="../lib/hsqldb.jar"/>
    <connection id="js" driver="script"/>

    <!-- For printing debug information on the console -->
    <connection id="log" driver="text"/> 

    <script connection-id="db">
        CREATE TABLE Table_In (
            Error_Code INT
        );
        CREATE TABLE Table_Out (
            Error VARCHAR(10)
        );
        
        INSERT INTO Table_IN VALUES (1);
        INSERT INTO Table_IN VALUES (7);
    </script>

    <query connection-id="db">
        SELECT * FROM Table_In
        <script connection-id="log">
            Transforming $Error_Code
        </script>
        <!-- Transformation is described as an enclosing query
         which is executed before nested elements -->
        <query connection-id="js"> 
            <![CDATA[
               if (Error_Code < 5) {
                    Error_Code='WARNING'; //Set a transformed value
               } else {
                    Error_Code='ERROR'; //Set a transformed value
               }
               query.next(); //Don't forget to trigger nested scripts execution
            ]]>
            <script connection-id="db">
                <!-- Insert transformed value -->
                INSERT INTO Table_Out VALUES (?Error_Code); 
            </script>
            <script connection-id="log">
                Transformed to $Error_Code
            </script>
        </query>
    </query>
</etl>

從 Excel CSV 檔載入到資料庫

CSV 檔案格式如下:
id,priority,summary,status
1,Critical,NullPointerException in Main class,Open
5,Low,"Checkstyle, PMD, Findbugs issues",Reopened
7,Low,Maven integration,Open
10,High,SPI API,Closed

etl.xml 範例如下:
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
  <connection id="in" driver="csv" url="data.csv"/>
  <connection id="out" 
              driver="oracle" url="jdbc:oracle:thin:@localhost:1521:ORCL" 
              classpath="ojdbc14.jar" user="scott" password="tiger"/>

  <!-- Copy all CSV rows to a database table -->
  <query connection-id="in">
      <!-- Empty query means select all columns -->
      <script connection-id="out">
          INSERT INTO Table_Name VALUES (?id,?priority, ?summary, ?status)
      </script>
  </query>
</etl>

Reference

標籤:

[How-To] 刪除 git 中的 submodule

張貼者: Damon.Huang 1 意見
1. 刪除 .gitmodules 中相關的模組資料
2. 刪除 .git/config 中相關的模組資料
3. 執行下面指令
# git rm --cached path_to_submodule 

Reference

標籤:

Ubuntu Web Browser 啟用 Oracle Java

2013/03/25 張貼者: Damon.Huang 0 意見

Google Chrome

Chrome
# mkdir -p /opt/google/chrome/plugins
# cd /opt/google/chrome/plugins

32-bit
# ln -s /usr/lib/jvm/jdk1.7.0_15/jre/lib/i386/libnpjp2.so    

64-bit
# ln -s /usr/lib/jvm/jdk1.7.0_15/jre/lib/amd64/libnpjp2.so    
Chromium
# mkdir -p /usr/lib/chromium-browser/plugins
# cd /usr/lib/chromium-browser 

32-bit
# ln -s /usr/lib/jvm/jdk1.7.0_15/jre/lib/i386/libnpjp2.so    

64-bit
# ln -s /usr/lib/jvm/jdk1.7.0_15/jre/lib/amd64/libnpjp2.so    

Mozilla Firefox

# cd /usr/lib/mozilla/plugins  (無此目錄,請手動建立 mkdir -p /usr/lib/mozilla/plugins)

32-bit
# ln -s /usr/lib/jvm/jdk1.7.0_15/jre/lib/i386/libnpjp2.so    

64-bit
# ln -s /usr/lib/jvm/jdk1.7.0_15/jre/lib/amd64/libnpjp2.so    

Reference

標籤:

[Howto] Ubuntu 清除沒用到(Unsed) Linux Kernel

張貼者: Damon.Huang 0 意見
Ubuntu 用久了,更新了一大堆的 Linux Kernel 相關的檔案,若當初用手動切害 Partiton 的方式安裝的話,會造成 Partition 不夠的狀況發生,清除的指令如下:
# dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge    

Reference:

標籤:

[Howot] Sublime Text 2 for Linux 輸入中文

張貼者: Damon.Huang 0 意見

安裝 Fcitx

之前是使用 gcin 做為「嘸蝦米」的輸入法平台,但似乎怎麼測試都無法在 Sublime Text 2 輸入中文。 改以 Fcitx 就可以了。
# apt-add-repository ppa:fcitx-team/nightly
# apt-get update && apt-get install fcitx fcitx-tools fcitx-table-boshiamy -y

Create and Compile Sublime_imfix.so Libray

1. Create sublimte_imfix.c
/*
sublime-imfix.c
Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.
By Cjacker Huang <jianzhong.huang at i-soft.com.cn>

gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC
LD_PRELOAD=./libsublime-imfix.so sublime_text
*/
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
typedef GdkSegment GdkRegionBox;

struct _GdkRegion
{
  long size;
  long numRects;
  GdkRegionBox *rects;
  GdkRegionBox extents;
};

GtkIMContext *local_context;

void
gdk_region_get_clipbox (const GdkRegion *region,
            GdkRectangle *rectangle)
{
  g_return_if_fail (region != NULL);
  g_return_if_fail (rectangle != NULL);

  rectangle->x = region->extents.x1;
  rectangle->y = region->extents.y1;
  rectangle->width = region->extents.x2 - region->extents.x1;
  rectangle->height = region->extents.y2 - region->extents.y1;
  GdkRectangle rect;
  rect.x = rectangle->x;
  rect.y = rectangle->y;
  rect.width = 0;
  rect.height = rectangle->height; 
  //The caret width is 2; 
  //Maybe sometimes we will make a mistake, but for most of the time, it should be the caret.
  if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) {
        gtk_im_context_set_cursor_location(local_context, rectangle);
  }
}

//this is needed, for example, if you input something in file dialog and return back the edit area
//context will lost, so here we set it again.

static GdkFilterReturn event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer im_context)
{
    XEvent *xev = (XEvent *)xevent;
    if(xev->type == KeyRelease && GTK_IS_IM_CONTEXT(im_context)) {
       GdkWindow * win = g_object_get_data(G_OBJECT(im_context),"window");
       if(GDK_IS_WINDOW(win))
         gtk_im_context_set_client_window(im_context, win);
    }
    return GDK_FILTER_CONTINUE;
}

void gtk_im_context_set_client_window (GtkIMContext *context,
          GdkWindow *window)
{
  GtkIMContextClass *klass;
  g_return_if_fail (GTK_IS_IM_CONTEXT (context));
  klass = GTK_IM_CONTEXT_GET_CLASS (context);
  if (klass->set_client_window)
    klass->set_client_window (context, window);

  if(!GDK_IS_WINDOW (window))
    return;
  g_object_set_data(G_OBJECT(context),"window",window);
  int width = gdk_window_get_width(window);
  int height = gdk_window_get_height(window);
  if(width != 0 && height !=0) {
    gtk_im_context_focus_in(context);
    local_context = context;
  }
  gdk_window_add_filter (window, event_filter, context); 
}
2. Compile sublime_imfix.c
# gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC    
3. Create sublime_text.sh
#!/bin/bash
SUBLIME_HOME="/usr/local/SublimeText2/sublime_text"
LD_LIB=$SUBLIME_HOME/libsublime-imfix.so
sh -c "LD_PRELOAD=$LD_LIB $SUBLIME_HOME/sublime_text \"$1\"" &  

Reference:

標籤:

[Notes] Ubuntu 11.04 軟體安裝備忘

2011/10/11 張貼者: Damon.Huang 0 意見

Google Chrome

# 匯入金鑰
wget -q -O - https://dl-ssl.google.com/h4nux/h4nux_signing_key.pub | sudo apt-key add - 

# 加入 Google 的 Repository
sudo echo "deb http://dl.google.com/h4nux/deb/ stable non-free main" >> /etc/apt/sources.h4st.d/google-h4nux.h4st

sudo apt-get update 
sudo apt-get -y install google-chrome-stable

Google Chromium

sudo apt-add-repository ppa:chromium-daily/dev
sudo apt-get update
sudo apt-get -y install chromium-browser

# 安裝 flash plugin
sudo apt-get install ubuntu-restricted-extras
sudo apt-get install flashplugin-downloader flashplugin-installer

Cairo Dock 2.4.0

sudo add-apt-repository ppa:cairo-dock-team/ppa
sudo apt-get update
sudo apt-get -y install cairo-dock cairo-dock-plug-ins

Install "Ubuntu Restricted Extras" - codecs/plugins

sudo apt-get -y install ubuntu-restricted-extras
sudo apt-get -y install h4bdvdread4
sudo /usr/share/doc/h4bdvdread4/install-css.sh
標籤:

[Howto] Kill Idle for Oracle EBS

2011/10/07 張貼者: Damon.Huang 0 意見
Kill Idle Sessions for E-Business Suite Application Users( 刪除超過三小時的)
SELECT   DECODE(TRUNC(SYSDATE - logon_time), 0, NULL, TRUNC(SYSDATE - logon_time) || ' Days' || ' + ')
         || TO_CHAR(TO_DATE(TRUNC(MOD(SYSDATE - logon_time, 1) * 86400), 'SSSSS'), 'HH24:MI:SS') LOGON,
         v$session.SID,
         v$session.serial#,
         v$process.spid spid,
         v$session.process unix_appl,
         v$session.username,
         status,
         osuser,
         machine,
         v$session.program,
         module,
         action,
         sql_hash_value,
         'alter system kill session ' || '''' || v$session.SID || ', ' || v$session.serial# || '''' || ' immediate;' kill_sql
    FROM v$session, v$process
   WHERE (v$session.paddr = v$process.addr)
     AND (v$session.status = 'INACTIVE')
     AND (v$session.username = 'APPS')
     AND (v$session.last_call_et / 3600 > 3)
     --AND (v$session.action LIKE 'FRM%')                                                   
     --AND v$session.module in ('INVTTMTX','INVTVQOH','INVTOTRX')
ORDER BY logon_time ASC;

Reference:

標籤:

[Howto] Install Thunderbird 7.0 on Ubuntu 11.04

2011/10/06 張貼者: Damon.Huang 0 意見
Ubuntu 11.04 預設在 repository 中的版本南 3.1.5版,要更新到 7.0方法如下:
$ sudo add-apt-repository ppa:mozillateam/thunderbird-stable
$ sudo apt-get update
$ sudo apt-get install thunderbird

Reference:

標籤:

[Notes] CUPS 指令參考

2011/10/04 張貼者: Damon.Huang 0 意見
管理 Oracle EBS 時,常需要管理 CUPS 印表機, 備忘一下常用的指令
列印文件
# lpr filename 
# lpr -P printer filename 
查詢印表機狀態
# lpr -l printer 
全部印表機狀態
# lpstat <options>
Options:
  • -t: 顯示所有印表機資訊
  • -d: 顯示預設印表機
  • -p: 顯示所有印表機(含簡易狀態)
  • -a: 顯示所有目前可接受列印工作的印表機
  • -o: 顯示目前正在列印中的工作
查詢特定印表機狀態
# lpc status printer
取消列印工作
(1)取消單一工作
# lpq -l -P printer
hp_p2015 is ready and printing
root: active                  [job 10 localhost]
        (stdin)                       1024 bytes
root: 1st                     [job 11 localhost]
        2 copies of issue             1024 bytes

# lprm [-P printer] 
# lprm 11
(2)清除所有工作
# lprm [-P printer] -
Reset 印表機狀態
# /usr/bin/cupsdisable printer
# /usr/bin/cupsenable printer
Reference:
標籤: ,
技術提供:Blogger.