Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

蒲公英の生活 ohcrider

🏠
Working from home
View GitHub Profile
@ohcrider
ohcrider / page.md
Last active Aug 26, 2019
page logic
View page.md

小于等于页数7

  • 页数 5 1 2 3 4 5
  • 页数 6 1 2 3 4 5 6
  • 页数 7 1 2 3 4 5 6 7

大于页数7

示例一 (页数能整除

@ohcrider
ohcrider / test.js
Last active Apr 22, 2019
js 递归函数 获取json
View test.js
function fetchLast(obj, strs) {
// 1
// obj = a
// strs = ['b', 'c', 'd']
// 2
// obj = a['b']
// strs = ['c', 'd']
// 3
@ohcrider
ohcrider / format.js
Last active Dec 19, 2018
三目运算符避免不正确的数据
View format.js
var data = {
a: {
b: ''
},
d: '0',
dct: {
'0': 'aaaa',
'1': 'bbbb'
}
}
@ohcrider
ohcrider / request.js
Last active Dec 4, 2018
通用请求类
View request.js
import 'whatwg-fetch';
import queryString from 'query-string';
import { fetchMessage, fetchRootDomain } from './helper';
import { toast } from 'react-toastify';
export default class Request {
constructor(token) {
this.baseUrl = fetchRootDomain() + '/';
this.token = token;
}
@ohcrider
ohcrider / underscorejs-basic-usage.md
Last active Dec 4, 2018
underscorejs基本用法
View underscorejs-basic-usage.md

字典转数组

var dct = {
  a: 1,
  b: 2,
  c: 3
};

var list = _.map(_.pairs(dct), (item)=> {
  return {
View git-basic-usage.md

git clone git@github.com:fewspider/client-1.git 克隆一个项目到本地,默认路径是git项目的地址

git status 查看当前分支的状态

git add . 添加当前的修改

git commit -m 'update' 记录一个修改

git push origin master 提交当前所有修改到远程master分支

@ohcrider
ohcrider / isIntNumber.js
Last active Nov 4, 2015
javascript check int number
View isIntNumber.js
function isIntNumber(value) {
var numberRe = /^-?[0-9]+$/;
return typeof(value) === 'number' && numberRe.test(value);
}
@ohcrider
ohcrider / base10to26.py
Last active Sep 24, 2015
python converter 10 to 26
View base10to26.py
# -*- coding: utf-8 -*-
'''
copyright: (c) 2015 by fewspider(fewspider@gmail.com).
~~~~~~~~~
converter 10 to 26,like:
1 -> A
2 -> B
27 -> AA
~~~~~~~~~
test it: