Skip to content

Instantly share code, notes, and snippets.

View mdjhny's full-sized avatar

Fanxin Yang mdjhny

View GitHub Profile
@mdjhny
mdjhny / factorize.py
Last active December 14, 2015 06:48
Python分解因数
def factorize(n):
'''Adapted from http://www.math.utah.edu/~carlson/notes/python.pdf'''
if n < 2:
return '本函数仅适用于不小于2的正整数'
d = 2
factors = []
while not n % d:
factors.append(d)
n /= d
d = 3
@mdjhny
mdjhny / .vimrc
Created February 23, 2013 14:12
vim的python配置 即使配置如此 ,Python的缩进也并不是很理想。比较好的选择是再使用一个插件 hynek/vim-python-pep8-indent。
"自动缩进
set autoindent
"类似C语言风格的缩进
set cindent
"智能缩进:每一行都和前一行有相同的缩进量,
"同时这种缩进形式能正确的识别出花括号,当遇到右花括号(}),
"则取消缩进形式。此外还增加了识别C语言关键字的功能。
"如果一行是以#开头的(比如宏),那么这种格式将会被特殊对待而不采用缩进格式
set smartindent
"For Python Programmers
@mdjhny
mdjhny / tail.py
Last active December 14, 2015 02:19
用python实现的类似tail的程序
from mmap import mmap
def tail(fn, count=10):
with open(fn,'r+') as f:
data = mmap(f.fileno(), 0)
pos = len(data)
for _ in range(count):
pos = data.rfind('\n', 0, pos)
if pos == -1:
pos = 0
break
@mdjhny
mdjhny / README.md
Created January 3, 2013 11:45 — forked from wong2/README.md

人人的登录改版后,采用RSA加密后传输密码,该项目用于解决这种情况下人人的模拟登录

使用前先 pip install requests

@mdjhny
mdjhny / what-forces-layout.md
Created September 30, 2015 02:38 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@mdjhny
mdjhny / bash-invocation.md
Created January 6, 2012 12:35 — forked from yegle/bash-invocation.md
Bash Shell启动方式与RC脚本

Bash Shell启动方式与rc脚本

Shell的不同分类

根据启动Bash Shell的方式不同,对Shell有两种分类方式

登录Shell与非登录Shell

根据Shell的启动方式不同,可以将Shell分为

@mdjhny
mdjhny / Makefile
Last active August 29, 2015 14:24 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@mdjhny
mdjhny / IconMaker
Last active August 29, 2015 14:16 — forked from jevonszmx/IconMaker
#!/usr/local/bin/php
<?php
# 注:请注意php路径,并给这个文件执行权限!!!
# 通过原始1024X1024图片来生成各种iphone ios icon,包含Content.json
#
# 使用说明:
# 1、默认生成到当前目录: IconMaker 1024.png
# 2、指定路径: IconMaker 1024.png ~/Desktop/icon/