Skip to content

Instantly share code, notes, and snippets.

View leadscloud's full-sized avatar
💭
I may be slow to respond.

LeadsCloud leadscloud

💭
I may be slow to respond.
View GitHub Profile
# find keywords liveperson in js file
find /home/wwwroot/ -type f -name "*.js" | xargs grep "liveperson" -sl
find /home/wwwroot/ -type f -name "*.js" -o -name "*.html" -o -name "*.htm" -o -name "*.php" | tr -d "\'"| xargs grep "liveperson" -sl
@leadscloud
leadscloud / sample.sh
Last active August 29, 2015 14:02
一些常用的操作lnmp的shell脚本
# http://linux-bash.googlecode.com/files/damnp-actgod.sh
function check_install {
if [ -z "`which "$1" 2>/dev/null`" ]
then
executable=$1
shift
while [ -n "$1" ]
do
DEBIAN_FRONTEND=noninteractive apt-get -q -y --force-yes install "$1"
@leadscloud
leadscloud / sanitize_at_name.py
Created July 12, 2014 08:53
格式化标题为首字母大写,特别符号除外
def sanitize_at_name(name, decode = False):
""" Sanitize achternaam, optionally decodes
to unicode string from AT input """
if decode:
name = unicode(name, 'iso-8859-15')
tussenvoegsels = [
"af",
"aan",
#!/usr/bin/env python
"""
ListeningSocketHandler
======================
A python logging handler.
logging.handlers.SocketHandler is a TCP Socket client that sends log
records to a tcp server.
This class is the opposite.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 Yannick Albert <http://yckart.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@leadscloud
leadscloud / socket_client.py
Last active August 29, 2015 14:11
代码一,测试是没有任何问题的,但不支持多线程,单一请求。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Code is built by Ray. QQ: 75504026 E-mail:zhanglei@shibangcrusher.com
# Development environment: win7 64bit, python 2.7.8
import socket
import datetime
from time import sleep
import time
HOST = '192.168.1.170' # Symbolic name meaning the local host
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Code is built by Ray. QQ: 75504026 E-mail:zhanglei@shibangcrusher.com
# Development environment: win7 64bit, python 2.7.8
from SocketServer import TCPServer, ThreadingMixIn, StreamRequestHandler
import datetime
import time
import socket
import threading
#!/usr/bin/env python
import SocketServer
from threading import Thread
class service(SocketServer.BaseRequestHandler):
def handle(self):
data = 'dummy'
print "Client connected with ", self.client_address
@leadscloud
leadscloud / image_hover.js
Created March 14, 2015 14:50
网页中大于100*100的图片,鼠标移动到图片上时显示小图标按钮。
// created by zhanglei http://www.love4026.org at 2011-2-23
var img=document.getElementsByTagName('img');function getElementsByClassName(strClassName){var arrElements=document.all?document.all:document.getElementsByTagName('*');var arrReturnElements=new Array();strClassName=strClassName.replace(/\-/g,"\\-");var oRegExp=new RegExp("(^|\\s)"+strClassName+"(\\s|$)");for(var i=0;i<arrElements.length;i++){if(oRegExp.test(arrElements[i].className)){arrReturnElements.push(arrElements[i]);}}return(arrReturnElements)}function getFloat(el){if(!window.getComputedStyle||!document.defaultView){if(el.getAttribute('align')=='left'||el.getAttribute('align')=='right')var y=el.getAttribute('align');else var y=el.currentStyle['styleFloat'];}else var y=document.defaultView.getComputedStyle(el,null).getPropertyValue('float');return y;}for(var i=0;i<img.length;i++){if(img[i].height>100&&img[i].width>100){var innerhtml=document.createElement('div');innerhtml.innerHTML='<span>Get a Quote</span>';innerhtml.className="imgHoverBtn";va
@leadscloud
leadscloud / pop-imap.py
Created April 30, 2015 09:23
使用Python下载邮件(pop/imap)
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import time
import email
import poplib
import imaplib
import cStringIO