syntax on
set t_Co=256
set bg=dark
set modeline
set shiftwidth=4
set softtabstop=4
set expandtab
set background=dark
2015年6月20日 星期六
[Tips] ERROR SOLUTION DURING FIRMWARE UPDATE HUAWEI MODEM
最近有一張 Huawei E398-u1 的網卡不知道為什麼無法連線, 結果找到幾個新版的 firmware, 更新一直要問密碼...
Error Solution:
http://www.modemunlock.com/error-solution-during-firmware-update-huawei-modem.html
Huawei modem unlock code and flash code calculator:
http://www.modemunlock.com/huawei.php
DC-unlocker client(看IMEI)
https://www.dc-unlocker.com/downloads
Error Solution:
http://www.modemunlock.com/error-solution-during-firmware-update-huawei-modem.html
Huawei modem unlock code and flash code calculator:
http://www.modemunlock.com/huawei.php
DC-unlocker client(看IMEI)
https://www.dc-unlocker.com/downloads
2015年2月19日 星期四
[Python] PEP8 Coding Style + 基本 Vim 設定
PEP8 落落長, 常用的紀錄一下吧
以下文字大多從這篇來的
1. 以 4 個空格進行縮排
2. 利用 4 個空格取代 Tab
3. 限制每行最多 79 字元
4. Top level 的函數與類別之間用空 2 行進行區隔
5. 類別內的方法,以空 1 行進行區隔
6. 程式檔案編碼使用 UTF-8
7. import 模組應該 1 行 1 個
8. import 需有次序之別,並且群組間以空行區隔
9. 不使用 Wildcard imports
10. 不需使用空格對齊
11. 不需在參數的等號(=)旁邊增加空格
12. 模組名稱應儘量短,並全部小寫
13. 類別名稱應使用 CapWords 命名
14. 函數名稱應使用小寫
15. 常數(Constants)應大寫,並以底線分割單字
另外 vim 的設定也可以注意一下
reference: 隨手養成 Python 好習慣 - PEP8 Coding Style、Vim 基本設定
以下文字大多從這篇來的
1. 以 4 個空格進行縮排
2. 利用 4 個空格取代 Tab
3. 限制每行最多 79 字元
4. Top level 的函數與類別之間用空 2 行進行區隔
5. 類別內的方法,以空 1 行進行區隔
6. 程式檔案編碼使用 UTF-8
7. import 模組應該 1 行 1 個
8. import 需有次序之別,並且群組間以空行區隔
9. 不使用 Wildcard imports
10. 不需使用空格對齊
11. 不需在參數的等號(=)旁邊增加空格
12. 模組名稱應儘量短,並全部小寫
13. 類別名稱應使用 CapWords 命名
14. 函數名稱應使用小寫
15. 常數(Constants)應大寫,並以底線分割單字
另外 vim 的設定也可以注意一下
set tabstop=4 set shiftwidth=4 set softtabstop=4 set smarttab set expandtab nnoremap <F2> :<C-U>setlocal lcs=tab:>-,trail:-,eol:$ list! list? <CR>按 F2 可以顯示 Tab 和空格
reference: 隨手養成 Python 好習慣 - PEP8 Coding Style、Vim 基本設定
2015年2月12日 星期四
[Tips] AWS EC2加大硬碟
總是要手忙腳亂, 最重要的就是要先備份
官方的文件其實蠻清楚的, 就是這篇
簡單紀錄步驟
1. 備份(做 snapshot)
2. 建立新的 volume(注意要和舊的 volume 在同一個 zone)
3. stop instance
4. 將舊的 volume 卸載
5. 將新的 volume 裝載, 使用剛剛的 snapshot, 並且 mount 到 /dev/sda1
6. start instance
7. IP 會跑掉, 所以 DNS 要改
真是心驚膽跳阿!!
對了, 這次才發現不同的 SSD 有不同的價格和建議用途, 參考這張表吧
reference:
* How to upgrade EC2 Ubuntu Linux micro instance to small
* Expanding the Storage Space of a Volume on Linux
* How to Increase Disk Space on an Amazon EC2 Instance
官方的文件其實蠻清楚的, 就是這篇
簡單紀錄步驟
1. 備份(做 snapshot)
2. 建立新的 volume(注意要和舊的 volume 在同一個 zone)
3. stop instance
4. 將舊的 volume 卸載
5. 將新的 volume 裝載, 使用剛剛的 snapshot, 並且 mount 到 /dev/sda1
6. start instance
7. IP 會跑掉, 所以 DNS 要改
真是心驚膽跳阿!!
對了, 這次才發現不同的 SSD 有不同的價格和建議用途, 參考這張表吧
reference:
* How to upgrade EC2 Ubuntu Linux micro instance to small
* Expanding the Storage Space of a Volume on Linux
* How to Increase Disk Space on an Amazon EC2 Instance
[RPi] 用HUAWEI E397u-53上網
E397u-53 規格可參考這篇
- 4G LTE FDD - (B13/B20) 700/800/1500Mhz.
- 3G/2G CDMA - 800/1900Mhz.
前面步驟省略, 參考這篇, 但有三個檔案要注意
因為我是用種花的, 所以不支援這張網卡, 所以也是測心酸的
- 4G LTE FDD - (B13/B20) 700/800/1500Mhz.
- 3G/2G CDMA - 800/1900Mhz.
前面步驟省略, 參考這篇, 但有三個檔案要注意
$ sudo vim /lib/udev/rules.d/40-usb_modeswitch.rules
ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1505", RUN+="usb_modeswitch '%b/%k'"
sudo vim /etc/usb_modeswitch.conf
DefaultVendor=0x12d1 DefaultProduct=0x1505 TargetVendor=0x12d1 TargetProduct=0x1506 MessageContent="5553424312345678000000000000061e000000000000000000000000000000"
$ sudo vim /etc/wvdial.conf
[Dialer E397] Phone = *99# APN = internet Username = username Password = password Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init3 = AT+CGDCONT=1, "IP","Internet" Modem = /dev/ttyUSB1 Baud = 460800 Stupid Mode = 1
因為我是用種花的, 所以不支援這張網卡, 所以也是測心酸的
2015年1月27日 星期二
[Python] 使用bottle.py寫web應用程式
沒辦法, 太菜了, 只好從之 ajax 開始學起...
這篇有投影片可下載, 其中有些參考資源不錯
例如一些 python web framework 的比較, 幾個 hello world 範例
這篇有簡單的範例, 程度差不多就是 1+1=2 的水準
main.py
json.tpl
執行: python main.py
另外這篇還有教 MVC 的寫法, 不過現在用不到 @@
這篇有投影片可下載, 其中有些參考資源不錯
例如一些 python web framework 的比較, 幾個 hello world 範例
這篇有簡單的範例, 程度差不多就是 1+1=2 的水準
main.py
#!/usr/bin/env python
from bottle import route, run, template, debug
debug(True)
# this will be the dictionary returned by the ajax call.
# Bottle convert this in a json compatibile string.
items = {1: 'first item', 2: 'second item'}
# a simple json test main page
@route('/')
def jsontest():
return template('json')
@route('/getallitems.json')
def shop_aj_getallitems():
return (items)
run(host='localhost', port=8080)
json.tpl
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
var xmlhttp;
// Are we using a modern browser or ...
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
// This will render the two output which substitute the
// elements id="raw" and id="forin"
function GetItems()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
// var jsonobj = eval ("(" + xmlhttp.responseText + ")");
var jsonobj = JSON.parse(xmlhttp.responseText);
var output = xmlhttp.responseText;
document.getElementById("raw").innerHTML = output;
output = "";
for (i in jsonobj) {
output += '<p>';
output += i + " : " + jsonobj[i];
output += '</p>';
}
document.getElementById("forin").innerHTML = output;
} else {
alert("data not available");
}
}
// xmlhttp.onreadystatechange = GetArticles;
// the GetItems function will be triggered once the ajax
// request is terminated.
xmlhttp.onload = GetItems;
// send the request in an async way
xmlhttp.open("GET", "/getallitems.json", true);
xmlhttp.send();
</script>
</head>
<body>
<p>The raw result from the ajax json request is:</p>
<div id="raw"></div>
<br />
<p>The for cycle produces :</p>
<div id="forin"></div>
</body>
</html>
執行: python main.py
另外這篇還有教 MVC 的寫法, 不過現在用不到 @@
2015年1月23日 星期五
訂閱:
文章 (Atom)
