Skip to content

Instantly share code, notes, and snippets.

View jwz-ecust's full-sized avatar
:shipit:
=。=

jwzhang jwz-ecust

:shipit:
=。=
View GitHub Profile
@jwz-ecust
jwz-ecust / read_contcar.py
Last active February 28, 2017 07:35
read contcar file, which is used to add CO mole to the slab
def read_contcar(contcar_path):
'''
read data from contcar file
return coordiante_array and atom_list
Target: 需要读取 原子种类, 原子坐标, 晶胞参数
return:
lattice (a. b. c)
atom, x, y, z, tf_x, tf_y, tf_z
'''
with open(contcar_path, 'r') as f:
@jwz-ecust
jwz-ecust / 0_reuse_code.js
Created March 14, 2017 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jwz-ecust
jwz-ecust / goose_chinese.py
Created March 14, 2017 14:20
简单的文章爬取库
# -*- coding: utf-8 -*-
# @Date : 2017-03-14 22:03:55
# @Author : "zhangjiawei"
# @Email : "aaronzjw@icloud.com"
# @Link : ${https://github.com/jwz-ecust}
# @Version : $Id$
from goose import Goose
from goose.text import StopWordsChinese
@jwz-ecust
jwz-ecust / identifyid.py
Created March 22, 2017 01:17
身份证验证
# -*- coding:utf-8 -*-
import re
IDCARD_REGEX = '[1-9][0-9]{14}([0-9]{2}[0-9X])?'
# 新身份证18位, 最后一位可能是X; 老身份证15位
def is_valid_idcard(idcard):
"""Validate id card is valid."""
if isinstance(idcard, int):
@jwz-ecust
jwz-ecust / paramiko_download_linux.py
Last active March 24, 2017 02:43
paramiko download from linux server
import paramiko
import os
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
IP = "***********"
# port = 22
# user = "riic"
# key = "/Users/zhangjiawei/.ssh/id_dsa_138_jwzhang.jwzhang"
@jwz-ecust
jwz-ecust / test.py
Created April 11, 2017 02:30
decorator
class zjw():
def __init__(self):
self.name = 1
@classmethod
def classmethod(cls, arg):
print dir(cls)
print cls
print dir(arg)
print arg
@jwz-ecust
jwz-ecust / python
Created July 11, 2017 08:48
计算相距最远的两个相等元素
from collections import Counter
from collections import defaultdict
def solution(A):
c = Counter(A)
repeat = [i for i in c if c[i] > 1]
ddict = defaultdict(list)
for i in range(len(A)):
ddict[A[i]].append(i)
dis = [max(ddict[i]) - min(ddict[i]) for i in ddict if len(ddict[i]) > 1]
@jwz-ecust
jwz-ecust / getmuchongcredit.py
Created August 15, 2017 16:41
木虫金币自动领取
import requests
import re
url = "http://muchong.com/bbs/logging.php?action=login"
sess = requests.session()
# 构建headers
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) \
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 \
@jwz-ecust
jwz-ecust / traj2pov.py
Created August 31, 2019 02:09
ase traj to pov input
import os
import sys
from glob import glob
from ase.io import read, write
from ase import Atoms
import numpy as np
from ase.utils import natural_cutoffs
from ase.build import molecule
import matplotlib.pyplot as plt
@jwz-ecust
jwz-ecust / traj2pov.py
Last active August 31, 2019 02:10
ase traj to pov input
import os
import sys
from glob import glob
from ase.io import read, write
from ase import Atoms
import numpy as np
from ase.utils import natural_cutoffs
from ase.build import molecule
import matplotlib.pyplot as plt