Skip to content

Instantly share code, notes, and snippets.

View weaming's full-sized avatar
🦀
Rustacean

Garden Yuen weaming

🦀
Rustacean
  • Shenzhen, China
View GitHub Profile
@weaming
weaming / JSONView.css
Last active April 5, 2016 03:11
JSONView chrome plugin
body {
white-space: pre;
font-family: monospace;
background-color: #002b36;
color: #ddd;
}
a{
color: green;
}
@weaming
weaming / baidu-as-a-network-utility.css
Last active May 17, 2016 06:55 — forked from tianyuf/baidu-as-a-network-utility.css
BaaN: Baidu as a Network Utility - 百度的实用主义方法论.
@-moz-document domain("baidu.com") {
#u1,
#ftCon,
#form input,
#form span
{display: none;}
#form::after {
font-family: "BlinkMacSystemFont", "Segoe UI", sans-serif;
@weaming
weaming / ua.js
Last active July 11, 2016 07:55 — forked from Takazudo/ua.js
var ua = (function(){
var ua = {};
var navigator = window.navigator;
var platforms = [
{ property: 'platform', regex: /iPhone/i, identity: 'iPhone' },
{ property: 'platform', regex: /iPod/i, identity: 'iPod' },
{ property: 'userAgent', regex: /iPad/i, identity: 'iPad' },
{ property: 'userAgent', regex: /Blackberry/i, identity: 'Blackberry' },
{ property: 'userAgent', regex: /Android/i, identity: 'Android' },
{ property: 'platform', regex: /Mac/i, identity: 'Mac' },
@weaming
weaming / python-logging.py
Last active July 12, 2016 04:32
python 的 logging 模块
# coding:utf-8
"""
CRITICAL = 50
FATAL = CRITICAL
ERROR = 40
WARNING = 30
WARN = WARNING
INFO = 20
DEBUG = 10
NOTSET = 0
function checkBrowser(){
var br={}
var ua=navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/chrome\/([\d.]+)/)) ? br.chrome = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? br.firefox = s[1] :
(s = ua.match(/msie ([\d.]+)/)) ? br.ie = s[1] :
(s = ua.match(/net.*rv:([\d.]+)/)) ? br.ie = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? br.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? br.safari = s[1] : 0;
@weaming
weaming / youdao.py
Created August 21, 2016 07:06 — forked from DeanThompson/youdao.py
命令行版本的有道词典
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
命令行版本的有道词典,调用有道翻译的 API 实现
用法一:
% python youdao.py search
原文: search
发音: sɜːtʃ
@weaming
weaming / stylish-rust-lang-reference.css
Created December 24, 2016 17:08
stylish-rust-lang-reference.css
@-moz-document regexp("https://doc.rust-lang.org/reference.*") {
#TOC{
position: fixed;
left: 0;
top: 0;
overflow: scroll;
overflow-x: hidden;
height: 100vh;
max-width: 30vw;
body {font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; }
#Search div {
background-image:none!important;
border-image-repeat:repeat;
border-image-slice:27 27 27 50;
border-image-source:url(https://v2ex.com/static/img/qbar_light@2x.png);
border-image-width:27px 27px 27px 50px;
width:auto!important;
}
@weaming
weaming / Objectify.py
Created March 10, 2017 10:02
Make a dict or a dict to be object.
class Objectify(object):
def __init__(self, data):
""" data maybe one dict or list """
self.data = data
def __getitem__(self, item):
_data = object.__getattribute__(self, 'data')
return _data[item]
def __getattribute__(self, item):
@weaming
weaming / words.hs
Last active April 17, 2017 15:53
Count the words of input text with beautiful output.
import qualified Data.Char as C
import qualified Data.Map as M
import Data.List.Split
import Control.Monad
quicksort :: (Ord a) => [(k,a)] -> [(k,a)]
quicksort [] = []
quicksort ((k,a):xs) =
let smallerSorted = quicksort [(x,y) | (x,y) <- xs, y<=a]
biggerSorted = quicksort [(x,y) | (x,y) <- xs, y>a]