Skip to content

Instantly share code, notes, and snippets.

@dervn
dervn / getElementsByTagName.js
Created September 21, 2017 23:46
JS 选中页面中所有复选框
ss = document.getElementsByTagName('select');
for (var i = 0; i < ss.length; i++) {
var se = ss[i];
for (var j = 0; j < se.options.length; j++) {
if(se.options[j].text=='只读'){
se.options[j].selected = true;
}
}
}
@dervn
dervn / domain_name_search.py
Created November 27, 2012 03:21
一个用来检测字符表里面是否有可用的拼音域名的脚本 http://pypi.python.org/pypi/chardet 用来检测编码
# -*- coding: utf-8 -*-
import codecs
import urllib2
import json
from sets import Set
"""
一个用来检测字符表里面是否有可用的拼音域名的脚本
http://pypi.python.org/pypi/chardet 用来检测编码
"""
f = codecs.open('data/pinyin.dic', encoding='utf-8')
@dervn
dervn / search_domain.py
Created November 27, 2012 03:21 — forked from lintianzhi/search_domain.py
search availible domain name
#!/usr/bin/python
#coding=utf-8
import urllib
import urllib2
import re
import threading
import Queue
url = 'https://who.is/whois/name_search/'
@dervn
dervn / chkbox.html
Created November 7, 2012 10:34
让复选框在整个TD区域内可点击
<table>
<tr>
<td width="80px" bgcolor="#f5f5f5">
<label for="box" style="display:block;line-height:80px">
<input id='box' name="chco" value="" type="checkbox">
</label>
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
@dervn
dervn / build_http_query.php
Created September 26, 2012 03:43
sig签名构造方法
function build_http_query($params) {
if (!$params) return '';
// Urlencode both keys and values
$keys = array_keys($params);
$values = array_values($params);
//$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
//$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
@dervn
dervn / markdown.css
Created August 29, 2012 07:51 — forked from zhimiaoli/markdown.css
github的markdown的样式
.markdown-body {
font-size: 14px;
line-height: 1.6;
}
.markdown-body > *:first-child {
margin-top: 0 !important;
}
.markdown-body > *:last-child {
margin-bottom: 0 !important;
}
@dervn
dervn / gist:3375687
Created August 17, 2012 03:29 — forked from lepture/china-dream.md
龍應台:我們的「中國夢」(8月1日北京大學演講講辭)

龍應台:我們的「中國夢」(8月1日北京大學演講講辭)

【明報專訊】第一次接到電話,希望我談談「中國夢」的時候,我的第一個反應是:「一千枚飛彈對準我家,我哪裏還有中國夢啊?」

可是沉靜下來思索,1952年生在台灣的我,還有我前後幾代人,還真的是在「中國夢」裏長大的,我的第一個中國夢是什麼呢?

我們上幼稚園時,就已經穿著軍人的制服、帶著木製的步槍去殺「共匪」了,口裏唱著歌。當年所有的孩子都會唱的那首歌,叫做《反攻大陸去》:

反攻 反攻 反攻大陸去
@dervn
dervn / install-php-memcached.sh
Created August 15, 2012 12:43
php memcached 扩展安装以及测试代码
// 安装 php memcached 扩展 http://www.php.net/manual/zh/book.memcached.php
// 注意:不是http://www.php.net/manual/zh/book.memcache.php
// 确保已经安装了libmemcached
wget http://pecl.php.net/get/memcached-2.1.0.tgz
tar zxf memcached-2.1.0
cd memcached-2.1.0
phpize
./configure
make
@dervn
dervn / get_line_random.php
Created August 9, 2012 08:26
随机取文件若干行
<?php
$file_name = "7";
$out = $file_name.".out";
$num = 3000;
$lines = get_lines_random( $file_name, $num);
foreach($lines as $key=>$value) {
file_put_contents($out, $value, FILE_APPEND);
file_put_contents($out, "\n", FILE_APPEND);