Skip to content

Instantly share code, notes, and snippets.

@yannisxu
yannisxu / gist:2858697
Created June 2, 2012 14:47 — forked from zythum/gist:2848881
google收录的敏感词
@yannisxu
yannisxu / Shell:CMDHistory
Created August 12, 2012 15:24
Shell:CMDHistory
history | awk '{CMD[$2]++;count++;} END { for (a in CMD )print CMD[ a ]" " CMD[ a ]/count*100 "% " a }' | grep -v "./" | column -c3 -s " " -t |sort -nr | nl | head -n10
@yannisxu
yannisxu / Regex:IP
Created October 15, 2012 08:50
Regex:IP
((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))
@yannisxu
yannisxu / MatchIP.py
Last active October 12, 2015 13:58
Python:MatchIP
ipAddrPattern = re.compile('^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$')
ip_match = ipAddrPattern.match(ip)
@yannisxu
yannisxu / bookmarklet_new.js
Created November 24, 2012 13:49
Javascript:BookMarklet_new
javascript:(function(){
var createElement = function (tag,attrs){
var elem = document.createElement(tag);
for (var key in attrs){
elem.setAttribute(key, attrs[key]);
};
return elem;
};
var loadJS = function(src, success) {
var domScript = createElement('script', { 'src' : src, 'type' : 'text/javascript'});
@yannisxu
yannisxu / ipregular.js
Created December 4, 2012 09:22
Javascript:IPRegular
obj="1.1.1.1"
//ip地址
var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
var reg = obj.match(exp);
if(reg==null)
{
alert("IP地址不合法!");
}
else
{
[Solarized Dark]
text(bold)=839496
magenta(bold)=6c71c4
text=839496
white(bold)=fdf6e3
green=859900
red(bold)=cb4b16
green(bold)=586e75
black(bold)=073642
red=dc322f
import logging
import os
logging.basicConfig(filename = os.path.join(os.getcwd(), 'log.txt'), level = logging.INFO, filemode = 'w', format = '%(asctime)s - %(levelname)s: %(message)s')
@yannisxu
yannisxu / replaceAll.js
Created April 8, 2013 07:35
javascript string replaceall method
//method1
mystring.replace(/\./g,' ')
//method2
"abcccc".split("c").join("a")
//method3
str.replace(new RegExp(".","gm")," ")
@yannisxu
yannisxu / pyquery_each.py
Created April 22, 2013 15:20
pyquery each用法
texts = []
lis = pq('li')
def get(i,e):
e = pq(e)
texts.append(e.text())
lis.each(get)