class Object
def in?(arr)
arr.include? self
end
end
class Array
def any_in?(container)
container.has_any? self
end
def all_in?(container)
......................
阅读全部 | 2012年10月22日 15:12
class Object
def method_missing(name, *args)
if name[-1] == '='
nam = name.to_s[0...-1]
if instance_variables.map{|x|x.to_s}.include? "@#{nam.to_s}"
raise "undefined method `#{name}' for #<#{self.class}:#{self.object_id}>"
else
instance_variable_set("@#{nam}", args[0])
end
else
if instance_variables.map{|x|x.to_s}.include? "@#{name.to_s}"
instance_variable_get("@#{name}".to_s)
......................
阅读全部 | 2012年10月22日 03:02
<?php
echo send_mail('qq123456@qq.com','发信测试','测试测试测试测试测试测试');
function send_mail($to, $subject = 'No subject', $body) {
$loc_host = "test"; //发信计算机名,可随意
$smtp_acc = "bccn@bccn.net"; //Smtp认证的用户名,类似fuweng@im286.com,或者fuweng
$smtp_pass="12345678"; //Smtp认证的密码,一般等同pop3密码
$smtp_host="smtp.exmail.qq.com"; //SMTP服务器地址,类似 smtp.tom.com
$from="bccn@bccn.net"; //发信人Email地址,你的发信信箱地址
$headers = "Content-Type: text/plain; charset=\"gb2312\"\r\nContent-Transfer-Encoding: base64";
$lb="\r\n"; //linebreak
......................
阅读全部 | 2012年10月13日 00:26
/*
String类: first、last、has、has_any、has_all、is_in、format
Array类: first、last、has、has_any、has_all、is_in、any_in、all_in
*/
var has_any = function() {
var list = arguments;
if (typeof(list[0])=='object') {
list = list[0];
}
var result = false;
for (var i=0; i<list.length; i++) {
if (this.has(list[i])) {
......................
阅读全部 | 2012年6月7日 19:22
class Object
def in?(arr)
arr.include? self
end
end
class Array
def any_in?(container)
container.has_any? self
end
def all_in?(container)
......................
阅读全部 | 2012年6月4日 19:19
class Object
def in?(arr)
arr.include? self
end
end
class Array
def any_in?(container)
container.has_any? self
end
def all_in?(container)
......................
阅读全部 | 2012年6月1日 16:49
<script>
Object.prototype.changdu = function(){
return this.length;
}
alert('xxx'.changdu());
</script>
阅读全部 | 2012年5月7日 13:39
def test_block x
puts x
yield(x*2)
end
test_block(3) {|a| puts a}
test_block 3 do |a|
puts a
end
阅读全部 | 2012年4月25日 18:41
# 在这里找到一个解决方案 http://www.linuxdiyf.com/viewarticle.php?id=145791
# 不过几十个文件挨个改太麻烦了,用这个脚本可以自动修改,放在/usr/share/applications/kde4/里面运行
# 记得运行前备份kde4文件夹
import os
for f in os.listdir('.'):
s = open(f).read()
if not 'OnlyShowIn=KDE' in s:
s = s + "\nOnlyShowIn=KDE"
file(f, 'w').write(s)
print f
......................
阅读全部 | 2012年3月28日 23:07
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import os
from django import template
from django.conf import settings
register = template.Library()
class SassNode(template.Node):
def __init__(self, format_string):
self.format_string = format_string
......................
阅读全部 | 2012年3月15日 21:46