This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function betweenDays(first_date, second_date, separator) { | |
var separator = separator || "-", | |
first_date_parts = first_date.split(separator), | |
second_date_parts = second_date.split(separator), | |
first_date_object = new Date(first_date_parts[0], first_date_parts[1], first_date_parts[2]), | |
second_date_object = new Date(second_date_parts[0], second_date_parts[1], second_date_parts[2]), | |
between_time = Math.abs(first_date_object.getTime() - second_date_object.getTime()); | |
return between_time/(1000*60*60*24); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
第一次執行時: | |
- onCreate ---> onStart() ---> onResume() | |
Activity A 打開 Activity B: | |
- Activity A: onPause() --–> 等待 B 創建 ---> onStop() | |
- Activity B: onCreate() ---> onStart() ---> onResume() | |
按返回鍵,回到 Activity A 時: | |
- Activity B: onPause() --–> 等待 A 恢復 ---> onStop() --–> onDestory() | |
- Activity A: onRestart() ---> onStart() --–> onResume() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){if(typeof VisualEvent!='undefined'){if(document.getElementById('Event_display')){VisualEvent.fnClose();}else{VisualEvent.fnInit();}}else{var n=document.createElement('script');n.setAttribute('language','JavaScript');n.setAttribute('src','http://www.sprymedia.co.uk/design/event/media/js/event-loader.js');document.body.appendChild(n);}})();; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wget --mirror -p --adjust-extension --no-parent --convert-links http://website.com | |
這個是目前測試以來最好的 | |
$ wget -r -np -nd http://example.com/packages/ | |
这条命令可以下载 http://example.com 网站上 packages 目录中的所有文件。其中,-np 的作用是不遍历父目录,-nd 表示不在本机重新创建目录结构。 | |
$ wget -r -np -nd --accept=iso http://example.com/centos-5/i386/ | |
与上一条命令相似,但多加了一个 --accept=iso 选项,这指示 wget 仅下载 i386 目录中所有扩展名为 iso 的文件。你也可以指定多个扩展名,只需用逗号分隔即可。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print int(''.join( | |
re.compile( | |
r'<td class="componentBlack" nowrap="nowrap" align="right">(.*?)</td>' | |
).search( | |
re.compile( | |
r'<td class="componentBlack" nowrap="nowrap" align="right">.*?</td>', | |
re.MULTILINE | |
).findall(open('test.html', 'r').read())[4] | |
).group(1).replace(" ", " ").split(" ") | |
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install cloc | |
cloc . --exclude-dir=cache,attachment,.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pw () { | |
p=`perl -e 'print map { chr rand(94) + 33 } 1..16';` | |
echo -n $p | pbcopy | |
echo $p | |
} | |
alias pw="perl -le 'print map { chr rand(94) + 33 } 1..16';" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## {{{ http://code.activestate.com/recipes/491264/ (r4) | |
import socket | |
class DNSQuery: | |
def __init__(self, data): | |
self.data=data | |
self.dominio='' | |
tipo = (ord(data[2]) >> 3) & 15 # Opcode bits | |
if tipo == 0: # Standard query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
portsnap update | |
OR | |
cvsup -L 2 -h cvsup.tw.FreeBSD.org /usr/share/examples/cvsup/ports-supfile | |
** Update only not upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
# Some hosts may require you to use the `RewriteBase` directive. | |
# If you need to use the `RewriteBase` directive, it should be the | |
# absolute physical path to the directory that contains this htaccess file. | |
# | |
# RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)$ index.php [QSA,L] |