envsetup.sh that came with AOSP provide lots handy command when browse android source tree.
By default, it will require envsetup.sh reside at $TOP/build, so we could modify it to remove this requirement :
neomacbookair:home neo$ diff envsetup.sh nenvsetup.sh
18c18
< for i in `cat $T/build/envsetup.sh | sed -n "/^function /s/function \([a-z_]*\).*/\1/p" | sort`; do
---
> for i in `cat ~/Dropbox/home/nenvsetup.sh | sed -n "/^function /s/function \([a-z_]*\).*/\1/p" | sort`; do
555,556c555,556
< local TOPFILE=build/core/envsetup.mk
< if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
---
> local TOPFILE=~/Dropbox/home/nenvsetup.sh
> if [ -n "$TOP" -a -f "$TOPFILE" ] ; then
I rename envsetup.sh into nenvsetup.sh, and placed in ~/Dropbox/home folder. In my source tree, I could simply type :
neomacbookair:mp007 neo$ export TOP=`pwd`
neomacbookair:mp007 neo$ . ~/Dropbox/home/nenvsetup.sh
Then you could use it's utility to travel your source tree :
neomacbookair:mp007 neo$ godir Config.java
Creating index... Done
[1] ./gen/com/wong/mprj/mp007
[2] ./src/com/wong/mprj/mp007
Select one: 2
neomacbookair:mp007 neo$ ls -l Config.java
-rw-r--r-- 1 neo staff 906 8 27 14:13 Config.java
neomacbookair:mp007 neo$ godir mprj-jni.cpp
[1] ./jni/libmprj
[2] ./jni/libtest
Select one: 2
neomacbookair:libtest neo$ ls -l mprj-jni.cpp
-rw-r--r-- 1 neo staff 1808 8 18 23:10 mprj-jni.cpp
neomacbookair:libtest neo$ croot
neomacbookair:mp007 neo$
Of course you may use cgrep, jgrep too, for those m, mm utility it may require more hack before you can use, but I am fine with croot, godir, that's enough for me.
Tuesday, August 28, 2012
Monday, July 02, 2012
Pipe a tar command after find command
For example, we want to pack all pdf file from a folder tree :
neo@sd2bsp:~$find 15r6 -type f -name \*.pdf -print0 | tar --null -cvjf pdfpack.tar.bz2 -T -
man find :
-print0
True; print the full file name on the standard output, followed by a null character
(instead of the newline character that -print uses). This allows file names that contain
newlines or other types of white space to be correctly interpreted by programs that
process the find output.
man tar :
--null --files-from reads null-terminated names, disable --directory
-T, --files-from F
get names to extract or create from file F
More over, move all pdf files from one folder to another :
neo@sd2bsp:/tmp/all_pdf$ find ~/vendor/15r6 -type f -name \*.pdf -print0 | tar --null -cvf - -T - | tar x
Then those pdf will be copy from ~/vendor/15r6 to /tmp/all_pdf, and within the same folder tree.
neo@sd2bsp:~$find 15r6 -type f -name \*.pdf -print0 | tar --null -cvjf pdfpack.tar.bz2 -T -
man find :
-print0
True; print the full file name on the standard output, followed by a null character
(instead of the newline character that -print uses). This allows file names that contain
newlines or other types of white space to be correctly interpreted by programs that
process the find output.
man tar :
--null --files-from reads null-terminated names, disable --directory
-T, --files-from F
get names to extract or create from file F
neo@sd2bsp:/tmp/all_pdf$ find ~/vendor/15r6 -type f -name \*.pdf -print0 | tar --null -cvf - -T - | tar x
Then those pdf will be copy from ~/vendor/15r6 to /tmp/all_pdf, and within the same folder tree.
Tuesday, June 19, 2012
Tweak Apple Remote for XBMC
Apple Remote is a small and pretty remote controller for Mac OSX, but it contain less key then others. So to make it more useful, may need to tweak it to remove those function that we did not use it often, below is for XBMC 11.0 :
Modified joystick.AppleRemote.xml : http://goo.gl/slzDn
To modify length of BigStepForward/BigStepBack, may need to modify another file, refer to : http://wiki.xbmc.org/?title=Advancedsettings.xml
neomacmini:TempHD neo$ diff joystick.AppleRemote.xml joystick.AppleRemote.xml.orig # Click "Menu" button at main screen to bring up shutdown menu 86,87c86,87 < <button id="8">XBMC.ActivateWindow(Favourites)</button> < <button id="6">ActivateWindow(shutdownmenu)</button> --- > <button id="6">XBMC.ActivateWindow(Favourites)</button> > <button id="8">ActivateWindow(shutdownmenu)</button> # Click "Right" button to stop music, so that we dont need to browse to to "stop" button" 90,95d89 < <mymusicfiles> < <joystick name="AppleRemote"> < <button id="4">Stop</button> < <button id="6">ParentDir</button> < </joystick> < </mymusicfiles> # Let "Up/Down" button to do big jump when watching movie 98,99c92,93 < <button id="1">BigStepForward</button> < <button id="2">BigStepBack</button> --- > <button id="1">VolumeUp</button> > <button id="2">VolumeDown</button> #Long press "Menu" key at video screen will bring up OSD menu, instead of switch back to control screen 104c98,99 < <button id="8">OSD</button> --- > <button id="7">OSD</button> > <button id="8">Fullscreen</button>For Mac OSX, the location of joystick.AppleRemote.xml is at /Applications/XBMC.app/Contents/Resources/XBMC/system/keymaps
Modified joystick.AppleRemote.xml : http://goo.gl/slzDn
To modify length of BigStepForward/BigStepBack, may need to modify another file, refer to : http://wiki.xbmc.org/?title=Advancedsettings.xml
Monday, May 07, 2012
How to make sure FolderPicker.SuggestedStartLocation work every time ?
Windows Metro style application provide a class : FolderPicker for application to select a target folder, it provide a standard interface for end user to select a folder for further operation.
By assign SuggestedStartLocation, we could ask FolderPicker to default at an assigned location for user to browse.
However, by default, FolderPicker will remember where user selected last time, and start at last location, ignore the assignment of SuggestedStartLocation.
Check MSDN documents, it seems that the property of settingsidentifier could do some trick :
http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.folderpicker.settingsidentifier.aspx
After I assign this property before call PickSingleFolderAsync, the problem solved, FolderPicker start at suggestedStartLocation each time when it show up :
folderPicker.SettingsIdentifier = DateTime.Now.ToString("HH:mm:ss tt");
StorageFolder folder = await folderPicker.PickSingleFolderAsync();
Use DatTime.Now.ToString just to make sure the string assigned is different every time, should be easy to replace with another solution.
By assign SuggestedStartLocation, we could ask FolderPicker to default at an assigned location for user to browse.
However, by default, FolderPicker will remember where user selected last time, and start at last location, ignore the assignment of SuggestedStartLocation.
Check MSDN documents, it seems that the property of settingsidentifier could do some trick :
http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.folderpicker.settingsidentifier.aspx
After I assign this property before call PickSingleFolderAsync, the problem solved, FolderPicker start at suggestedStartLocation each time when it show up :
folderPicker.SettingsIdentifier = DateTime.Now.ToString("HH:mm:ss tt");
StorageFolder folder = await folderPicker.PickSingleFolderAsync();
Use DatTime.Now.ToString just to make sure the string assigned is different every time, should be easy to replace with another solution.
Friday, May 04, 2012
Use WinRT API to get device information inside Metro style application
For some reason, we need to know USB port information for plugged USB device inside metro application.
Refer to MSDN :
It provides two set of namespace for access device information. By calling PnpObject.FindAllAsync, we could create a collection of device (filtered or not) :
PnpObjectCollection oo = await PnpObject.FindAllAsync(PnpObjectType.Device, properites );
foreach (PnpObject o in oo)
{
Debug.WriteLine(o.Id);
var pt = o.Properties.GetEnumerator();
while (pt.MoveNext())
{
if( pt.Current.Value != null )
Debug.WriteLine(pt.Current.Key + "=" + pt.Current.Value);
}
Debug.WriteLine(" ");
}
The secret here is how you assign those properties that you want in the second parameter of FindAllAsync . MSDN list some of them inside their pages :
System.Devices.InterfaceClassGuid
|
DEVPKEY_DeviceInterface_ClassGuid
|
Class GUID of the interface.
|
System.ItemNameDisplay
|
DEVPKEY_NAME
|
The friendly name of the device interface.
|
But also mention that for those not listed, you may query by defined GUID plus one pid string, so below is two example :
string[] properites = {
"System.ItemNameDisplay",
"System.Devices.ContainerId",
"{a45c254e-df1c-4efd-8020-67d146a850e0},15", // location info
"{540B947E-8B40-45BC-A8A2-6A0B894CBDA2},10" // bios device name
};
Below is the output result :
DISPLAY\ACI22FC\4&10c0f544&0&UID16843008
System.ItemNameDisplay=Generic PnP Monitor
{540B947E-8B40-45BC-A8A2-6A0B894CBDA2} 10=\_SB.PCI0.GFX0.DD01
DISPLAY\LGD2297\4&10c0f544&0&UID67568640
System.ItemNameDisplay=Generic PnP Monitor
{540B947E-8B40-45BC-A8A2-6A0B894CBDA2} 10=\_SB.PCI0.GFX0.DD03
USB\VID_0A12&PID_0001\6&18d9f06f&0&3
System.ItemNameDisplay=Generic Bluetooth Radio
System.Devices.ContainerId=29fb1cf5-7950-11e1-a117-806e6f6e6963
{A45C254E-DF1C-4EFD-8020-67D146A850E0} 15=Port_#0003.Hub_#0005
{540B947E-8B40-45BC-A8A2-6A0B894CBDA2} 10=\_SB.PCI0.EHC1.HUBN.PR01.PR13
USB\VID_093A&PID_2510\6&18d9f06f&0&1
System.ItemNameDisplay=USB Input Device
System.Devices.ContainerId=29fb1cf3-7950-11e1-a117-806e6f6e6963
{A45C254E-DF1C-4EFD-8020-67D146A850E0} 15=Port_#0001.Hub_#0005
{540B947E-8B40-45BC-A8A2-6A0B894CBDA2} 10=\_SB.PCI0.EHC1.HUBN.PR01.PR11
So that I got what I want, the monitor's BIOS device name, and port information of USB device.
Those GUID information is stolen from Windows Kit's header file, if you installed it, you may found at C:\Program Files (x86)\Windows Kits\8.0\Include\shared\devpkey.h
Basically, all those properties that displayed at Device Manager could be dump by this way.
Wednesday, April 25, 2012
How to have a VS project that contain Mofcomp command
1. New a project that based on "Template" -> "Visual C++" -> " Windows Driver" -> "Applications", and select "Empty DLL for Drivers"
2. Select Project->Property Pages, you may see Mof Compiler existing there.
3. After insert .mof file, VS will auto select Mofcomp as the build option.
Wednesday, March 14, 2012
Install Windows 8 consumer preview at virtualbox
Installed at w8 cp at VirtualBox in Ubuntu 11.10.
The default version of VirtualBox that came with 11.10 is version 4.1.2.
No Windows 8 option, so select others, system will up, and stop at recovery option.
Google found that 4.1.8+ version should already come with w8 option, update to 4.1.8, w8 up without problem.
Windows 8 consumer preview location :
http://windows.microsoft.com/en-US/windows-8/consumer-preview
VirtualBox location :
https://www.virtualbox.org/wiki/Downloads
The default version of VirtualBox that came with 11.10 is version 4.1.2.
No Windows 8 option, so select others, system will up, and stop at recovery option.
Google found that 4.1.8+ version should already come with w8 option, update to 4.1.8, w8 up without problem.
Windows 8 consumer preview location :
http://windows.microsoft.com/en-US/windows-8/consumer-preview
VirtualBox location :
https://www.virtualbox.org/wiki/Downloads
Friday, March 09, 2012
Google Spreadsheet ,TEXT() 函數, format 的語法
在一個對網路很不友善的環境下....(略)...
沒想到最廣泛被大家使用的竟然是 Google Doc ... 想想也合理... 因為 Outlook 空間過小... 不適合丟大檔案... 公司的 server 空間使用規定很嚴... 一切都要靠 VPN ... 所以最後大家都把檔案都丟 google doc... 也正好利用了他天生方便共筆的特性... 同步大家的資訊也容易....
所以.. 除了漸漸淡忘的 Excel 語法後... 我又開始學習 Google spreadsheet 比較進階的用法了....
" Google Spreadsheet 裡面 TEXT() 函數裡面, format 的用法.... http://goo.gl/00S5p "
Sunday, March 04, 2012
Build UEFI EDK2 UnixPkg 64bit under Ubuntu 11.10
Fellow the instruction here :
http://blog.xuite.net/meloscheng/note/56299386
Two place need to modify :
1. Link crt*.o to correct place :
root@neou11:/usr/lib# ls /usr/lib/crt* -l
lrwxrwxrwx 1 root root 32 2012-03-04 02:37 /usr/lib/crt1.o -> /usr/lib/x86_64-linux-gnu/crt1.o
lrwxrwxrwx 1 root root 32 2012-03-04 02:37 /usr/lib/crti.o -> /usr/lib/x86_64-linux-gnu/crti.o
lrwxrwxrwx 1 root root 32 2012-03-04 02:37 /usr/lib/crtn.o -> /usr/lib/x86_64-linux-gnu/crtn.o
2. Use GCC 4.6 instead of 4.4 :
neo@neou11:~/work/edk2-12898/UnixPkg$ svn diff build64.sh
Index: build64.sh
===================================================================
--- build64.sh (revision 12898)
+++ build64.sh (working copy)
@@ -41,7 +41,7 @@
# Pick a default tool type for a given OS
#
TARGET_TOOLS=MYTOOLS
-UNIXPKG_TOOLS=GCC44
+UNIXPKG_TOOLS=GCC46
NETWORK_SUPPORT=
case `uname` in
CYGWIN*) echo Cygwin not fully supported yet. ;;
Then SecMain could be built, and running.
Thursday, March 01, 2012
Don`t mess your environment, use schroot instead
以 Linux 當開發環境的人, 常在系統裡安裝一堆有的沒的 Library, 特別是要 match 某些 open source 的開發需求時, 有時候萬一一個不小心, 把你日常的桌面環境搞爆炸了, 復原或是重新安裝可就是一筆大工程...
在一個對網路不友善的環境中, 要是爆炸了, 那更是一種難受的折磨...
要是純是 x86 的開發需求, 可以用單純的 chroot 環境來應付, cross compiler 也有成熟的 sandbox mode 相關的工具, 另外 schroot 則是補足 chroot 的需求, 讓一般的用戶也可以切換到一個隔離的開發環境, 適合在多人分享的 build server 下使用...
This note is Chinese, but author too busy to finish them all :-(
http://novus.pixnet.net/blog/post/29322140-%E5%A5%BD%E7%94%A8%E7%9A%84-schroot
This note is English, but with simple step-by-step :-)
https://dev.launchpad.net/Running/Schroot
在一個對網路不友善的環境中, 要是爆炸了, 那更是一種難受的折磨...
要是純是 x86 的開發需求, 可以用單純的 chroot 環境來應付, cross compiler 也有成熟的 sandbox mode 相關的工具, 另外 schroot 則是補足 chroot 的需求, 讓一般的用戶也可以切換到一個隔離的開發環境, 適合在多人分享的 build server 下使用...
This note is Chinese, but author too busy to finish them all :-(
http://novus.pixnet.net/blog/post/29322140-%E5%A5%BD%E7%94%A8%E7%9A%84-schroot
This note is English, but with simple step-by-step :-)
https://dev.launchpad.net/Running/Schroot
Sunday, February 12, 2012
in_addr v.s. in_addr_t
There are lots function/macros designed to convert them :
in_addr_t inet_addr(const char *cp);
in_addr_t inet_lnaof(struct in_addr in);
struct in_addr inet_makeaddr(in_addr_t net, in_addr_t lna);
in_addr_t inet_netof(struct in_addr in);
in_addr_t inet_network(const char *cp);
char *inet_ntoa(struct in_addr in);
In fact, both in_addr_t, in_addr is defined in netinet/in.h :
#ifndef _IN_ADDR_T
#define _IN_ADDR_T
typedef __uint32_t in_addr_t;
#endif
struct in_addr {
in_addr_t s_addr;
};
Struct in_addr contain/hide detail of IP address, so if you need to record IP inside your program, use struct in_addr maybe a better idea then in_addr_t.
Thursday, February 09, 2012
Unhandled Lockdown error (-15)
在一個對網路不友善的環境中....(略)
公司的 Linux build machine, 因為沒有登入公司網域, 要連外更新時都是很頭痛的問題, 然後又沒有無線網卡, 也沒法透過我 iPhone 分享的無線網路出去
上次意外發現 Ubuntu 11.10 內建 ipheth 之後, 就解決了這個問題, 透過 USB 走我的 iPhone 出去, 結果昨天晚上 iPhone 白蘋果, 復原後, 今天早上就發現接上去的時候有問題沒法出去了
錯誤的訊息是 : "Unhandled Lockdown error (-15)", 跟上次我遇到的問題不一樣 (上次更新 libimobiledevice 之後就可以動了)
Google 後發現了解法 :
1. 移除~/.config/libimobiledevice, 重新連接一次
2. 安裝 libimobiledevice-utils, 重新 pairing 一次 : idevicepair unpair && idevicepair pair
我做到第一步之後就解了, 要是第一步不行, 以現在沒法連接外網的情況, 我又要手動複製 .deb 了, 這就痛苦了
看了一下 ~/.config/libimobiledevice 下, 好像是些認證的檔案, 也許重刷後這些翻新了, 導致之前配對的過程要重來一次吧
Reference :
Paulo (pauloerweber) wrote on 2011-11-18: #26
The unpair/pair commands worked on my iPad 1st Gen. Later to the commands, I removed ~/.config/libimobiledevice, rebooted the PC and only then connected the iPad (unlocked) on USB. After that, Ubuntu 11.10 was able to mount the iPad, even locked.almadana (almadana) wrote on 2011-11-22: #27
sudo apt-get install libimobiledevice-utils
idevicepair unpair && idevicepair pair
Tuesday, February 07, 2012
在一個對網路不友善的環境中
在一個對網路不友善的環境中....(略)
repo 預設會啟動4個 sync thread, 對於我小小的3G連外頻寬是個吃重的負荷, 可以用 -j 指定要用幾個 thread 抓 :
repo sync -j 1
repo 預設會啟動4個 sync thread, 對於我小小的3G連外頻寬是個吃重的負荷, 可以用 -j 指定要用幾個 thread 抓 :
repo sync -j 1
Thursday, February 02, 2012
How to manually add a new user account by command line in Mac OSX Snow Leopard
sh-3.2# dscl . -create /Users/svnuser
sh-3.2# dscl . -create /Users/svnuser UserShell /bin/bash
sh-3.2# dscl . -passwd /Users/svnuser passwd
sh-3.2# dscl . -create /Users/svnuser RealName SvnUser
sh-3.2# dscl . -create /Users/svnuser UniqueID 510
sh-3.2# dscl . -create /Users/svnuser PrimaryGroupID 80
sh-3.2# dscl . -create /Users/svnuser NFSHomeDirectory /Users/svnuser
sh-3.2# cp -R /System/Library/User\ Template/English.lproj/ /Users/svnuser
sh-3.2# chown -R svnuser:staff /Users/svnuser
Refer from :
sh-3.2# dscl . -create /Users/svnuser UserShell /bin/bash
sh-3.2# dscl . -passwd /Users/svnuser passwd
sh-3.2# dscl . -create /Users/svnuser RealName SvnUser
sh-3.2# dscl . -create /Users/svnuser UniqueID 510
sh-3.2# dscl . -create /Users/svnuser PrimaryGroupID 80
sh-3.2# dscl . -create /Users/svnuser NFSHomeDirectory /Users/svnuser
sh-3.2# cp -R /System/Library/User\ Template/English.lproj/ /Users/svnuser
sh-3.2# chown -R svnuser:staff /Users/svnuser
Refer from :
Friday, January 20, 2012
Useful rar command line
Usage: rar <command> - <switch 1> <switch N> <archive> <files....>
<@listfiles...> <path_to_extract\>
<Commands>
a Add files to archive
x Extract files with full path
<Switches>
So, normally we use :
It will be max compression level, with recovery record, and also multi-volume with 600MB for each files.
<@listfiles...>
<Commands>
x Extract files with full path
m<0..5> Set compression level (0-store...3-default...5-maximal)
rr[N] Add data recovery record
v[k,b] Create volumes with size=*1000 [*1024, *1]
So, normally we use :
rar a -m5 -rr -v600000k abc.rar abcfiles
It will be max compression level, with recovery record, and also multi-volume with 600MB for each files.
ssh config file to different machine, user, port
Normally we may have different account at different machine, including different user name or port.
* man page of ssh_config http://linux.die.net/man/5/ssh_config
When default ssh run, it will use your user name as default connection user name, and also port 22 for remote port.
We may use ssh -l login_name to overwrite user name, and ssh -p port to overwrite port number.
We may also have below text inside .ssh/config file to default some useful connection :
Host Home
User neo
Port 1234
HostName neozone.com
User neo
Port 1234
HostName neozone.com
Host Office
User neo_wong
Port 13579
HostName hellocompany.com
User neo_wong
Port 13579
HostName hellocompany.com
So that when we use ssh Home, it will equal to :
ssh -l neo -p 1234 neozone.com
It dont have have all field exist :
User neo
equal to :
ssh -l neo
* man page of ssh_config http://linux.die.net/man/5/ssh_config
Monday, January 02, 2012
Windows 下如何 dump DNS cache, 如何清除DNS cache
Dump DNS cache : ipconfig /displaydns
Clean DNS cache : ipconfig /flushdns
Clean DNS cache : ipconfig /flushdns
Outlook 2007 無法遠端存取公司 Exchange 郵件
為了避免登入公司 Domain 時被強制安裝很多監控軟體, 重裝了電腦, 這次不將帳號設成登入公司網域, 只在必要的時候連線公司網路進入 intranet 存取資源
唯一最重要要常常存取的東西就是公司的 mail, 公司的 exchange 預設可以遠端存取郵件, 只是這台新設好的電腦, 在遠端存取上一直發生問題, 出現以下的錯誤 :
[Proxy 伺服器的安全性憑證發生問題,
http://social.technet.microsoft.com/forums/zh-TW/exchangezhcht/thread/e24022ee-2b4d-4c7b-bded-eb7a826048f9
唯一最重要要常常存取的東西就是公司的 mail, 公司的 exchange 預設可以遠端存取郵件, 只是這台新設好的電腦, 在遠端存取上一直發生問題, 出現以下的錯誤 :
[Proxy 伺服器的安全性憑證發生問題,
-安全性憑證不是來自可信任的憑證授權單位,
-Outlook無法連線至Proxy伺服器mail.xxx.com.tw,(錯誤代碼8) ]
-Outlook無法連線至Proxy伺服器mail.xxx.com.tw,(錯誤代碼8) ]
google 了一下發現 :
http://social.technet.microsoft.com/forums/zh-TW/exchangezhcht/thread/e24022ee-2b4d-4c7b-bded-eb7a826048f9
對照有登入網域的電腦後, 發現我少了兩個憑證, 從那台電腦匯出, 這台匯入後, 就可以存取了 , 這樣我的 Outlook 運作正常, 就不需要沒事登入公司的網路了, 嘿嘿
Sunday, January 01, 2012
clear, more command missing in cygwin
Clear command did not default installed, you need to add ncurses package when install cygwin.
Also Ctrl+L could clear screen too, if you dont have clear.exe installed.
More command could be replace by less command, so set an alias should be able to fix it.
Also Ctrl+L could clear screen too, if you dont have clear.exe installed.
More command could be replace by less command, so set an alias should be able to fix it.
Subscribe to:
Posts (Atom)