Skip to content

Instantly share code, notes, and snippets.

View jizhang's full-sized avatar

Jerry jizhang

View GitHub Profile
def import_submodules(package) -> None:
package = importlib.import_module(package)
for _, name, is_pkg in pkgutil.iter_modules(package.__path__):
full_name = package.__name__ + '.' + name
if is_pkg:
import_submodules(full_name)
else:
importlib.import_module(full_name)
@jizhang
jizhang / rows_to_list.py
Last active July 12, 2023 02:44
SQLAlchemy result serialization
from typing import Any, Iterable, List, Dict
from decimal import Decimal
from datetime import datetime
from sqlalchemy import Row
from sqlalchemy.orm import DeclarativeMeta
def row_to_dict(row) -> dict:
if isinstance(row, Row):
@jizhang
jizhang / csdn.py
Created August 9, 2017 22:21
Crawl CSDN Blog's Page Views
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import urllib2
import datetime
html = urllib2.urlopen('http://blog.csdn.net/zjerryj').read()
mo = re.search(r'访问:<span>(\d+)次</span>', html)
@jizhang
jizhang / server.py
Created March 22, 2017 09:39
Log Tailer with WebSocket and Python
# -*- coding: utf-8 -*-
import time
import os.path
import asyncio
import logging
import argparse
import websockets
from collections import deque
from urllib.parse import urlparse, parse_qs

xx项目

项目目标

本周进展(yyyy-mm-dd)

里程碑及产出

alias gl='git log --graph --pretty=format:'\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --date=relative'
@jizhang
jizhang / add_route.py
Created June 11, 2015 15:05
Add Route in Windows
import re
import subprocess
ipconfig = subprocess.check_output(['ipconfig'])
mo = re.search(r'192\.168\.189\.[0-9]+', ipconfig)
vpn = mo.group()
ips = [
['192.168.1.100'],
['192.168.1.61'],
@jizhang
jizhang / config
Last active January 3, 2017 12:40
GFW
# Linux
Host github.com
ProxyCommand socat STDIO PROXY:192.168.1.101:%h:%p,proxyport=8118
# Mac
Host github.com
ProxyCommand nc -X 5 -x 127.0.0.1:1086 %h %p
ServerAliveInterval 10
@jizhang
jizhang / JsonUtils.scala
Created January 26, 2015 02:53
json4s opt methods
import org.json4s._
object JsonUtils {
implicit class AugmentJValue(val jvalue: JValue) {
implicit val formats = DefaultFormats
def getString(key: String): String = {
@jizhang
jizhang / wordstream.py
Created January 18, 2015 06:28
simple word stream
import SocketServer
import random
import time
words = ('cat', 'dog', 'monkey', 'horse', 'rabbit')
class MyTCPHandler(SocketServer.BaseRequestHandler):
def handle(self):
while True:
self.request.sendall(' '.join(random.sample(words, 3)) + '\n')