Skip to content

Instantly share code, notes, and snippets.

View zeuxisoo's full-sized avatar
🛥️
No response

Zeuxis zeuxisoo

🛥️
No response
View GitHub Profile
@zeuxisoo
zeuxisoo / gist:1059749
Last active September 26, 2015 07:17
javascript calcate between days
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);
}
@zeuxisoo
zeuxisoo / gist:1062065
Created July 3, 2011 08:17
[Android] Activity Processing State
第一次執行時:
- 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()
@zeuxisoo
zeuxisoo / gist:1108578
Created July 27, 2011 03:11
Find out which element had binding event bookmarklet
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);}})();;
@zeuxisoo
zeuxisoo / gist:1122039
Last active September 26, 2015 15:57
wget mirror usage
$ 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 的文件。你也可以指定多个扩展名,只需用逗号分隔即可。
@zeuxisoo
zeuxisoo / gist:1173084
Created August 26, 2011 09:47
Python re module grep current number (3 Person column) on public house
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("&nbsp;", " ").split(" ")
))
@zeuxisoo
zeuxisoo / gist:1173800
Created August 26, 2011 16:25
Count line of code by cloc
brew install cloc
cloc . --exclude-dir=cache,attachment,.git
@zeuxisoo
zeuxisoo / gist:1178023
Created August 29, 2011 08:43
Shell Script Generate Random Password
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';"
@zeuxisoo
zeuxisoo / gist:1205467
Created September 9, 2011 04:02
Mini Fake DNS server (Python recipe)
## {{{ 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
@zeuxisoo
zeuxisoo / gist:1209520
Created September 11, 2011 12:39
FreeBSD ports update
portsnap update
OR
cvsup -L 2 -h cvsup.tw.FreeBSD.org /usr/share/examples/cvsup/ports-supfile
** Update only not upgrade
@zeuxisoo
zeuxisoo / .htaccess
Created September 26, 2011 08:22
PHP url router like rails
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]