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
@leadscloud
leadscloud / recursive_find_replace_string.md
Created September 26, 2016 03:35
批量替换文件夹中的文件中的字符

find /home/wwwroot/ -type f -print0 | xargs -0 sed -i 's/string/replacement/g'

find /home/wwwroot/ -type f -exec sed -i 's/string/replacement/g' {} \;

@leadscloud
leadscloud / enable-copy.js
Created January 6, 2014 05:58
Allow you copy-paste action on "copy-protected" website 允许你复制其它被限制复制的网站。
// ==UserScript==
// @name Enable Copy
// @description Allow you copy-paste action on "copy-protected" website
// @version 1.2
// ==/UserScript==
setInterval("document.oncontextmenu=null;document.contextmenu=null;document.ondragstart=null;document.onkeydown=null;document.onmousedown=null;document.onmousemove=null;document.onmouseup=null;document.onselectstart=null;document.selectstart=null;window.oncopy=null;document.oncopy=null;document.body.oncopy=null;document.body.onselect=null;document.body.onbeforecopy=null;document.body.contextmenu=null;document.body.oncontextmenu=null;document.body.ondragstart=null;document.body.onkeydown=null;document.body.onmousedown=null;document.body.onmousemove=null;document.body.onmouseup=null;document.body.selectstart=null;document.body.onselectstart=null;window.contextmenu=null;window.oncontextmenu=null;window.ondragstart=null;window.onkeydown=null;window.onmousedown=null;window.onmousemove=null;window.onmouseup=null;window.selectstart=null;window.onselectstart=null;window
/**
* browser sinffing
* http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/
*/
(function(){
var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
@leadscloud
leadscloud / get_client_language.php
Last active December 18, 2015 14:08
检测浏览器语言
/*检测浏览器语言*/
function get_client_language($availableLanguages, $default='en'){
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
//start going through each one
foreach ($langs as $value){
##MySQL数据库SQL(Structured Query Language)结构化查询语言常用基本操作:
/*DDL(Data Definition Language)数据定义语言*/
##创建数据库:
create database '数据库名称' charset utf8;
##删除数据库:
drop database '数据库名称';
##显示所有数据库:
show databases;
##使用数据库
use '数据库名称';
curl -A "Mozilla" "http://translate.google.com/translate_tts?tl=en&q=hello+world" > hello.mp3
@leadscloud
leadscloud / KMP.py
Last active August 29, 2015 14:20 — forked from kylebgorman/KMP.py
#!/usr/bin/env python
# Knuth-Morris-Pratt demonstration
# Kyle Gorman <kgorman@ling.upenn.edu>
#
# A naive Python implementation of a function that returns the (first) index of
# a sequence in a supersequence is the following:
def subsequence(needle, haystack):
"""
Naive subsequence indexer; None if not found
@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
@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
#!/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