This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload=function(){ | |
var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire"); | |
var browser = navigator.userAgent.toLowerCase(); | |
for (var i=0; i<mobileAgent.length; i++){ | |
if (browser.indexOf(mobileAgent[i])!=-1){ | |
alert(mobileAgent[i]); | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# author: haofly | |
# | |
# fun: 生成随机姓名、随机电话号码、随机字符串,目前仅支持Python2 | |
import random | |
def generateName(first_len=0, last_len=0): | |
surnames = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def mycmp(version1, version2): | |
def normalize(v): | |
return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")] | |
return cmp(normalize(version1), normalize(version2)) | |
if __name__ == '__main__': | |
assert mycmp("1", "1") == 0 | |
assert mycmp("2.1", "2.2") < 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qiniu import Auth, put_file, etag, urlsafe_base64_encode, BucketManager | |
from typing import List, Dict | |
import os | |
from qiniu import build_batch_delete | |
class Sync: | |
""" | |
同步目录至七牛云 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import graphene | |
from graphene import String | |
from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField | |
from promise import Promise | |
from promise.dataloader import DataLoader | |
from sqlalchemy import Column, BigInteger, ForeignKey | |
from sqlalchemy.orm import relationship | |
from db import Base, db_session # 这里自己去定义 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 覆盖Laravel默认的SoftDeletingScope,用于替换软删除的默认行为,解决deleted_at必须为NULL的问题,为NULL的时候不能设置唯一键 | |
* 即默认是whereNull更改为判断timestamp的0值,即'0000-00-00 00:00:00'(空字符串在某些数据库版本也是可以的,但是考虑到兼容性还是写全吧),以使deleted_at字段不为NULL | |
* 使用时只需要把之前Model中的`use SoftDeletes`替换为`use LaravelCustomSoftDeletes`即可 | |
* 请自行替换本文件中的部分命名空间 | |
*/ | |
namespace Common; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.haofly.net.sensitiveword; | |
public class BCConvert { | |
/** | |
* ASCII表中可见字符从!开始,偏移位值为33(Decimal) | |
*/ | |
static final char DBC_CHAR_START = 33; // 半角! |