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
Zen Code | |
1.CSS like Selectors | |
div -> <div></div> | |
div#header.some.classes+ul>li -> <div id="header" class="some classes"></div> | |
<ul> |
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
<?php | |
for ($i=1;$i<100;$i++){ | |
if (file_exists("$i.jpg")){ | |
rename("$i.jpg","product$i.jpg"); | |
}else{ | |
echo "rename complete!".($i-1)."files was renamed."; | |
die(); | |
} | |
} |
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
php 小数整理,向上取整,向下去整,四舍五入,丢弃小数部分,保留整数部分(转) | |
1.丢弃小数部分,保留整数部分 | |
php: intval(7/2) | |
js:parseInt(7/2) | |
2.向上取整,有小数就整数部分加1 | |
php: ceil(7/2) | |
js: Math.ceil(7/2) | |
3,四舍五入. | |
php: round(7/2) | |
js: Math.round(7/2) |
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
<?php | |
class A { | |
function foo(){ | |
if (isset($this)){ | |
echo "\$this is defined ("; | |
echo get_class($this); | |
echo ")\n"; | |
} else { | |
echo "\$this is not defined"; |
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
<?php | |
/** | |
* 要创建一个类的实例,必须使用 new 关键字。 | |
* 当创建新对象时该对象总是被赋值,除非该对象定义了构造函数并且在出错时抛出了一个异常。 | |
* 类应在被实例化之前定义(某些情况下则必须这样)。 | |
* ***如果在 new 之后跟着的是一个包含有类名的字符串,则该类的一个实例被创建。*** | |
* 如果该类属于一个名字空间,则必须使用其完整名称。 | |
* Tip : 在类定义内部,可以用 new self 和 new parent 创建新对象。 | |
*/ | |
class foo |
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
/* Heartbleed OpenSSL vulnerbility POC | |
* CVE-2014-0160 | |
* | |
* You need to modify OpenSSL client code: ssl/t1_lib.c, function tls1_heartbeat | |
* Previous line: \/\* Payload length (18 bytes here) \*\/ | |
* Old line: s2n(payload, p); | |
* New line: s2n(65536 - 100, p); // pretend that we have so many bytes of payload... | |
* | |
* To compile: | |
* gcc -g -o testssl -Iinclude -L. -lssl ssl/*.o testssl.c |
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
import copy | |
import functools | |
class B(object): | |
def __init__(self, name): | |
self.name = name | |
class A(object): |
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
#!/usr/bin/python | |
#-*- coding: utf-8 -*- | |
# ============================================ | |
# _____ _ _ _ _ | |
# | ____| | | | | ___ _ __ | |_ __ _(_) | |
# | _| _____| |_| |/ _ \ '_ \| __/ _` | | | |
# | |__|_____| _ | __/ | | | || (_| | | | |
# |_____| |_| |_|\___|_| |_|\__\__,_|_| | |
# | |
# -------------------------------------------- |
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
# -*- coding:utf-8 -*- | |
from pyquery import PyQuery as pq | |
import requests | |
from PIL import Image | |
from StringIO import StringIO | |
import time | |
import os | |
import stat | |
import datetime | |
import operator |
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
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
# shaozx@gmail.com 2009-05-04 | |
# | |
# Description: 在控制台使用 cd 命令时用拼音补全中文路径 | |
# | |
# 实验目录如下: | |
# biff@lenovo:/domain/WorkSpace$ ls | |
# SVN培训 全球眼 浙江建行 浙江农信 | |
# |
OlderNewer