Skip to content

Instantly share code, notes, and snippets.

View grzhan's full-sized avatar
🧸
带娃宅

grzhan grzhan

🧸
带娃宅
View GitHub Profile
@grzhan
grzhan / zencoding_manual.html
Created August 28, 2012 19:48
Zencoding_keymap
Zen Code
1.CSS like Selectors
div -> <div></div>
div#header.some.classes+ul>li -> <div id="header" class="some classes"></div>
<ul>
@grzhan
grzhan / rename.php
Created August 29, 2012 12:45
An easy rename php script.
<?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();
}
}
@grzhan
grzhan / Ceil_round_floor.php
Created August 29, 2012 16:47
Some functions about php float number
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)
@grzhan
grzhan / php_OOP_dollar_this.php
Created May 12, 2013 12:46
PHP Object Learning - Basic Concept - $this
<?php
class A {
function foo(){
if (isset($this)){
echo "\$this is defined (";
echo get_class($this);
echo ")\n";
} else {
echo "\$this is not defined";
@grzhan
grzhan / PHP_OOP_new($).php
Created May 12, 2013 12:50
PHP - OOP - Learning - a "new" statement using string.
<?php
/**
* 要创建一个类的实例,必须使用 new 关键字。
* 当创建新对象时该对象总是被赋值,除非该对象定义了构造函数并且在出错时抛出了一个异常。
* 类应在被实例化之前定义(某些情况下则必须这样)。
* ***如果在 new 之后跟着的是一个包含有类名的字符串,则该类的一个实例被创建。***
* 如果该类属于一个名字空间,则必须使用其完整名称。
* Tip : 在类定义内部,可以用 new self 和 new parent 创建新对象。
*/
class foo
/* 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
import copy
import functools
class B(object):
def __init__(self, name):
self.name = name
class A(object):
@grzhan
grzhan / ehentai.py
Last active August 28, 2015 12:49
因为最近e绅士收藏的本子经常失效丢失,所以写了个简单的下载器,设定了延时来规避e绅士对于下载脚本的检测,速度比较慢,但满足了自己的需求
#!/usr/bin/python
#-*- coding: utf-8 -*-
# ============================================
# _____ _ _ _ _
# | ____| | | | | ___ _ __ | |_ __ _(_)
# | _| _____| |_| |/ _ \ '_ \| __/ _` | |
# | |__|_____| _ | __/ | | | || (_| | |
# |_____| |_| |_|\___|_| |_|\__\__,_|_|
#
# --------------------------------------------
# -*- 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
@grzhan
grzhan / chsdir
Created October 13, 2015 10:22
Linux Shell下的目录拼音补全,出处:https://code.google.com/p/easyscripts/wiki/chsdir
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# shaozx@gmail.com 2009-05-04
#
# Description: 在控制台使用 cd 命令时用拼音补全中文路径
#
# 实验目录如下:
# biff@lenovo:/domain/WorkSpace$ ls
# SVN培训 全球眼 浙江建行 浙江农信
#