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.
  • China
View GitHub Profile
curl -A "Mozilla" "http://translate.google.com/translate_tts?tl=en&q=hello+world" > hello.mp3
##MySQL数据库SQL(Structured Query Language)结构化查询语言常用基本操作:
/*DDL(Data Definition Language)数据定义语言*/
##创建数据库:
create database '数据库名称' charset utf8;
##删除数据库:
drop database '数据库名称';
##显示所有数据库:
show databases;
##使用数据库
use '数据库名称';
@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){
/**
* 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 / parse phpinfo
Created August 17, 2013 04:51
php: parse phpinfo
/**
* 解析 PHP info
*
* @return array
*/
function parse_phpinfo() {
ob_start(); phpinfo(INFO_MODULES); $s = ob_get_contents(); ob_end_clean();
$s = strip_tags($s, '<h2><th><td>');
$s = preg_replace('/<th[^>]*>([^<]+)<\/th>/', '<info>\1</info>', $s);
$s = preg_replace('/<td[^>]*>([^<]+)<\/td>/', '<info>\1</info>', $s);
@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
# 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.