Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Friday, May 16, 2014

Install better Emacs on Mac OS X

Of course, with Homebrew

brew fetch emacs --HEAD --force

brew reinstall emacs --use-git-head --srgb --japanese --with-gnutls --with-cocoa --with-x11 --HEAD --force

brew linkapps emacs

https://github.com/Homebrew/homebrew/blob/master/Library/Formula/emacs.rb

Monday, May 5, 2014

Move .emacs.d to bbatsov/prelude

After a night of Sashimi, I went my friend @superbil's home.



We talked a lot about emacs and other interesting hacking stuffs.

He recommend me to switch my emacs configuration to Bozhidar Batsov's prelude on github.

https://github.com/bbatsov/prelude

Steps:

Backup all stuffs in my .emacs and .emacs.d/ directory.

cd

git clone https://github.com/bbatsov/prelude.git .emacs.d

Copy prelude-modules.el from sample/ to personal/ .

cp sample/prelude-modules.el personal/

Comment (out) modules I need

Launch my emacs.

(waiting for compiling lisp files)

Make prelude up to date

M-x prelude-update

Restart my emacs.

Done!

----

Other settings


Add @superbil's fix-font-org-mode.el under personal/preload/

https://gist.github.com/Superbil/7113937

Switch to color-theme-sanityinc-tomorrow

http://emacsthemes.caisah.info/sanityinc-tomorrow-themes/

And...

github-browse-file mode
twittering-mode
switch-window mode
guide-key mode
ace-jump mode
rebind C-h

https://github.com/xatier/rc-files/blob/master/prelude-modules.el



Big thanks to @superbil (https://twitter.com/superbil)

Monday, July 1, 2013

keyboard setting om OS X

我有個  filco 青軸,接在 Air 上面需要作一些 keyboard layout 的調整

我的 control 和 capslock 是交換的,並且 Alt/Command 在 Mac 鍵盤上是和一般鍵盤的順序是相反的。

如以下方式調整


Thursday, March 21, 2013

Emacs: Flyspell-mode


最近開始拿 Emacs 編寫上課筆記,像我這種英文苦手表示悲劇,常常拼錯自,好在 Emacs 有內建的 flyspell-mode 可以幫我解決這個問題

http://www.emacswiki.org/emacs/FlySpell

在 .emacs 裡面加入  (或是用  hook 綁在某個  mode 上)這行即可

(flyspell-mode 1)

M-TAB 可以幫你 auto correct 回來,就甘心


Tuesday, March 5, 2013

Python dump skype DB

據說 Skype local 端資料也是直接用 sqlite 存的

Mac OSX
~/Library/Application Support/Skype/$account/main.db

Linux
~/.Skype/$account/main.db

所以我們可以自己寫 tools 查看自己的資料 請不要拿來查看別人的資料 >_<

剛剛初步可以 Dump 出以下XD

也許這樣學習資料庫比較有趣(?


[~/.Skype/****]-[Arch Linux] $ sqlite3 main.db
SQLite version 3.7.15.2 2013-01-09 11:53:05
sqlite> .table
Accounts        ChatMembers     Conversations   Participants    Videos
Alerts          Chats           DbMeta          SMSes           Voicemails
CallMembers     ContactGroups   LegacyMessages  Transfers
Calls           Contacts        Messages        VideoMessages
sqlite> select * from Accounts;


Sample code:
#!/usr/bin/python

import sys
import sqlite3

def printProfile(skypeDB):
    conn = sqlite3.connect(skypeDB)
    c = conn.cursor()


    print "show tables:"
    c.execute("SELECT tbl_name from sqlite_master WHERE type=='table';")
    print c.fetchall()

    c.execute("SELECT fullname, skypename, city, country, \
               datetime(profile_timestamp,'unixepoch') FROM Accounts;")


    print "Dump Account: "
    print "-" * 50
    for row in c.fetchall():
        print '[*] -- Found Account --'
        print '    [+] User: ' + row[0]
        print '    [+] Skype Username: ' + row[1]
        print '    [+] Location: ' + row[2] + ',' + row[3]
        print '    [+] Profile Date: ' + row[4]

    print "Dump Contacts: "
    print "-" * 50
    c.execute("SELECT displayname, skypename, phone_mobile, \
               birthday FROM Contacts;")

    for row in c.fetchall():
        print '[*] -- Found Account --'
        print '    [+] User: ' + (row[0])
        print '    [+] Skype Username: ' + row[1]
        print '    [+] Phone_mobile: ' + str(row[2])
        print '    [+] Birthday: ' + str(row[3])


if __name__ == "__main__":
    
    printProfile(sys.argv[1])

Wednesday, November 21, 2012

sha-bang! running scripts on Unix machines

reference: http://en.wikipedia.org/wiki/Shebang_(Unix)

sha-bang 是 Unix 系統上面的特殊慣例,由一個 # (sharp) 和一個 ! (bang) 組成

在 script 中,這個慣例用來表示要用哪個 interpreter 來解釋 / 執行這個 script

一般用絕對路徑來表示,例如 #!/bin/sh 來呼叫外部的 Bourne shell




#!/path/to/the/interpreter [arguments]





常見例子:

#!/bin/sh
#!/bin/sh -x
#!/bin/bash
#!/bin/sed -f
#!/usr/bin/awk -f
#!/usr/bin/perl
#!/usr/bin/python
#!/usr/bin/ruby





當然也可以很空虛的...
#!/bin/cat




另外,有時候為了可攜性,會用 /usr/bin/env python 這種用法來找到該機器的 interpreter 在哪邊

然後不要傻呼呼的吃到 Permission denied. 才在哭說不知道要怎麼跑 lol

chmod +x your_script

Tuesday, October 9, 2012

update bash version on Mac

用到今天我才發現原來 Mac 上面 default 的 bash 竟然是骨灰級的版本

$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.


更新步驟

$ brew install bash

$ /usr/local/bin/bash --version
GNU bash, version 4.2.37(2)-release (i386-apple-darwin12.2.0)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


# 在最後加上裝好的 bash 新版
sudo vim /private/etc/shells
/usr/local/bin/bash

# 換過來
chsh -s /usr/local/bin/bash

$ echo $SHELL
/usr/local/bin/bash

$ echo $BASH_VERSION
4.2.37(2)-release


done.