此文目標讀者需先自行學會
- 開 Github 帳號
- 會 fork 程式 repository
- 會在自己的電腦使用命令列
git
- 會 clone 自己的 repository
// 检测浏览器的 User Agent 应该是非常简单的事情 | |
// 微信在 Android 下的 User Agent | |
mozilla/5.0 (linux; u; android 4.1.2; zh-cn; mi-one plus build/jzo54k) applewebkit/534.30 (khtml, like gecko) version/4.0 mobile safari/534.30 micromessenger/5.0.1.352 | |
// 微信在 iPhone 下的 User Agent | |
mozilla/5.0 (iphone; cpu iphone os 5_1_1 like mac os x) applewebkit/534.46 (khtml, like gecko) mobile/9b206 micromessenger/5.0 | |
// 通过javascript判断 | |
// 很容易看出来,微信的 User Agent 都有‘micromessenger’字符串标示,我们判断是否含有这些字符串就OK了 | |
function isWeixinBrowser(){ |
import ply.lex, argparse, io | |
#Usage | |
# python stripcomments.py input.tex > output.tex | |
# python stripcomments.py input.tex -e encoding > output.tex | |
#This utility is released under the WTFPL license: http://www.wtfpl.net/about/ | |
def strip_comments(source): | |
tokens = ( |
$('form :input').each(function(index, elem) { | |
var eId = $(elem).attr('id'); | |
var label = null; | |
if (eId && (label = $(elem).parents('form').find('label[for='+eId+']')).length === 1) { | |
$(elem).attr('placeholder', $(label).html()); |
define([ | |
'module/bootstrap', // this is jQuery and PubSub libs | |
], function (lib) { | |
var windowMock = { | |
resizeSet: false, // set within the fake `lib` object below | |
createFakeWindow: function(width, height) { | |
return { | |
document: { | |
documentElement: { |
import numpy as np | |
from collections import Counter | |
def transport(supply, demand, costs): | |
# Only solves balanced problem | |
assert sum(supply) == sum(demand) | |
s = np.copy(supply) |
#!/usr/bin/python | |
# GoogleMapDownloader.py | |
# Created by Hayden Eskriett [http://eskriett.com] | |
# | |
# A script which when given a longitude, latitude and zoom level downloads a | |
# high resolution google map | |
# Find the associated blog post at: http://blog.eskriett.com/2013/07/19/downloading-google-maps/ | |
import urllib | |
import Image |
#coding:utf-8 | |
''' | |
python图片处理 | |
@author:fc_lamp | |
@blog:http://fc-lamp.blog.163.com/ | |
''' | |
import Image as image | |
#等比例压缩图片 | |
def resizeImg(**args): |
#coding: utf-8 | |
from nose.plugins.skip import SkipTest | |
from mongoengine.python_support import PY3 | |
from mongoengine import connect | |
try: | |
from django.test import TestCase | |
from django.conf import settings | |
except Exception as err: |