Skip to content

Instantly share code, notes, and snippets.

View staticor's full-sized avatar

SteveYagn staticor

View GitHub Profile
#!/usr/bin/python
# -*- coding:utf-8 -*-
import re
import sys
import requests
reload(sys)
sys.setdefaultencoding('utf8')
@staticor
staticor / matplotlibrc
Last active August 29, 2015 14:23 — forked from huyng/matplotlibrc
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overridden in your next install.
# If you want to keep a permanent local copy that will not be
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).
CONFIG = {
'Arial Black' : 'ENG',
'Arial' : 'ENG',
'Calibri' : 'ENG',
'Cambria' : 'ENG',
'Candara' : 'ENG',
'Comic Sans MS' : 'ENG',
'Constantia' : 'ENG',
'Corbel' : 'ENG',
'Georgia' : 'ENG',
class BoyerMoore
attr_accessor :text
attr_reader :pattern, :matches
def initialize( opts )
@text = opts[:text]
end
def search( pattern_str )
@pattern = Pattern.new( pattern_str )
@staticor
staticor / protocol-fix.txt
Created January 10, 2016 13:59 — forked from eculver/protocol-fix.txt
How to deal with tmux "protocol version mismatch"
$ tmux attach
protocol version mismatch (client 7, server 6)
$ pgrep tmux
3429
$ /proc/3429/exe attach
@staticor
staticor / ubuntu-maven-3
Created January 11, 2016 01:59 — forked from stephanetimmermans/ubuntu-maven-3
Install Maven3 on Unbuntu 14.04
#sudo apt-get remove maven2
sudo add-apt-repository "deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main"
sudo apt-get update
sudo apt-get install maven3
#If you encounter this:
#The program 'mvn' can be found in the following packages:
# * maven
# * maven2
@staticor
staticor / img_upload.py
Created January 11, 2016 09:15 — forked from ficapy/img_upload.py
当做图床使用,读取粘贴板的图像保存上传,完成后将url地址写入到剪贴板
#!/usr/local/bin/python2
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '16/1/1'
import datetime
import sys
import os
import atexit
import requests
@staticor
staticor / class_decorator.py
Created January 28, 2016 03:10 — forked from phith0n/class_decorator.py
class decorator
class Tx(object):
def __init__(self):
print("Tx:init")
self.something()
def something(self):
print("Tx:something")
def otherthing(self):
print("Tx:otherthing")
@staticor
staticor / squirrel.custom.yaml
Created March 23, 2016 05:23 — forked from lotem/squirrel.custom.yaml
【鼠鬚管】定製檔
# 適用於【鼠鬚管】0.9.13+
# 位置:~/Library/Rime/squirrel.custom.yaml
# 用法:想要哪項生效,就刪去該行行首的#字符,但注意保留用於縮進的空格
patch:
# us_keyboard_layout: true # 鍵盤選項:應用美式鍵盤佈局
# show_notifications_when: growl_is_running # 狀態通知,默認裝有Growl時顯示,也可設爲全開(always)全關(never)
# style/horizontal: true # 候選窗横向顯示
# style/inline_preedit: false # 非內嵌編碼行
# style/font_face: "儷黑 Pro" # 我喜歡的字體名稱
@staticor
staticor / gcd_and_lcm.py
Created March 24, 2016 02:25 — forked from endolith/gcd_and_lcm.py
GCD and LCM functions in Python
# Greatest common divisor of more than 2 numbers. Am I terrible for doing it this way?
def gcd(*numbers):
"""Return the greatest common divisor of the given integers"""
from fractions import gcd
return reduce(gcd, numbers)
# Least common multiple is not in standard libraries? It's in gmpy, but this is simple enough:
def lcm(*numbers):