$ ~/Library/Android/sdk/build-tools/23.0.2/aapt dump badging app-release.apk | grep package:\ name
package: name='aa.bb.cc' versionCode='###' versionName='######' platformBuildVersionName='#.#.#.####'
2016年10月4日 星期二
查看 APK 裡頭的 Package Name @ Mac OS 10.11.6
透過 aapt 工具,以 Mac OS 來說,大概落於 ~/Library/Android/sdk/build-tools/xxxx/aapt,用法:
2016年9月8日 星期四
Ansible 筆記 - 設定 Nginx 啟用 ngx_http_geoip_module.so 片段程式 @ Ubuntu 14.0
其實該寫成 Ansible Role 的,但一時之間有點懶,先把練習的片段紀錄一下。
安裝 nginx-module-geoip:
設定 nginx.conf:
如此一來,產生的 nginx.conf 如下:
查看 /var/log/nginx/access.log 就可以看到類似的範例:
更多變數定義,請參考:http://nginx.org/en/docs/http/ngx_http_geoip_module.html
安裝 nginx-module-geoip:
$ cat geoip-nginx.yml
---
- name: install geoip packages
apt: name={{ item }} update_cache=yes state=latest
with_items:
- nginx-module-geoip
when: install_package is defined and install_package
- name: check maxmind db - http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
command: bash -c 'test -e /data/GeoIP.dat || curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz | gunzip - > /data/GeoIP.dat'
- name: check maxmind db - http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
command: bash -c 'test -e /data/GeoLiteCity.dat || curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | gunzip - > /data/GeoLiteCity.dat'
設定 nginx.conf:
$ cat server-deploy.yml
...
tasks:
...
- include: geoip-nginx.yml
- name: setup nginx config file - add modules/ngx_http_geoip_module.so
lineinfile:
dest: /etc/nginx/nginx.conf
insertbefore: '^user '
line: 'load_module "modules/ngx_http_geoip_module.so";'
- name: setup nginx config file - setup geoip resource path
lineinfile:
dest: /etc/nginx/nginx.conf
insertafter: '^http {'
line: ' geoip_country /data/GeoIP.dat; geoip_proxy 192.168.0.0/16; geoip_proxy 10.0.0.0/24; geoip_proxy_recursive on;'
#line: ' geoip_city /data/GeoLiteCity.dat;'
- name: setup nginx file to enable geoip - update log format
lineinfile:
dest: /etc/nginx/nginx.conf
regexp: ".*?http_user_agent.*?http_x_forwarded_for"
line: " '\"$http_user_agent\" \"$http_x_forwarded_for\"' $geoip_country_code \"$geoip_country_name\" ;"
- name: setup nginx file to enable geoip - add GEOIP_COUNTRY_CODE for FastCGI
lineinfile:
dest: /etc/nginx/fastcgi_params
insertbefore: "^fastcgi_param QUERY_STRING"
line: "fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;"
如此一來,產生的 nginx.conf 如下:
$ cat /etc/nginx/nginx.conf && sudo nginx -t
load_module "modules/ngx_http_geoip_module.so";
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
geoip_country /data/GeoIP.dat; geoip_proxy 192.168.0.0/16; geoip_proxy 10.0.0.0/24; geoip_proxy_recursive on;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"' $geoip_country_code "$geoip_country_name" ;
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
查看 /var/log/nginx/access.log 就可以看到類似的範例:
.... CN,CHN,"China"
.... US,USA,"United States"
更多變數定義,請參考:http://nginx.org/en/docs/http/ngx_http_geoip_module.html
2016年9月7日 星期三
[Linux] Nginx 啟用 nginx-module-geoip @ Ubuntu 14.04
Nginx 從 1.9.1 起,支援 Dynamic Modules 囉,此例是想要使用 MaxMind 來進行 IP 反查,接著想說有沒有方便的整合方式,像是寫 PHP 就用 MaxMind PHP library 等。
接著,就先查一下自己的 nginx 情況吧!
很 OK ,接著再裝一下 ngx_http_geoip_module.so 吧!
下載 MaxMind 資料:
設置 Nginx,把 load_module 擺在最前頭
如此一來,就可以翻 /var/log/nginx/access.log 看看豐富的 GeoInfo 啦
接著,就先查一下自己的 nginx 情況吧!
$ nginx -V
nginx version: nginx/1.10.1
... 找關鍵字 ...
--with-http_geoip_module=dynamic
...
很 OK ,接著再裝一下 ngx_http_geoip_module.so 吧!
$ apt-cache search nginx-module-geoip
nginx-module-geoip - geoip module
$ sudo apt-get install nginx-module-geoip
...
The GeoIP dynamic module for nginx has been installed.
To enable this module, add the following to /etc/nginx/nginx.conf
and reload nginx:
load_module modules/ngx_http_geoip_module.so;
Please refer to the module documentation for further details:
http://nginx.org/en/docs/http/ngx_http_geoip_module.html
...
下載 MaxMind 資料:
$ curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz | gunzip - > /data/GeoIP.dat
$ curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | gunzip - > /data/GeoLiteCity.dat
設置 Nginx,把 load_module 擺在最前頭
$ sudo vim /etc/nginx/nginx.conf
load_module "modules/ngx_http_geoip_module.so";
...
http {
#geoip_country /data/GeoIP.dat;
geoip_city /data/GeoLiteCity.dat;
...
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'GeoCountry[ "$geoip_country_name" "$geoip_country_code" "$geoip_country_code3" ] '
'GeoCity[ "$geoip_city_country_code" "$geoip_city_country_code3" "$geoip_city_country_name" ] '
'GeoLocation[ "$geoip_latitude" "$geoip_longitude" "$geoip_region" "$geoip_region_name" "$geoip_city" "$geoip_postal_code" ] '
;
access_log /var/log/nginx/access.log main;
...
$ sudo service nginx reload
如此一來,就可以翻 /var/log/nginx/access.log 看看豐富的 GeoInfo 啦
2016年8月28日 星期日
[Mac] TOTO LINK N150UA @ MacOSX 10.11.6
經過黃色鬼屋買了一張 USB 無線網卡,結果就是一場災難的開始 XD (買的比網路上貴外,設定又如此搞剛)回來用 MacOSX 來測試,然後附贈的安裝 CD 跟 TOTO LINK (Ralink) 官網下載都無法成功設定,且文件上都說只支援 10.6 ~ 10.10 ,看來文件所敘無誤。
接著,開始翻他的硬體資訊,發現有 MediaTek 字樣!追了一下原來是 MediaTek 產出啊,網路上也看了幾篇 MTK 跨入無線網卡的新聞介紹,原來我 lag 那麼久 :P
最後,就是跑去 MediaTek 網站下載驅動程式(內含 Wireless Utility):MT7612_7610U_D5.0.1.25_SDK1.0.2.18_UI5.0.0.27_20151209
- http://www.mediatek.com/zh-TW/products/connectivity/wi-fi-new/
- http://www.mediatek.com/en/downloads1/downloads/
- http://www.mediatek.com/en/downloads1/downloads/mt7610u/
透過這次我也才明瞭在 MacOSX 設置 USB 無線網卡時,基本上都是透過第三方軟體設置的,且在 MacOSX 自身的網路偏好設定只能觀看而無法設定
2016年8月22日 星期一
[Mac] MacPorts: no destroot found @ Mac OSX 10.11.6
前陣子一直在測試相容性問題,不斷地用 sudo port -fp uninstall installed 清光軟體。但一直懶沒把所有相依性刪光,在安裝 py-pip27 時,就會蹦出以下錯誤訊息:
解法就是老老實實參考 MacPorts - 2.4. Uninstall 官方文件清資料,仔細做了以下動作:
下載並安裝最新版 MacPorts: https://distfiles.macports.org/MacPorts/MacPorts-2.3.4-10.11-ElCapitan.pkg
重新安裝需要的軟體:
$ sudo port install py27-pip
---> Computing dependencies for py27-pip
---> Installing py27-pip @8.1.2_0
Error: org.macports.install for port py27-pip returned: no destroot found at: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_python_py-pip/py27-pip/work/destroot
Please see the log file for port py27-pip for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_python_py-pip/py27-pip/main.log
To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Error: Processing of port py27-pip failed
解法就是老老實實參考 MacPorts - 2.4. Uninstall 官方文件清資料,仔細做了以下動作:
$ sudo rm -rf /opt/local/ ~/.macports
下載並安裝最新版 MacPorts: https://distfiles.macports.org/MacPorts/MacPorts-2.3.4-10.11-ElCapitan.pkg
重新安裝需要的軟體:
$ sudo port selfupdate
$ sudo port install py27-pip
訂閱:
文章 (Atom)