2015-08-11

「可疑 IP 列表」
 可疑 IP 有可能是電腦被綁架,大多非主動攻擊者,但都有攻擊現象,故建議短期內還是加入 「IP 阻攔列表裡」


192.187.110.98
182.118.53.125
218.246.34.99
185.78.112.26
104.236.212.155
137.226.113.7




2015-07-31

使用 python + django 做一個大數據網路平台


你是不是想知道使用 python + django 做一個大數據網路平台可以做到什麼樣的程度?
我發現 這裡 比異鳥 (http://www.biyibird.info) 有個網站,它使用了 python + django + search engine + jquery
很輕鬆的從龐大數據庫內抓取必要的資料,並減少資料庫的負擔。
想寫好一篇作文最佳的捷徑就是多看些文章
想學 python 的人最好的方式就是多參考一些網站,這個網站大家可以多多瀏覽、瞭解、參考看看



2015-07-29

Using .htaccess to redirect from one domain to another

If you want to redirect your www.from.com  to  www.to.com

[.htaccess]
in your root directory(or sub-directory, according to ur needs), create an .htaccess file, and input content below.


RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.from.com$ [NC]
RewriteRule ^(.*)$ http://www.to.com/$1 [R=301,L]


[例子]
RewriteEngine On
# 從  from.com  轉到 www.to.info
RewriteCond %{HTTP_HOST} ^from\.com$ [NC]
RewriteRule ^(.*)$ http://www.to.info/$1 [L,R=301]
# 從  www.from.com  轉到 www.to.info
RewriteCond %{HTTP_HOST} ^www\.from\.com$ [NC]
RewriteRule ^(.*)$ http://www.to.info/$1 [R=301,L]



[try]

go to browser URL input http://www.from.com/account/login and then you will be redirected to http://www.to.com/account/login

URI is corrected be mapped.





2015-06-17

mysql log error

如果你的 mysql log 有以下訊息
Native table 'performance_schema'.'file_instances' has the wrong structure
Native table 'performance_schema'.'cond_instances' has the wrong structure
Native table 'performance_schema'.'rwlock_instances' has the wrong structure
Native table 'performance_schema'.'mutex_instances' has the wrong structure
...

原因是你的資料庫結構是舊的,而你用的mysql卻是新的

2015-06-05

django 樣版 列出所有 form error 的方法

django 樣版 列出所有 form error 的方法
{{form.non_field_errors}} ==> 列出 global error
{{ field.errors }} ==> 跟欄位有關的 error


方法一:
         {% if form.errors %}
          <div class="alert alert-error">
            <button type="button" class="close" data-dismiss="alert">×</button>
            {{form.non_field_errors}}
            {% for field in form %}
              {% if field.errors %}
                <li>{{ field.label }}: {{ field.errors }}</li>
              {% endif %}
            {% endfor %}
          </div>
        {% endif %}



方法二:
            {% for field, errors in form.errors.items %}
              {% for error in errors %}
                {{error}}
              {% endfor %}
            {% endfor %}
                     


註:只帶訊息不帶 <ul> <li> 方法
form.errors.backup_email.0 (加個.0 , 取 str)

2015-05-12

django compressor 找不到 offline manifest 問題解法

如果你用 django compressor,而且你用的是 offline compress
COMPRESS_ENABLED = True
COMPRESS_OFFLINE = True
那麼你有可能會遇到以下錯誤訊息

  1. You have offline compression enabled but key "70be2d0f8286eb3a32bfe94a55518c8f" is missing from offline manifest. You may need to run "python manage.py compress".
這代表你的 compress tag 包夾的內容含有動態性的資料
因為 compressor 是用內容 hash 成 hash code 去 lookup cached javascript
所以 offline compress 的東西產生的 hash code 會跟你線上得到的 code 不一樣
例如以下這個例子,拿掉{{user.email}}即可正常
  1. {% compress js %}
  2. ......
  3. formData.append('email', '{{ user.email }}');
  4. ......
  5. {% endcompress %}
請確保你的 compress 是壓縮最內層、乾淨的「靜態」資料

2015-05-01

javascript 中文字長度判斷

因為現在網頁幾乎都是 utf8, 所以以往中文字會被判斷成2 bytes的問題現在都變成1了
例如
var s="中"
alert(s.length)
結果會顯示 1

那麼你若想要判斷 byte 的長度怎麼辦? (因為有時資料庫長度限制需求)
這裡有個網路上網友提供的好方法,速度快,又不用 regular express 或 encodeURIComponent