Somewhere I Belong

All about geek's life


  • 首頁

  • 歸檔

  • 關於

  • 標籤

  • 開源專案

Linux Find 指令找出前幾大的檔案或資料夾

發表於 5月 29 2014 | 0 Comments

找前 10 大的檔案

find node_modules -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
265K    node_modules/hexo-generator-minify/node_modules/css-condense/extras/trello.css
271K node_modules/hexo-generator-minify/node_modules/css-condense/extras/diff.txt
283K node_modules/hexo-generator-minify/node_modules/css-condense/extras/soundcloud.condensed3b_yui.css
284K node_modules/hexo-generator-minify/node_modules/css-condense/extras/soundcloud.condensed3b.css
297K node_modules/hexo-generator-minify/node_modules/css-condense/extras/soundcloud.yui.css
317K node_modules/hexo-generator-minify/node_modules/css-condense/extras/github.diff
325K node_modules/hexo-generator-minify/node_modules/css-condense/extras/soundcloud.css
339K node_modules/hexo-generator-minify/node_modules/css-condense/extras/yahoo.diff
457K node_modules/hexo-generator-minify/node_modules/css-condense/extras/trello.diff
499K node_modules/hexo-generator-minify/node_modules/css-condense/extras/soundcloud.diff

找前 10 大的資料夾

find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
1.9M    ./.deploy
3.8M ./node_modules/hexo-migrator-wordpress/node_modules
3.8M ./node_modules/hexo-migrator-wordpress
4.4M ./themes
8.2M ./node_modules/hexo-generator-minify/node_modules/css-condense/extras
8.7M ./node_modules/hexo-generator-minify/node_modules/css-condense
9.5M ./node_modules/hexo-generator-minify/node_modules
9.5M ./node_modules/hexo-generator-minify
15M ./node_modules
22M .

差異就在 find 的 -type d 跟 -type f 分別代表 directory 與 file

如果要變成前 20 大,只要改 tail -10 變成 tail -20

source: Linux utility for finding the largest files/directories

mount -o remount,rw /

發表於 5月 27 2014 | 0 Comments

隨手記一下, 有些機器預設掛載不能寫入

mount -o remount,rw /

MQTT Mosquitto 移植 arm9 平台

發表於 5月 16 2014 | 0 Comments

今天在公司弄一些 RD Award 的東西,就順手把 mosquitto 移植到公司產品上

不囉嗦先準備好 ARM9 32-bit RISC CPU toolchain 然後把一些環境變數設定好

建立一個 build.sh 內容物如下…

#!/bin/sh

MACH=arm9 #xscale

if [[ "${MACH}" = xscale ]]; then
trueTOOLCHAIN="/usr/local/arm-linux-4.4.2-v4"
trueHOST="arm-none-linux-gnueabi"
else
trueTOOLCHAIN="/usr/local/arm-linux"
trueHOST="arm-linux"
fi

# export shell environment variables
export PATH="${PATH}:${TOOLCHAIN}/bin"
export CPP="${HOST}-gcc -E"
export STRIP="${HOST}-strip"
export OBJCOPY="${HOST}-objcopy"
export AR="${HOST}-ar"
export RANLIB="${HOST}-ranlib"
# This is due to linker doesn't take the 'rpath' parameter
#export LD="${HOST}-ld"
export LD="${HOST}-g++"
export OBJDUMP="${HOST}-objdump"
export CC="${HOST}-gcc"
export CXX="${HOST}-g++"
export NM="${HOST}-nm"
export AS="${HOST}-as"

make clean
make

上面這些參數設定基本上就依照不同情況去做一些調整,網路上有些 crosscompile 的文章可以參考看看 (裡面的 MACH 改成 xscal 是我要移植到另一台用的)

Compile 過程當中會遇到兩個錯誤,分別是…

net_mosq.c: In function `_mosquitto_try_connect':
net_mosq.c:235: error: `AI_ADDRCONFIG' undeclared (first use in this function)
net_mosq.c:235: error: (Each undeclared identifier is reported only once
net_mosq.c:235: error: for each function it appears in.)
make[1]: *** [net_mosq.o] Error 1

上面這個 AI_ADDRCONFIG 可參考 RFC 2553 裡面的描述…

The AI_ADDRCONFIG flag specifies that a query for AAAA records
should occur only if the node has at least one IPv6 source
address configured and a query for A records should occur only
if the node has at least one IPv4 source address configured.

For example, if the node has no IPv6 source addresses
configured, and af equals AF_INET6, and the node name being
looked up has both AAAA and A records, then:

(a) if only AI_ADDRCONFIG is specified, the function
returns a NULL pointer;
(b) if AI_ADDRCONFIG | AI_V4MAPPED is specified, the A
records are returned as IPv4-mapped IPv6 addresses;

總之就是 IPv6 的東東,於是我們可以在檔案 mosquitto/src/lib/net_mosq.h 69行附近加入

#ifndef AI_ADDRCONFIG
#define AI_ADDRCONFIG 0x0000
#endif

大功告成讓我們繼續看下去…

嗯,很好又遇到錯誤了

net.c:342: error: `IPV6_V6ONLY' undeclared (first use in this function)
net.c:342: error: (Each undeclared identifier is reported only once
net.c:342: error: for each function it appears in.)
make[1]: *** [net.o] Error 1

原來是 IPV6_V6ONLY 沒有定義阿…依據 google 所以我們簡單把他設定為一個 nonzero 就可以了

IPV6_V6ONLY (since Linux 2.4.21 and 2.6)
If this flag is set to true (nonzero), then the socket is re‐
stricted to sending and receiving IPv6 packets only. In this
case, an IPv4 and an IPv6 application can bind to a single
port at the same time.

If this flag is set to false (zero), then the socket can be
used to send and receive packets to and from an IPv6 address
or an IPv4-mapped IPv6 address.

The argument is a pointer to a boolean value in an integer.

The default value for this flag is defined by the contents of
the file /proc/sys/net/ipv6/bindv6only. The default value for
that file is 0 (false).

在檔案的 mosquitto/src/net.c 第 75 行左右加入

#ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 1
#endif

大功告成啦~ Hooooooray~

快快樂樂享受 Mosquitto 吧~ 我們下次見~

後記:其實過程當中一度編譯成功但是 mosquitto_sub, mosquitto_pub 這兩隻一直不能正常運作,mosquitto 可以動(但是 bridge mode 不行),還想說到底是哪裡有病阿…結果原來是我網路上抄來的 AI_ADDRCONFIG 這個數值害慘了…因為有些定義成 0x0020 我直接拿來用顯然是錯誤的 0x0000 在我們的 case 中才是正解,所以鄉親啊!!!要注意。

一本創業電子書

發表於 5月 11 2014 | 0 Comments

這兩天在網路上看到人家在轉貼一個電子書是有關於創業的,感覺滿有意思的就下載來看看…

他的網站是 Startup 2.0 工程師創業手冊 – 高科技創業經驗分享

電子書下載的 頁面

從事資訊相關對創業有興趣但是沒有概念與想法可以當作小說參考看看,提早認知一些過來人的經驗感覺挺不錯的!感謝原作者願意分享他一路上的寶貴經驗 :)

(我還沒看完,看完有心得再補上。)

反反情蒐之直書轉橫書

發表於 5月 7 2014 | 0 Comments

這兩天看到網路上有人寫了一個反情蒐網頁

剛好我來練習包 Node.js NPM 於是就誕生了…反反情蒐 (就是惡搞再把直書轉回來)

看看政府的網軍要不要把他撿回去用啊 XDDDDDD

NPM 位置:https://www.npmjs.org/package/chinese-writing-style-converter

為什麼瀏覽器 user-agent string 總是包含 Mozilla/5.0 ?

發表於 6月 2 2013 | 分類於 有趣的問題 | 3 Comments

最近從 eit.tw 短網址服務後台觀察到一個很神奇的現象,其實也不是最近才看到是今天終於記得要上網問 Google 大神這個問題了 XD

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36

Mozilla/5.0 (Linux; U; Android 4.1.2; zh-tw; GT-I9300 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)

閱讀全文 »

Gearman 安裝心得 (Ubuntu)

發表於 5月 30 2013 | 分類於 PHP | 0 Comments

安裝

先把安裝來源加入

sudo add-apt-repository ppa:gearman-developers/ppa
sudo aptitude update

直接下指令安裝
sudo aptitude install gearman

閱讀全文 »

2013 JSDC 心得 (還沒寫)

發表於 5月 27 2013 | 分類於 JavaScript | 0 Comments

剛剛在網路上看到 2013 JSDC 的懶人包,有空應該要來吸收一下新知

就算不是很懂也可以瞧瞧,了解一下前端技術的發展動向

懶人包

用 vsFTPd 架設作業上傳環境 (以 Ubuntu 為例)

發表於 5月 26 2013 | 分類於 Linux | 0 Comments

請先安裝 vsFTPd 方法應該不用多說,Google 有很多很多很多

我比較在意的是如何設定讓使用者符合下列行為:

  • 只能上傳 (能上傳才能交作業嘛)
  • 不能下載 (參考看別人作業)
  • 不能刪除 (errr…誤刪別人作業)
  • 除了交作業帳號外其他帳號不受影響 (要不然我也不能用啦)
    閱讀全文 »

OpenCV (C# Emgu) 物件追蹤程式,使用 Camshift 演算法

發表於 5月 26 2013 | 分類於 C# , 影像處理 | 0 Comments

這學期擔任影像處理助教,所以要出作業給學弟妹練習一下 OpenCV
會使用 Emgu 不外乎是環境好建置,只要把將範例專案做好基本上下載回去能馬上使用
可以專心在撰寫功能不需要去建置環境,雖然說建置環境對一個工程師也是一項基本功啦…

閱讀全文 »
1…67

YuLun Shih

70 文章
6 分類
127 標籤
RSS
GitHub E-Mail Twitter
© 2017 YuLun Shih