Skip to content

Instantly share code, notes, and snippets.

Avatar

Fanxin Yang mdjhny

View GitHub Profile
@mdjhny
mdjhny / install_node_sass.sh
Created May 20, 2017
如何快速安装node-sass
View install_node_sass.sh
# 使用淘宝镜像
npm i node-sass --sass-binary-site=http://npm.taobao.org/mirrors/node-sass
@mdjhny
mdjhny / what-forces-layout.md
Created Sep 30, 2015 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

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()
View 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.
View IconMaker
#!/usr/local/bin/php
<?php
# 注:请注意php路径,并给这个文件执行权限!!!
# 通过原始1024X1024图片来生成各种iphone ios icon,包含Content.json
#
# 使用说明:
# 1、默认生成到当前目录: IconMaker 1024.png
# 2、指定路径: IconMaker 1024.png ~/Desktop/icon/
View citydata.js
var citydata =[
{province:'北京市',city:['东城区','西城区','朝阳区','丰台区','石景山区','海淀区','门头沟区','房山区','通州区','顺义区','昌平区','大兴区','怀柔区','平谷区','密云县','延庆县']},
{province:'天津市',city:['和平区','河东区','河西区','南开区','河北区','红桥区','东丽区','西青区','津南区','北辰区','武清区','宝坻区','滨海新区','宁河县','静海县','蓟县']},
{province:'河北省',city:['石家庄市','唐山市','秦皇岛市','邯郸市','邢台市','保定市','张家口市','承德市','沧州市','廊坊市','衡水市']},
{province:'山西省',city:['太原市','大同市','阳泉市','长治市','晋城市','朔州市','晋中市','运城市','忻州市','临汾市','吕梁市']},
{province:'内蒙古自治区',city:['呼和浩特市','包头市','乌海市','赤峰市','通辽市','鄂尔多斯市','呼伦贝尔市','巴彦淖尔市','乌兰察布市','兴安盟','锡林郭勒盟','阿拉善盟']},
{province:'辽宁省',city:['沈阳市','大连市','鞍山市','抚顺市','本溪市','丹东市','锦州市','营口市','阜新市','辽阳市','盘锦市','铁岭市','朝阳市','葫芦岛市']},
{province:'吉林省',city:['长春市','吉林市','四平市','辽源市','通化市','白山市','松原市','白城市','延边朝鲜族自治州']},
{province:'黑龙江省',city:['哈尔滨市','齐齐哈尔市','鸡西市','鹤岗市','双鸭山市','大庆市','伊春市','佳木斯市','七台河市','牡丹江市','黑河市','绥化市','大兴安岭地区']},
{province:'上海市',city:['黄浦区','徐汇区','长宁区','静安区','普陀区','闸北区','虹口区','杨浦区','闵行区','宝山区','嘉定区','浦东新区','金山区','松江区','青浦区','奉贤区','崇明县']},
@mdjhny
mdjhny / anti_spam.php
Created Sep 3, 2013
防止用户恶意或者重复提交数据,进行code验证
View anti_spam.php
<?php
$salt = 'qwerty';
if (!empty($_GET['code'])) {
$code = $_GET['code'];
list($time, $encode) = explode('_', $code);
if ($encode != md5($time . $salt)) {
echo '非法请求';
exit();
}
@mdjhny
mdjhny / is_cn.py
Created Aug 13, 2013
判断字符是否为中文
View is_cn.py
def is_cn_char(i):
return 0x4e00<=ord(i)<0x9fa6
def is_cn_or_en(i):
o = ord(i)
return o<128 or 0x4e00<=o<0x9fa6
View ip.py
class Node(object):
def __init__(self, value, is_start):
self.value = value
self.is_start = is_start
def __lt__(self, other):
if self.value != other.value:
return self.value < other.value
@mdjhny
mdjhny / 管道和输入同时作为输入的解决办法
Created Aug 8, 2013
管道和输入同时作为输入的解决办法
View 管道和输入同时作为输入的解决办法
如果脚本从管道获取输入,同时需要有输入交互,可以采取以下三种措施:
http://mail.python.org/pipermail/python-list/2000-March/020133.html
* Put the data in a file and pass the name of the file to your
script, then open that file:
lines = open(sys.argv[1]).readlines()
This is probably the nicest solution, and the least prone to making
wierd things happen if your script gets run differently.
@mdjhny
mdjhny / 18位身份证校验方法
Created Jul 24, 2013
18位身份证校验方法
View 18位身份证校验方法
18位身份证标准在国家质量技术监督局于1999年7月1日实施的GB11643-1999《公民身份号码》中做了明确规定。
GB11643-1999《公民身份号码》为GB11643-1989《社会保障号码》的修订版,其中指出将原标准名称“社会保障号码”更名为“公民身份号码”,另外GB11643-1999《公民身份号码》从实施之日起代替GB11643-1989。
公民身份号码是特征组合码,由十七位数字本体码和一位校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位校验码。其含义如下:
1. 地址码:表示编码对象常住户口所在县(市、旗、区)的行政区划代码,按GB/T2260的规定执行。
2. 出生日期码:表示编码对象出生的年、月、日,按GB/T7408的规定执行,年、月、日分别用4位、2位、2位数字表示,之间不用分隔符。
3. 顺序码:表示在同一地址码所标识的区域范围内,对同年、同月、同日出生的人编定的顺序号,顺序码的奇数分配给男性,偶数分配给女性。
You can’t perform that action at this time.