2016年7月18日 星期一

Ubuntu Trusty 14.04 (Linux Kernel 3.19.0-65) install NVIDIA GeForce 780M driver



Recently, after an kernel upgrade, my laptop cannot detect external monitors anymore. Finding a solution takes me two days – here’s a note in case I need to do it again in the future.

  • google keyword: ubuntu+nvidia+driver; ubuntu+nvidia+dual/multi monitor 
  • re-install ubuntu, get a clean environment 
  • disable UEFI secure boot is required 
  • still need to download and run official nvidia driver install script - NVIDIA-Linux-x86_64->.
run
  $ add-apt-repository ppa:graphics-drivers/ppa
  $ sudo add the graphics-drivers ppa
  $ sudo apt-get update
  $ sudo ubuntu-drivers autoinstall // in order to disable UEFI secure boot
Since I tried lots of steps and finally worked, which steps are nessesary or not is never known. Here’s the packages related to nvidia I currently installed:





[NOTE]
During installation with NVIDIA-Linux-x86_64->.
run , remember0. follow the steps recommended on Ask-Ubuntu forum to disable x-server
1. don't install source for next kernel upgrage
2. generate new key-pair
3. remove old key
4. re-start x-server ($ sudo service lightdm start)

Hope this pose help someone also.

2013年5月26日 星期日

[分享] 不需要安裝 iTunes 也可以使用 iTools 的方法

最近重灌了電腦,適逢身邊有許多人一直在詢問重複的問題,乾脆趁安裝軟體的同時來紀錄一下,順便當成教學文件。

這篇是針對「想要使用 iTools,卻不想安裝 iTunes 巨獸」的 iPhone/iPod/iPad 使用者。

需要預先安裝的軟體:
1. 7-zip

需要預先下載好的程式:
1. iTunes(不需要安裝,下載即可)

假設在一台沒裝 iTunes 的電腦裡面直接執行 iTools,會出現錯誤訊息「iTunes 載入失敗,請確認您是否已經安裝完成 iTunes」

1-error_msg

因為 iTools 在執行的時候會先去檢查有沒有 Apple 驅動,而蘋果官方提供 iPhone/iPod/iPad 安裝驅動程式的唯一方法就是直接安裝 iTunes(這也是當初我遲遲不想入手 iPhone 的原因,因為怕被 iTunes 綁死)

其實官方下載的 iTunes 安裝檔,可以用解壓軟體 7-zip 打開,然後只安裝 iTools 需要的部分即可。

右鍵點選 iTunes 安裝檔,選「7-zip」->「開啟」,可以看到以下的檔案清單:

2-extraction

其中 iTools 需要的只有兩個:
1. AppleApplicationSupport.msi
2. AppleMobileDeviceSupport64.msi
(請注意 Windows 的版本,如果不是 x64 的話就不能用 AppleMobileDeviceSupport64.msi,要另外去下載 32-bit 的 iTunes 安裝檔來解壓縮)

安裝過程就一直點 next 直到最後就好,但是要注意順序,先安裝 AppleApplicationSupport.msi,再安裝 AppleMovileDeviceSupport64.msi。

安裝完之後,理論上 iTools 就可以正常執行了。(還是不行的話…請在 google 上另請高明~)

2012年8月15日 星期三

在 Android ICS 下新增 userspace cosole application 的方法

1. 比照 external 內的資料夾,新增一個 project folder ,內容比照辦理。

2. 進入 device 資料夾,加入新的 application 定義

3. 可參考內建程式:tinymix, tinycap, tinyplay…

2012年8月6日 星期一

[工具] 相見恨晚的強大 SSH 工具 ─ MobaXterm

話說我的工作內容需要大量使用 SSH 來存取 virtual machine,但是 putty 一次一個視窗、要加 X11 forward 還要外掛,很是不便。

幸好給我找到這個軟體:MobaXterm

裡面幾乎整額所有我需要的功能:SSH、SFTP、RDP、X11 forwarding、多頁面視窗、還有很多像是 gvim 的外掛可以加。

難得讓我一看就覺得不可思議的好作品!

網址:http://mobaxterm.mobatek.net/

2012年5月16日 星期三

20120516 工作筆記

1. 在 linux console 下設定 proxy:
export http_proxy=”
http://hostname:portnumber”

2. SD card (sdb1、sdb2) mount 完成後(假設 mount 在 /media/boot/ 和 /media/rootfs/ 下),將 foo.tar.bz2 解壓到 /media/rootfs/:
tar jxfv foo.tar.bz2 –C /media/rootfs

3. 將 foo.tar.gz 解壓到 /myfolderpath/
tar zxfv foo.tar.gz –C /myfolderpath/

4. check out SVN server 中第 38 個版本:
svn co –r 38 –username MYNAME –password PASSWORD svn://hostip/folder/subfolder

5. 搜尋 FOLDER 資料夾中含有關鍵字 KEYWORD 的檔案並標示行數:
grep –r –n “KEYWORD” FOLDER

6. 讓自己寫的 script 開機後自動執行:
/etc/profile.d/my_script.sh

7. universalIndentGUI => save config file => create batch file (config and batch files shoud be at the same directory)

8. Vim 中的長字串自動完成:ctrl-p 或 ctrl-n

9. Good to use 共用資料夾 in VirtualBox guest OS, it's easy and powerful.

10. shift + right click folder => open command here

11. in 64bit Win7, 32bit-chrome will download 32bit Java by default

12. MSN minimize to system tray => Vista Mode

13. gtags 好像只能在 WinXP 32bit 下面才能正常運作,Win7 x64 無法, 但是在Ubuntu下可以正常運作

14. Good to use easygui in Python

15. win7 刪除服務 sc delete servicename

16. virtualbox network bridge 不能用混合模式

17. mount box.net: https://www.box.net/dav

18. mkmmc-android.sh

   1: #!/bin/bash
   2:  
   3: # Copyright (C) 2009 Andrei Dolnikov <dolnikov.andrei@gmail.com>
   4: #
   5: # Licensed under the Apache License, Version 2.0 (the "License");
   6: # you may not use this file except in compliance with the License.
   7: # You may obtain a copy of the License at
   8: #
   9: #      http://www.apache.org/licenses/LICENSE-2.0
  10: #
  11: # Unless required by applicable law or agreed to in writing, software
  12: # distributed under the License is distributed on an "AS IS" BASIS,
  13: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14: # See the License for the specific language governing permissions and
  15: # limitations under the License.
  16:  
  17: if [[ -z $1 || -z $2 || -z $3 || -z $4 ]]
  18: then
  19:     echo "mkmmc-android Usage:"
  20:     echo "    mkmmc-android <device> <board name> <uImage> <rootfs tar.bz2 archive>"
  21:     echo "    Example: mkmmc-android /dev/sdc beagleboard uImage rootfs.tar.bz2"
  22:     exit
  23: fi
  24:  
  25: if [[ -z `which mkimage` ]]
  26: then
  27:     echo "Please, install mkimage on your host"
  28:     echo "    On Ubuntu systems: sudo apt-get install uboot-mkimage"
  29:     exit
  30: fi
  31:  
  32: if ! [[ -e $2 ]]
  33: then
  34:     echo "Incorrect board name!"
  35:     exit
  36: fi
  37:  
  38: if ! [[ -e $3 ]]
  39: then
  40:     echo "Incorrect uImage location!"
  41:     exit
  42: fi
  43:  
  44: if ! [[ -e $4 ]]
  45: then
  46:     echo "Incorrect rootfs tarball location!"
  47:     exit
  48: fi
  49:  
  50: echo "All data on "$1" now will be destroyed! Continue? [y/n]"
  51: read ans
  52: if ! [ $ans == 'y' ]
  53: then
  54:     exit
  55: fi
  56:  
  57: echo "[Partitioning $1...]"
  58:  
  59: dev_sz=`fdisk -l $1 | grep $1: | awk '{print$(NF-1)}'`
  60: cyl=$(expr $dev_sz / 512 / 63 / 255)
  61: fat_end=$(expr $cyl / 2)
  62:  
  63: fdisk "$1" &> /dev/null << EOF
  64: o
  65: x
  66: h
  67: 255
  68: s
  69: 63
  70: c
  71: $cyl
  72: r
  73: n
  74: p
  75: 1
  76:  
  77: $fat_end
  78: t
  79: c
  80: a
  81: 1
  82: n
  83: p
  84: 2
  85:  
  86:  
  87: w
  88: EOF
  89:  
  90: echo "[Making filesystems...]"
  91:  
  92: mkfs.vfat -F 32 -n boot "$1"1 &> /dev/null
  93: mkfs.ext3 -L rootfs "$1"2 &> /dev/null
  94:  
  95: echo "[Copying files...]"
  96:  
  97: mount "$1"1 /mnt
  98: cp $3 /mnt/uImage
  99: mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n $2/normal/boot.script -d $2/normal/boot.script $2/normal/boot.scr &> /dev/null
 100: cp $2/normal/boot.scr /mnt
 101: umount "$1"1
 102:  
 103: mount "$1"2 /mnt
 104: tar jxvf $4 -C /mnt &> /dev/null
 105: chmod 755 /mnt
 106: umount "$1"2
 107:  
 108: echo "[Done]"

2011年10月25日 星期二

讓 Eclipse 可以呼叫外部編輯器開啟檔案

雖然 Eclipse 這個 IDE 相當強悍,功能多、自定性高,但看來看去總覺得 editor 的視窗太小了,遇到長一點的 code 就會覺得要一直滑滾輪很煩,然後就會很想用 vim 來開同一個檔案來看。

「Windows」=>「Preference」=>「General」=>「Editors」=>「File Associations」

在這裡更改即可。

2011年10月17日 星期一

VitualBox + Ubuntu + SSH Server 設定方式

萬萬沒想到,念了研究所拋棄擁抱多年的 Linux ,如今公司居然要我重操就業…
而且還是我一直沒打算碰的 Android XD

之前在學校都是直接灌 PC 或是用 VMware,但公司要求不能使用非法版權軟體,只好改用 VirtualBox
無奈第一步想要架起 SSH Server 從 Host 連進去就不斷失敗 orz

幸好最後還是有辦到,不然今晚就別想睡著了

首先,在 VirtualBox 裡面灌好 Ubuntu ,然後用 Synapic 安裝 OpenSSH Server 都不太可能出現問題。
接下來就是問題所在了,如果直接用 putty/pietty 連 192.168.56.1 (VirtualBox Host-Only Network)會顯示「Connection Refused」
在 Ubuntu 裡面怎麼試都沒用,因為不是 Guest 那邊的問題。

解決之道如下

方法一:用「命令提示字元」進入 VirtualBox 的安裝目錄,輸入「VBoxManage modifyvm UbuntuVM –natpf1 “guestsshh,tcp,,2222,,22”」
這樣可以在 Host 端連 localhost:2222 或 192.168.56.1:2222 ,VirtualBox 會把這個連線導入 Guest 的 port 22

方法二:直接修改「設定值」-「網路」-「連接埠轉送規則」

image

其實就是跟方法一得到一樣的效果,我另外嘗試 22 轉 22 ,也可以 work 。

如果出現了防火牆的訊息,記得點「允許」。

2011年5月21日 星期六

Excel VBA 抓 ebay 和 dealoz 書目資料

   1: Option Explicit
   2: Function ExistSheet(shtName As String)
   3:     Dim Sht As Object
   4:     On Error Resume Next
   5:     Set Sht = Sheets(shtName)
   6:     If Err.Number = 0 Then
   7:         ExistSheet = True
   8:     Else
   9:         ExistSheet = False
  10:     End If
  11:     Set Sht = Nothing
  12: End Function
  13: Public Sub getURLs()
  14:     ' find last row
  15:     Dim lastCell As Range
  16:     Set lastCell = Sheets("Control Panel").Range("A65536").End(xlUp)
  17:     Dim lastRow As Integer
  18:     lastRow = lastCell.Row
  19:     
  20:     Dim hlink As Hyperlink
  21:     Dim firstRow As Integer
  22:     firstRow = 3
  23:     
  24:     For Each hlink In Sheets("Control Panel").Range(Cells(firstRow, 1), Cells(lastRow, 1)).Hyperlinks
  25:         Cells(hlink.Range.Row, 2) = hlink.Address
  26:     Next
  27: End Sub
  28: Sub getISBN()
  29:     ' in Excel,  long numeric strings will be displayed in scientific notation
  30:     ' in order to avoid scientific notation
  31:     Cells.Select
  32:     Selection.NumberFormatLocal = "0"
  33:  
  34:     ' for each row:
  35:     ' 1. get DOM objects from URL
  36:     ' 2. find ISBN-10 and ISBN-13
  37:     
  38:     ' find last row
  39:     Dim lastCell As Range
  40:     Dim lastRow As Integer
  41:     Set lastCell = Sheets("Control Panel").Range("B65536").End(xlUp)
  42:     lastRow = lastCell.Row
  43:     Dim firstRow As Integer
  44:     firstRow = 3
  45:     
  46:     ' get DOM objs
  47:     Dim ie As WebBrowser
  48:     Set ie = CreateObject("InternetExplorer.Application")
  49:     Dim doc As HTMLDocument
  50:     Dim elements As IHTMLElementCollection
  51:     Dim elem1, elem2 As IHTMLElement    ' find 2 layers of document objs
  52:     Dim strURL As String
  53:     Dim bISBN_10, bISBN_13 As Boolean
  54:     Dim i As Integer
  55:     For i = firstRow To lastRow
  56:         strURL = Cells(i, 2).Value
  57:         ie.navigate (strURL)
  58:         ie.Visible = True
  59:         Do Until ie.readyState = READYSTATE_COMPLETE
  60:             DoEvents
  61:         Loop
  62:         
  63:         Set doc = ie.document
  64:         ' only search text inside table
  65:         Set elements = doc.getElementsByTagName("TD")
  66:         
  67:         bISBN_10 = False
  68:         bISBN_13 = False
  69:         ' check first layer
  70:         For Each elem1 In elements
  71:             If bISBN_10 = False And IsNumeric(elem1.innerText) And Len(Trim(elem1.innerText)) = 10 Then
  72:                 Cells(i, 3) = elem1.innerText
  73:                 bISBN_10 = True
  74:             End If
  75:             If bISBN_13 = False And IsNumeric(elem1.innerText) And Len(Trim(elem1.innerText)) = 13 Then
  76:                 Cells(i, 4) = elem1.innerText
  77:                 bISBN_13 = True
  78:             End If
  79:             If bISBN_10 = True And bISBN_13 = True Then
  80:                 Exit For
  81:             End If
  82:         Next elem1
  83:         ' check second layer
  84:         For Each elem1 In elements
  85:             For Each elem2 In elem1.all
  86:                 If bISBN_10 = False And IsNumeric(elem2.innerText) And Len(Trim(elem2.innerText)) = 10 Then
  87:                     Cells(i, 3) = elem2.innerText
  88:                     bISBN_10 = True
  89:                 End If
  90:                 If bISBN_13 = False And IsNumeric(elem2.innerText) And Len(Trim(elem2.innerText)) = 13 Then
  91:                     Cells(i, 4) = elem2.innerText
  92:                     bISBN_13 = True
  93:                 End If
  94:                 If bISBN_10 = True And bISBN_13 = True Then
  95:                     Exit For
  96:                 End If
  97:             Next elem2
  98:             If bISBN_10 = True And bISBN_13 = True Then
  99:                     Exit For
 100:             End If
 101:         Next elem1
 102:         ' if both ISBN-10 and ISBN-13 are not found, ignore the rest steps
 103:         If bISBN_10 = False And bISBN_13 = False Then
 104:             Cells(i, 3) = "Not Found"
 105:             Cells(i, 4) = "Not Found"
 106:         Else
 107:         End If
 108:     Next i
 109:     Columns(3).AutoFit
 110:     Columns(4).AutoFit
 111: End Sub
 112: Sub getBooksInfo()
 113:     ' for each row:
 114:     ' 1. get DOM objects from URL
 115:     ' 2. find title,
 116:     
 117:     ' find last row
 118:     Dim lastCell As Range
 119:     Dim lastRow As Integer
 120:     Set lastCell = Sheets("Control Panel").Range("B65536").End(xlUp)
 121:     lastRow = lastCell.Row
 122:     Dim firstRow As Integer
 123:     firstRow = 3
 124:     
 125:     Dim i As Integer
 126:     For i = firstRow To lastRow
 127:         If IsNumeric(Cells(i, 4)) Then
 128:             ' create a new "Temp" worksheet
 129:             If ExistSheet("Temp") Then
 130:                 Application.DisplayAlerts = False
 131:                 Sheets("Temp").Delete
 132:                 Application.DisplayAlerts = True
 133:             End If
 134:             Sheets.Add After:=Sheets(Sheets.Count)
 135:             ActiveSheet.Name = "Temp"
 136:             
 137:             Dim strISBN, strURL1, strURL2, strURL3, strURL4, strURL5, strURL6 As String
 138:             strISBN = Sheets("Control Panel").Cells(i, 4)
 139:             strURL1 = "URL;http://www.dealoz.com/prod2.pl?cat=book&op=buy&op2=buy&lang=en-us&search_country=us&shipto=us&cur=usd&zip=&nw=y&class=&pqcs=&quantity=&shipping_type=&sort=&catby=book.keyword&query="
 140:             strURL2 = "&asin=&ean="
 141:             strURL3 = "&upc=&mpn=&mfr="
 142:             strURL4 = "prod2.pl?cat=book&op=buy&op2=buy&lang=en-us&search_country=us&shipto=us&cur=usd&zip=&nw=y&class=&pqcs=&quantity=&shipping_type=&sort=&catby=book.keyword&query="
 143:             strURL5 = "&asin=&ean="
 144:             strURL6 = "&upc=&mpn=&mfr="
 145:             Sheets("Temp").Select
 146:             With ActiveSheet.QueryTables.Add(Connection:= _
 147:                 strURL1 & strISBN & strURL2 & strISBN & strURL3 _
 148:                 , Destination:=Range("A1"))
 149:                 .Name = _
 150:                 strURL4 & strISBN & strURL5 & strISBN & strURL6
 151:                 .FieldNames = True
 152:                 .RowNumbers = False
 153:                 .FillAdjacentFormulas = False
 154:                 .PreserveFormatting = True
 155:                 .RefreshOnFileOpen = False
 156:                 .BackgroundQuery = True
 157:                 .RefreshStyle = xlInsertDeleteCells
 158:                 .SavePassword = False
 159:                 .SaveData = True
 160:                 .AdjustColumnWidth = True
 161:                 .RefreshPeriod = 0
 162:                 .WebSelectionType = xlSpecifiedTables
 163:                 .WebFormatting = xlWebFormattingNone
 164:                 .WebTables = "10"
 165:                 .WebPreFormattedTextToColumns = True
 166:                 .WebConsecutiveDelimitersAsOne = True
 167:                 .WebSingleBlockTextImport = False
 168:                 .WebDisableDateRecognition = False
 169:                 .WebDisableRedirections = False
 170:                 .Refresh BackgroundQuery:=False
 171:             End With
 172:             Sheets("Control Panel").Select
 173:             Dim str As String
 174:             ' get Title
 175:             Sheets("Control Panel").Cells(i, 5) = Sheets("Temp").Cells(1, 1)
 176:             ' get Author
 177:             Sheets("Control Panel").Cells(i, 6) = Trim(Replace(Sheets("Temp").Cells(2, 1), "Author:", ""))
 178:             ' split data of edition, publisher, format
 179:             Dim varSplit As Variant
 180:             Dim j As Integer
 181:             varSplit = Split(Sheets("Temp").Cells(3, 1), " ")
 182:             ' get Edition
 183:             For j = LBound(varSplit) To UBound(varSplit)
 184:                 If InStr(varSplit(j), "Edition") Then
 185:                     Sheets("Control Panel").Cells(i, 7) = varSplit(j + 1)
 186:                 End If
 187:                 'MsgBox "Item " & intIndex & " is " & avarSplit(intIndex) & _
 188:                 '" which is " & Len(avarSplit(intIndex)) & " characters long", vbInformation
 189:             Next
 190:             ' get Publisher
 191:             Dim iStart, iEnd As Integer
 192:             iStart = 0
 193:             iEnd = 0
 194:             For j = LBound(varSplit) To UBound(varSplit)
 195:                 ' find the start and end string of publisher
 196:                 If InStr(varSplit(j), "Publisher") Then
 197:                     iStart = j + 1
 198:                 End If
 199:                 If InStr(varSplit(j), "Hard") Or InStr(varSplit(j), "Paper") Then
 200:                     iEnd = j - 1
 201:                 End If
 202:             Next j
 203:             ' if iStart=0, no publisher info
 204:             If iStart = 0 Then
 205:                 Exit For
 206:             End If
 207:             ' if iEnd=0, join the rest strings as publisher
 208:             If iEnd = 0 Then
 209:                 iEnd = UBound(varSplit)
 210:             End If
 211:             Dim strArr(256) As String
 212:             Dim k As Integer
 213:             For k = iStart To iEnd
 214:                 strArr(k - iStart + 1) = varSplit(k)
 215:             Next k
 216:             Sheets("Control Panel").Cells(i, 8) = Trim(Join(strArr))
 217:             ' get format
 218:             For j = LBound(varSplit) To UBound(varSplit)
 219:                 If InStr(varSplit(j), "Hard") Then
 220:                     Sheets("Control Panel").Cells(i, 9) = Replace(varSplit(j), ":", "")
 221:                     Exit For
 222:                 End If
 223:                 If InStr(varSplit(j), "Paper") Then
 224:                     Sheets("Control Panel").Cells(i, 9) = Replace(varSplit(j), ":", "")
 225:                     Exit For
 226:                 End If
 227:             Next
 228:         End If ' if ISBN isNumeric
 229:     Next i
 230:     Sheets("Control Panel").Select
 231:     Columns("E:I").Select
 232:     Selection.Columns.AutoFit
 233: End Sub