Skip to content

Instantly share code, notes, and snippets.

View Mark24Code's full-sized avatar
💻
Exploring

Mark24 Mark24Code

💻
Exploring
View GitHub Profile
@Mark24Code
Mark24Code / README.md
Created April 8, 2018 02:07
Circular imports in Python 2 and Python 3: when are they fatal? When do they work?

When are Python circular imports fatal?

In your Python package, you have:

  • an __init__.py that designates this as a Python package
  • a module_a.py, containing a function action_a() that references an attribute (like a function or variable) in module_b.py, and
  • a module_b.py, containing a function action_b() that references an attribute (like a function or variable) in module_a.py.

This situation can introduce a circular import error: module_a attempts to import module_b, but can't, because module_b needs to import module_a, which is in the process of being interpreted.

But, sometimes Python is magic, and code that looks like it should cause this circular import error works just fine!

@Mark24Code
Mark24Code / unorderArr.js
Created January 10, 2018 09:11
乱序数组算法
function unorderArr(arr){
let carr = arr.concat();
carr.sort(function(x,y){
return 0.5-Math.random()
})
return carr
}
@Mark24Code
Mark24Code / base64toBob&AxiosUploadFile.js
Last active January 10, 2018 09:11
base64转文件,axios上传文件(适用于裁剪头像上传)
//base64转 bob文件
function dataURItoBlob(dataURI) {
// convert base64/URLEncoded data component to raw binary data held in a string
var byteString;
if (dataURI.split(',')[0].indexOf('base64') >= 0)
byteString = atob(dataURI.split(',')[1]);
else
byteString = unescape(dataURI.split(',')[1]);
// separate out the mime component
@Mark24Code
Mark24Code / mover.py
Created August 9, 2017 08:46
mover搬运工
# encoding: utf-8
"""
搬运工Mover
列表一一对应,搬运文件
Windows下要注意,硬盘符号要写成C:\\,Win下Unicode的问题
author: mark24
email: [email protected]
date: 2017.08.09
@Mark24Code
Mark24Code / README.txt
Last active July 17, 2017 08:44
基于Vue-cli多页面Build
webpack.prod.conf.js
添加的自定义函数
filename:编译后的目标文件,相对路径是 dist
template:明确的模板,相对路径是 项目根目录
然后,来源,是 entry一一对应的入口(这是隐藏的)
大原则,就是,和 webpack.base.config.js的Entry一一对应
import re
newlines = []
with open('ff','r',encoding='UTF-8') as f:
lines = f.readlines()
for line in lines:
m = re.search(r'.+: (\d.px).+',line)
newline = ''
if m:
@Mark24Code
Mark24Code / cooker.py
Last active June 23, 2017 09:08
煮粥电饭煲计算预约时间
# -*- coding: utf-8 -*-
"""用于计算煮,粥预约时间"""
from datetime import datetime, timedelta, date
now_datetime = datetime.now()
cook_what = 'zhou' # 粥
cooked_time = '6:00:00' # 次日时间
cook_menu = {
@Mark24Code
Mark24Code / _base.scss
Created June 5, 2017 02:13
微信小程序Gulp & Sass
@charset "UTF-8";
@function rpx($v) {
@return $v/1px * 1rpx;
}
@Mark24Code
Mark24Code / eleme.py
Created May 8, 2017 00:42 — forked from SaulLawliet/eleme.py
查询饿了么品牌馆中有哪些是 <真·五折>
# coding: utf-8
import json
import re
import requests
# 替换成你自己的经纬度数据
# 查询方式 打开饿了么官网 -> 开发者模式 -> 输入送餐地址 -> 观察请求 -> 找到经纬度数据
latitude = 31.23978
longitude = 121.49968
@Mark24Code
Mark24Code / mobile_fit.js
Last active April 28, 2017 05:29
rem layout
;
(function(doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
// 不同尺寸可以配置
// if(clientWidth>=640){
// docEl.style.fontSize = '100px';