2016年3月11日 星期五

$Windows.~BT 與 $Windows.~WS 強迫升級 Windows 10

最近在兩週內連續被強迫兩次下載了 Windows 10 的 image。其中一次還用了手機的4G下載……。為了免麻煩所以記錄一下如何移除好了

首先是移除這個更新。這個更新會使得電腦自動下載 Windows 10 的 image。
KB3035583
再來是在 cmd 中打不下列命令,這樣檔案就可以移除了
takeown /F C:\$Windows.~BT\* /R /A
icacls C:\$Windows.~BT\*.* /T /grant administrators:F
rmdir /S /Q C:\$Windows.~BT\

參考網頁:
小心電腦會自行下載龐大的Windows 10安裝檔,即使你沒預約升級! | iThome
Can I delete $Windows.~BT & $Windows.~WS folders?

2016年3月7日 星期一

Extracting all zip in a directory to separated folder according to zip's name

Two things to do.

1. download 7za.exe, which can be found in the package "7-Zip Extra: standalone console version, 7z DLL, Plugin for Far Manager" in this page.

2. Extract 7za.exe to the folder that contains the zip you want to unzip. Use the command to unzip.
7za x *.zip -o*

2016年2月19日 星期五

一些與hadoop有關的命令記錄

直接對同機台上另一個帳號下命令

su hdfs -c '~/hdfs/sbin/stop-dfs.sh'

使用hadoop streaming

bin/hadoop jar share/hadoop/tools/lib/hadoop-streaming-2.7.1.jar \
    -input /usr/ctfan/input01 \
    -output /usr/ctfan/output/folder \
    -mapper mapper.py \
    -reducer reducer.py \
    -file ~/ctfan/pyStreaming/mapper.py \
    -file ~/ctfan/pyStreaming/reducer.py

mapper.py

#!/usr/bin/env python
import sys
for line in sys.stdin:
    line = line.strip()
    words = line.split()
    for word in words:
        print '%s\t%s' % (word, 1)

reducer.py

#!/usr/bin/env python
from operator import itemgetter
import sys
current_word = None
current_count = 0
word = None
for line in sys.stdin:
    line = line.strip()
    word, count = line.split('\t', 1)
    try:
        count = int(count)
    except ValueError:
        continue

    if current_word == word:
        current_count += count
    else:
        if current_word:
            print '%s\t%s' % (current_word, current_count)
        current_count = count
        current_word = word

if current_word == word:
    print '%s\t%s' % (current_word, current_count)

單機測試streaming命令

echo 'a b c a b' | ./mapper.py | sort -k1,1 | ./reducer.py

參考網頁

hadoop官方文件
Michael G. Noll's Blog