Skip to content

Instantly share code, notes, and snippets.

View solos's full-sized avatar
🎶
Listening music

solos

🎶
Listening music
View GitHub Profile
"""SSL client/server certificates verification for `urllib2`.
It works on Python 2.6, 2.7, 3.1, 3.2
It also works on Python 2.4, 2.5 if `ssl` is installed (``pip install ssl``)
Example::
>>> import urllib2, urllib2_ssl
>>> opener = urllib2.build_opener(urllib2_ssl.HTTPSHandler(
... key_file='clientkey.pem',
@solos
solos / dict.json
Created February 21, 2013 14:51
regex dict python implemention
This file has been truncated, but you can view the full file.
{
"fawn": "[f\u0254:n] \n n.(\u672a\u6ee1\u4e00\u5c81\u7684)\u5c0f\u9e7f,\u5c0f\u5c71\u7f8a,\u5c0f\u52a8\u7269,\u9e7f\u6bdb\u8272,\u6d45\u9ec4\u8910\u8272 vi.\u5949\u627f,\u8ba8\u597d v.\u751f(\u5c0f\u5c71\u7f8a\u6216\u5c0f\u52a8\u7269) adj.\u6d45\u9ec4\u8910\u8272",
"ray matter": "n.\u7070\u767d\u8d28,\u667a\u529b",
"cat-and-dog": "adj.\u5435\u5435\u95f9\u95f9\u7684,\u4e0d\u548c\u7684",
"unsupportable": "[\u02cf\u028cns\u04d9'p\u0254:t\u04d9bl] \n adj.=insupportable",
"supersensuous": "[\u02cfsju:p\u04d9'sensju\u04d9s] \n adj.\u8d85\u611f\u89c9\u7684",
"localizer": "['l\u04d9uk\u04d9laiz\u04d9(r)] \n n.\u5b9a\u4f4d\u5668,\u5b9a\u4f4d\u4fe1\u6807",
"biennialy": "adv.\u6bcf\u4e8c\u5e74\u4e00\u6b21\u5730",
"annularly": "adv.\u73af\u72b6\u5730",
"q-5": "\u5355\u5ea7\u53cc\u53d1\u8d85\u97f3\u901f\u653b\u51fb\u673a\u3002",
@solos
solos / offline_evernote.py
Created February 23, 2013 07:03
Offline evernote on android - solos's or diaosi's way to evernote pro.
#!/usr/bin/python
#coding=utf-8
import sqlite3
import os
from lxml import etree
def get_notes(ever_enex):
'''extract notes from .enex file'''
content = open(ever_enex, 'r').read()
#!/usr/bin/env python
# $Id$
import sys
import hashlib
import time
import copy
from string import Template
import thrift.protocol.TBinaryProtocol as TBinaryProtocol
import os
import re
import socket
import struct
def dns_resolve(host, dnsserver):
assert isinstance(host, basestring) and isinstance(dnsserver, basestring)
index = os.urandom(2)
hoststr = ''.join(chr(len(x))+x for x in host.split('.'))
data = '%s\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00%s\x00\x00\x01\x00\x01' % (index, hoststr)
@solos
solos / index.html
Created March 23, 2013 12:08
last.fm widget
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>last.fm | solos的网络日志</title>
</head>
<body>
<div>
<ul id="last_fm_tracks">
" fcitx.vim 记住插入模式小企鹅输入法的状态
" Author: lilydjwg
" Maintainer: lilydjwg
" Note: 另有使用 Python3 接口的新版本
" ---------------------------------------------------------------------
" Load Once:
if (has("win32") || has("win95") || has("win64") || has("win16"))
" Windows 下不要载入
finish
endif
"""
test commit creation with pygit2
To see the result:
rm -rf foo && python test_cc.py && cd foo/ && git log --graph --oneline --date-order --decorate --color --all && git status && cd ..
"""
import os
import sys
import pygit2
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@solos
solos / ping.py
Created June 8, 2013 05:02 — forked from pklaus/ping.py
#!/usr/bin/env python
"""
A pure python ping implementation using raw socket.
Note that ICMP messages can only be sent from processes running as root.
Derived from ping.c distributed in Linux's netkit. That code is