$ ls ~/Library/Application\ Support/iPhone\ Simulator/7.1/Applications/
最近改用 iOS 8 時,卻找不到 8.0 位置 XD 直到在 App 中印出位置才得知換了,粗略位置:
$ ls ~/Library/Developer/CoreSimulator/Devices/########-####-####-####-###########/data/Containers/Data/Application/
$ ls ~/Library/Application\ Support/iPhone\ Simulator/7.1/Applications/
$ ls ~/Library/Developer/CoreSimulator/Devices/########-####-####-####-###########/data/Containers/Data/Application/
$ ls /usr/share/locale | grep -v "\\." | grep "_"
af_ZA
am_ET
be_BY
bg_BG
ca_ES
cs_CZ
da_DK
de_AT
de_CH
de_DE
el_GR
en_AU
en_CA
en_GB
en_IE
en_NZ
en_US
es_ES
et_EE
eu_ES
fi_FI
fr_BE
fr_CA
fr_CH
fr_FR
he_IL
hr_HR
hu_HU
hy_AM
is_IS
it_CH
it_IT
ja_JP
kk_KZ
ko_KR
lt_LT
nl_BE
nl_NL
no_NO
pl_PL
pt_BR
pt_PT
ro_RO
ru_RU
sk_SK
sl_SI
sr_YU
sv_SE
tr_TR
uk_UA
zh_CN
zh_HK
zh_TW
$ cd /usr/share/locale && echo ??_??
af_ZA am_ET be_BY bg_BG ca_ES cs_CZ da_DK de_AT de_CH de_DE el_GR en_AU en_CA en_GB en_IE en_NZ en_US es_ES et_EE eu_ES fi_FI fr_BE fr_CA fr_CH fr_FR he_IL hr_HR hu_HU hy_AM is_IS it_CH it_IT ja_JP kk_KZ ko_KR lt_LT nl_BE nl_NL no_NO pl_PL pt_BR pt_PT ro_RO ru_RU sk_SK sl_SI sr_YU sv_SE tr_TR uk_UA zh_CN zh_HK zh_TW
<?php
// http://www.localeplanet.com/icu/
$lang_map = array(
'af_ZA' => 'Afrikaans (Suid-Afrika)',
'am_ET' => 'አማርኛ (ኢትዮጵያ)' ,
'be_BY' => 'беларуская (Беларусь)' ,
'bg_BG' => 'български (България)',
'ca_ES' => 'català (Espanya)',
'cs_CZ' => 'čeština (Česká republika)',
'da_DK' => 'dansk (Danmark)',
'de_AT' => 'Deutsch (Österreich)',
'de_CH' => 'Deutsch (Schweiz)',
'de_DE' => 'Deutsch (Deutschland)',
'el_GR' => 'Ελληνικά (Ελλάδα)',
'en_AU' => 'English (Australia)',
'en_CA' => 'English (Canada)',
'en_GB' => 'English (United Kingdom)',
'en_IE' => 'English (Ireland)',
'en_NZ' => 'English (New Zealand)',
'en_US' => 'English (United States)',
'es_ES' => 'español (España)',
'et_EE' => 'eesti (Eesti)' ,
'eu_ES' => 'euskara (Espainia)',
'fi_FI' => 'suomi (Suomi)',
'fr_BE' => 'français (Belgique)',
'fr_CA' => 'français (Canada)',
'fr_CH' => 'français (Suisse)',
'fr_FR' => 'français (France)',
'he_IL' => 'עברית (ישראל)',
'hr_HR' => 'hrvatski (Hrvatska)',
'hu_HU' => 'magyar (Magyarország)',
'hy_AM' => 'Հայերէն (Հայաստանի Հանրապետութիւն)',
'is_IS' => 'íslenska (Ísland)',
'it_CH' => 'italiano (Svizzera)' ,
'it_IT' => 'italiano (Italia)',
'ja_JP' => '日本語(日本)',
'kk_KZ' => 'kk_KZ',
'ko_KR' => '한국어(대한민국)',
'lt_LT' => 'lietuvių (Lietuva)',
'nl_BE' => 'Nederlands (België)',
'nl_NL' => 'Nederlands (Nederland)',
'no_NO' => 'no_NO',
'pl_PL' => 'polski (Polska)',
'pt_BR' => 'português (Brasil)',
'pt_PT' => 'português (Portugal)',
'ro_RO' => 'română (România)',
'ru_RU' => 'русский (Россия)',
'sk_SK' => 'slovenčina (Slovenská republika)',
'sl_SI' => 'slovenščina (Slovenija)',
'sr_YU' => 'sr_YU',
'sv_SE' => 'svenska (Sverige)',
'tr_TR' => 'Türkçe (Türkiye)',
'uk_UA' => 'українська (Україна)',
'zh_CN' => '中文(简体中文、中国)',
'zh_HK' => '中文(繁體中文,中華人民共和國香港特別行政區)',
'zh_TW' => '中文(繁體中文,台灣)'
);
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert cert.pem -key key.pem
$ cat cert.pem key.pem > out.pem
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert out.pem
$ openssl rsa -in key.pem -out nopass.pem
$ openssl s_client -connect gateway.push.apple.com:2195 -cert cert.pem -key key.pem
$ grep -v "^localhost\|::1" /var/log/apache2/access.log | awk '{print $1}' | uniq
$ wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
$ gunzip GeoLite2-City.mmdb.gz
$ sudo apt-get install geoip-bin
$ geoiplookup 8.8.8.8
GeoIP Country Edition: US, United States
$ geoiplookup -f GeoLite2-City.mmdb 8.8.8.8
Error Traversing Database for ipnum = 134744072 - Perhaps database is corrupt?
Segmentation fault (core dumped)
$ sudo pip install geoip2
$ vim t.py
mport sys
import geoip2.database
reader = geoip2.database.Reader('GeoLite2-City.mmdb')
try:
response = reader.city(sys.argv[1])
print str(response.location.latitude)+","+str(response.location.longitude)
except Exception, e:
pass
$ python t.py 8.8.8.8
37.386,-122.0838
$ sudo cp /var/log/apache2/access.log /tmp/access.log
$ sudo chmod 644 /tmp/access.log
$ vim log.py
import geoip2.database
reader = geoip2.database.Reader('GeoLite2-City.mmdb')
try:
log = open('/tmp/access.log','rb').read()
for rec in log.split('\n'):
fields = rec.split(' ')
try:
if fields[0] == 'localhost' or fields[0] == '::1' :
continue
response = reader.city(fields[0])
print fields[3][1:]+","+str(response.location.latitude)+","+str(response.location.longitude)
except Exception, e:
pass
except Exception, e:
pass
$ python log.py > log.csv
$ cat log.csv
...
07/Sep/2014:22:12:43,35.685,139.7514
07/Sep/2014:22:13:53,39.4899,-74.4773
...
$ gsutil config
This command will create a boto config file at /home/username/.boto
containing your credentials, based on your responses to the following
questions.
Please navigate your browser to the following URL:
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdevstorage.full_control&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=############.apps.googleusercontent.com&access_type=offline
In your browser you should see a page that requests you to authorize access to Google Cloud Platform APIs and Services on your behalf. After you approve, an authorization code will be displayed.
Enter the authorization code:
$ gsutil cp -r gs://pubsite_prod_rev_0123456789/reviews/reviews_* android_review/
Package Name,App Version,Reviewer Language,Reviewer Hardware Model,Review Submit Date and Time,Review Submit Millis Since Epoch,Review Last Update Date and Time,Review Last Update Millis Since Epoch,Star Rating,Review Title,Review Text,Developer Reply Date and Time,Developer Reply Millis Since Epoch,Developer Reply Text,Review Link
$ file reviews_*.csv
reviews_*.csv: Little-endian UTF-16 Unicode text, with very long lines
<?php
$raw = file_get_contents(...);
$result = iconv($in_charset = 'UTF-16LE' , $out_charset = 'UTF-8' , $raw);
if( false !== $result )
$raw = $result;
$raw_lines = explode("\n", $raw);
array_shift($raw_lines); // title
foreach( $raw_lines as $line ) {
$fields = str_getcsv($line);
print_r($fields);
}
$ curl https://itunes.apple.com/tw/rss/customerreviews/id=284882215/sortBy=mostRecent/json | python -mjson.tool
$ cat test.php
<?php
$app_id = '284882215';
$country_list = array( 'tw', 'us');
$format = 'xml';
$page_list = array(1,2,3,4,5,6,7,8,9,10);
foreach( $country_list as $country ) {
foreach( $page_list as $page ) {
$url = "https://itunes.apple.com/$country/rss/customerreviews/id=$app_id/page=$page/$format";
if ($format == 'json') {
$raw = json_decode(@file_get_contents($url), true);
//print_r($raw);
for ($i=1, $cnt=count($raw['feed']['entry']) ; $i<$cnt ; ++$i) {
print_r(array(
'user_id' => $raw['feed']['entry'][$i]['id']['label'],
'user_name' => $raw['feed']['entry'][$i]['author']['name']['label'],
'user_uri' => $raw['feed']['entry'][$i]['author']['uri']['label'],
'title' => $raw['feed']['entry'][$i]['title']['label'],
'content' => $raw['feed']['entry'][$i]['content']['label'],
'version' => $raw['feed']['entry'][$i]['im:version']['label'],
'rating' => $raw['feed']['entry'][$i]['im:rating']['label'],
));
}
} else {
$raw = simplexml_load_string(@file_get_contents($url));
//print_r($raw);
for($i=1, $cnt = count($raw->entry); $i<$cnt ; ++$i) {
//print_r($raw->entry[$i]);
$imAttrs = $raw->entry[$i]->children('im', true);
//print_r($imAttrs);
print_r(array(
'date' => (string)$raw->entry[$i]->updated,
'user_id' => (string)$raw->entry[$i]->id,
'user_name' => (string)$raw->entry[$i]->author->name,
'user_uri' => (string)$raw->entry[$i]->author->uri,
'title' => (string)$raw->entry[$i]->title,
'content' => (string)$raw->entry[$i]->content[0],
'version' => (string)$imAttrs->version,
'rate' => (string)$imAttrs->rating,
));
}
}
exit;
}
}
$ php test.php
Array
(
[date] => 2014-09-10T09:10:00-07:00
[user_id] => ###########
[user_name] => ###########
[user_uri] => https://itunes.apple.com/tw/reviews/id###########
[title] => 有Bug請改善
[content] => 點朋友的動態跑不出來!!
[version] => 14.0
[rating] => 1
)
Array
(
[date] => 2014-09-10T09:03:00-07:00
[user_id] => ###########
[user_name] => ###########
[user_uri] => https://itunes.apple.com/tw/reviews/id###########
[title] => 一直自動關掉
[content] => 用一用會一直自動跳掉,很頻繁,很煩。
[version] => 14.0
[rating] => 1
)
SELECT something FROM Table1, (SELECT id FROM Table2) AS list WHERE Table1.id = list.id;
SELECT something, @n AS total FROM Table1, (SELECT id, CASE WHEN @n > 0 THEN @n := @n + 1 ELSE @n := 1 END AS n FROM Table2, (SELECT @n := 0) AS init) AS list WHERE Table1.id = list.id;
SELECT something, @n AS total FROM Table1, (SELECT id, CASE WHEN @n > 0 THEN @n := @n + 1 ELSE @n := 1 END AS n FROM Table2, (SELECT @n := 0) AS init) AS list WHERE Table1.id = list.id LIMIT 0,10;
$ vim t.php
<?php
$data = "..<a href='...'>...</a>.."; //file_get_contents(...);
if (preg_match_all("#<a[^h]*href=['\"]{0,1}([^\"']+)[\"']{0,1}[^>]*>(.*?)</a>#", $data, $matches) )
print_r($matches);
$ php t.php
Array
(
[0] => Array
(
[0] => <a href='...'>...</a>
)
[1] => Array
(
[0] => ...
)
[2] => Array
(
[0] => ...
)
)
$ vim pcre_test.cpp
#include <pcre.h>
#include <iostream>
int main() {
const char *error;
int erroroffset;
pcre *preg_pattern_a_tag = pcre_compile("<a[^h]*href=['\"]{0,1}([^\"']+)[\"']{0,1}[^>]*>(.*?)</a>", PCRE_MULTILINE, &error, &erroroffset, NULL);
if (!preg_pattern_a_tag) {
std::cout << "ERROR\n";
return -1;
}
std::string raw = "..<a href='...'>...</a>..";
unsigned int offset = 0;
unsigned int len = raw.size();
int matchInfo[3*2] = {0};
int rc = 0;
while (offset < len && (rc = pcre_exec(preg_pattern_a_tag, 0, raw.c_str(), len, offset, 0, matchInfo, sizeof(matchInfo))) >= 0) {
for (int n=0; n<rc ; ++n) {
int data_length = matchInfo[2*n+1] - matchInfo[2*n];
std::cout << "Found:[" << raw.substr(matchInfo[2*n], data_length) << "]\n";
}
offset = matchInfo[1];
}
return 0;
}
$ g++ -std=c++11 pcre_test.cpp -lpcre
$ ./a.out
Found:[<a href='...'>...</a>]
Found:[...]
Found:[...]
$ vim re2_test.cpp
#include <re2/re2.h>
#include <iostream>
int main() {
//RE2 preg_pattern_a_tag("<a[^h]*href=['\"]{0,1}([^\"']+)[\"']{0,1}[^>]*>(.*?)</a>", RE2::Latin1);
RE2 preg_pattern_a_tag("<a[^h]*href=['\"]{0,1}([^\"']+)[\"']{0,1}[^>]*>(.*?)</a>");
std::string raw = "..<a href='...'>...</a>..";
re2::StringPiece result_a_href, result_a_body;
while(RE2::PartialMatch(raw, preg_pattern_a_tag, &result_a_href, &result_a_body)) {
std::cout << "result_a_href:[" << result_a_href << "]\n";
std::cout << "result_a_body:[" << result_a_body << "]\n";
raw = result_a_body.data();
}
return 0;
}
$ g++ -std=c++11 re2_test.cpp /path/libre2.a -lpthread
$ ./a.out
result_a_href:[...]
result_a_body:[...]
"v=spf1 a mx a:YourServerHostname ~all"
$ nslookup -q=txt cs.nctu.edu.tw
...
cs.nctu.edu.tw text = "v=spf1 a mx a:farewell.cs.nctu.edu.tw a:csmailer.cs.nctu.edu.tw a:tcsmailer.cs.nctu.edu.tw a:csmailgate.cs.nctu.edu.tw a:csmail1.cs.nctu.edu.tw a:csmail2.cs.nctu.edu.tw a:csws1.cs.nctu.edu.tw a:csws2.cs.nctu.edu.tw ~all"
...
Received-SPF: none (google.com: YourSender@YourMailServer does not designate permitted sender hosts) client-ip=YourMailServerIP;
Received-SPF: softfail (google.com: domain of transitioning YourSender@YourMailServer does not designate YourMailServerIP as permitted sender) client-ip=YourMailServerIP;
Received-SPF: pass (google.com: domain of YourSender@YourMailServer designates YourMailServerIP as permitted sender) client-ip=YourMailServerIP;
$ grep alias_maps /etc/postfix/main.cf
alias_maps = hash:/etc/aliase
$ sudo vim /etc/aliases
...
devnull: /dev/null
...
$ grep virtual_alias_maps /etc/postfix/main.cf
$ sudo vim /etc/postfix/main.cf
virtual_alias_maps = hash:/etc/postfix/virtual
$ sudo vim /etc/postfix/virtual
no-reply@hostname devnull
$ sudo newaliases
$ sudo postmap /etc/postfix/virtual
$ sudo postfix reload
postfix/postfix-script: refreshing the Postfix mail system
$ telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 hostname ESMTP Postfix (Ubuntu)
HELO localhost
250 hostname
mail from:<root@localhost>
250 2.1.0 Ok
rcpt to:<no-reply@hostname>
250 2.1.0 Ok
quit
221 2.0.0 Bye
Connection closed by foreign host.