2019年5月

  • 首先打开“系统偏好设置”。
  • 选择“用户与群组”。
  • 点击右下角的小锁,输入你的用户的密码。
  • 点击“登录选项”,点击右边网络账户服务器后面的“加入...”
    QQ20190530-0.png
  • 选择“打开目录实用工具”
    QQ20190530-1.png
  • 再弹出的页面中继续点击右下角的小锁,输入你的密码。
  • 在顶部的导航栏内选择“启用 Root 用户”,在这里也可以更改你的root的密码,以及停用你的root用户。

  1. 首先介绍一个mac上非常好用的命令行工具:iterm2.这个对后续的操作没有影响,只是小编用的比较舒心。哈哈哈哈。
  2. 在你的~文件夹下建立一个.bashrc文件,并且保存一下文件。可以使用 vi .bashrc进行操作,把以下内容复制到你新建的这个文件中。

    function git_branch {
    branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"
    if [ "${branch}" != "" ];then
        if [ "${branch}" = "(no branch)" ];then
            branch="(`git rev-parse --short HEAD`...)"
        fi
        echo " ($branch)"
    fi
    }
    
    export PS1='\u@\h \[\033[01;36m\]\W\[\033[01;32m\]$(git_branch)\[\033[00m\] \$ '

    如果你不会使用vi编辑器,可以查看小编的其他文章哦。

  3. 保存之后执行:source ~/.bashrc
  4. 如果你是mac的话,在执行下:echo "[ -r ~/.bashrc ] && source ~/.bashrc" >> .bash_profile
    然后你就大功告成了(如果没权限的话,切换到你的root用户去操作).

小编今天在整理两个文件对比的时候,打算自己做一个可执行的python程序,进行对比,在读取其中一个文件的时候,里面有很多的空行,小编就自己解决了下,希望对大家有所帮助.

f2 = open('setphonedistrict.log.1','r')
for line in f2:
    a=line.strip()
    if len(a)!=0:
        print(a)

是不是很简单呢。

  • 切换到root用户。

    sudo su
  • 在/home文件夹中简历一个用户名的文件夹(比如:sunxiaoning)

    mkdir sunxiaoning
  • 赋予权限

    chmod -R 777 /home/sunxiaoning
  • 添加用户

    useradd sunxiaoning
  • 给用户设置密码

    passwd sunxiaoning

    输入两次密码后就可以了

  • 为该用户指定命令解释程序(通常为/bin/bash)

    usermod -s /bin/bash sunxiaoning
  • 为用户设置主目录

    usermod -d /home/sunxiaoning sunxiaoning
  • 切换用户

    su sunxiaoning

小编在这里总结下比较3位版本号的方法,比如1.2.1和1.3.1。相等就返回0,大于就返回1,小于就返回-1.
实现方法如下:

def compare_version(a, b):
    '''比较版本号'''
    la = a.split('.')
    lb = b.split('.')
    f = 0
    if len(la) > len(lb):
        f = len(la)
    else:
        f = len(lb)
    for i in range(f):
        try:
            if int(la[i]) > int(lb[i]):
                return 1
            elif int(la[i]) == int(lb[i]):
                continue
            else:
                return -1
        except IndexError as e:
            if len(la) > len(lb):
                return 1
            else:
                return -1
    return 0

git更换远程仓库

u=1297849412,795774049&fm=26&gp=0.jpg

  1. 从原地址克隆一份裸版本库

    git clone --bare  迁移之前的地址
  2. 在新的服务器建立一个新的仓库,主要不要勾选Initialize repository with a README。
  3. 删除现在的地址,换成新仓库的地址

     git remote set-url --push origin 新的仓库地址
  4. 以镜像推送的方式上传到新的仓库

    git push --mirror 

微信小程序九宫格抽奖,随机选中奖品。

wxml

<view class="container-out">
  <view class="circle" wx:for="{{circleList}}" style="top:{{item.topCircle}}rpx;left:{{item.leftCircle}}rpx;background-color: {{(index%2==0)?colorCircleFirst:colorCircleSecond}};"></view>
  <view class="container-in">
    <view class="content-out" wx:for="{{awardList}}" style="top:{{item.topAward}}rpx;left:{{item.leftAward}}rpx;background-color: {{(index==indexSelect)?colorAwardSelect:colorAwardDefault}};">
     {{item.Award.name}}
    </view>
    <view class="start-btn" bindtap="startGame" style=" background-color:{{isRunning?'#e7930a':'#ffe400'}}">抽奖</view>
  </view>
</view>

js

Page({
    data: {
        circleList: [],//圆点数组
        awardList: [],//奖品数组
        colorCircleFirst: '#FFDF2F',//圆点颜色1
        colorCircleSecond: '#FE4D32',//圆点颜色2
        colorAwardDefault: '#F5F0FC',//奖品默认颜色
        colorAwardSelect: '#ffe400',//奖品选中颜色
        indexSelect: 0,//被选中的奖品index
        isRunning: false,//是否正在抽奖
        Award: [
            { name: '2元', value: 2 },
            { name: '免单', value: 100 },
            { name: '3元', value: 3 },
            { name: '2.66元', value: 2.66 },
            { name: '3.88元', value: 3.88 },
            { name: '4元', value: 4 },
            { name: '3.66元', value: 3.66 },
            { name: '2.88元', value: 2.88 },
           
        ],//奖品数组
    },

    onLoad: function () {
        var _this = this;
        //圆点设置
        var leftCircle = 7.5;
        var topCircle = 7.5;
        var circleList = [];
        for (var i = 0; i < 24; i++) {
            if (i == 0) {
                topCircle = 15;
                leftCircle = 15;
            } else if (i < 6) {
                topCircle = 7.5;
                leftCircle = leftCircle + 102.5;
            } else if (i == 6) {
                topCircle = 15
                leftCircle = 620;
            } else if (i < 12) {
                topCircle = topCircle + 94;
                leftCircle = 620;
            } else if (i == 12) {
                topCircle = 565;
                leftCircle = 620;
            } else if (i < 18) {
                topCircle = 570;
                leftCircle = leftCircle - 102.5;
            } else if (i == 18) {
                topCircle = 565;
                leftCircle = 15;
            } else if (i < 24) {
                topCircle = topCircle - 94;
                leftCircle = 7.5;
            } else {
                return
            }
            circleList.push({ topCircle: topCircle, leftCircle: leftCircle });
        }
        this.setData({
            circleList: circleList
        })
        //圆点闪烁
        setInterval(function () {
            if (_this.data.colorCircleFirst == '#FFDF2F') {
                _this.setData({
                    colorCircleFirst: '#FE4D32',
                    colorCircleSecond: '#FFDF2F',
                })
            } else {
                _this.setData({
                    colorCircleFirst: '#FFDF2F',
                    colorCircleSecond: '#FE4D32',
                })
            }
        }, 500)
        //奖品item设置
        var awardList = [];
        //间距,怎么顺眼怎么设置吧.
        var topAward = 25;
        var leftAward = 25;
        for (var j = 0; j < 8; j++) {
            if (j == 0) {
                topAward = 25;
                leftAward = 25;
            } else if (j < 3) {
                topAward = topAward;
                //166.6666是宽.15是间距.下同
                leftAward = leftAward + 166.6666 + 15;
            } else if (j < 5) {
                leftAward = leftAward;
                //150是高,15是间距,下同
                topAward = topAward + 150 + 15;
            } else if (j < 7) {
                leftAward = leftAward - 166.6666 - 15;
                topAward = topAward;
            } else if (j < 8) {
                leftAward = leftAward;
                topAward = topAward - 150 - 15;
            }
            var Award = this.data.Award[j];
            awardList.push({ topAward: topAward, leftAward: leftAward, Award: Award });
        }
        this.setData({
            awardList: awardList
        })
    },
    //开始游戏
    startGame: function () {
        if (this.data.isRunning) return
        this.setData({
            isRunning: true
        })
        var _this = this;
        var indexSelect = 0
        var i = 0;
        let f = Math.floor(Math.random() *8);
        console.warn(f)
        var timer = setInterval(function () {
            indexSelect++;
            //可根据自己的需求改变转盘速度
            i += 90;
            if (i > 1000) {
                //判断是随机生成的那个值得时候就停止
                if (f == indexSelect % 8){
                    _this.setData({
                        indexSelect: indexSelect
                    })
                    //去除循环
                    clearInterval(timer)

                    _this.setData({
                        isRunning: false
                    })
                }
                
                
                //获奖提示
                if(!_this.data.isRunning){
                    wx.showModal({
                        title: '恭喜您',
                        content: '获得了' + (_this.data.Award[f].name)+'尚坡红包',
                        showCancel: false,//去掉取消按钮
                        success: function (res) {
                            if (res.confirm) {

                            }
                        }
                    })
                }
               
            }
            indexSelect = indexSelect % 8;
            _this.setData({
                indexSelect: indexSelect
            })
        }, (200 + i))
    }
})

wxss

.container-out {
  height: 600rpx;
  width: 650rpx;
  background-color: #b136b9;
  margin: 100rpx auto;
  border-radius: 40rpx;
  box-shadow: 0 10px 0 #871a8e;
  position: relative;
}

.container-in {
  width: 580rpx;
  height: 530rpx;
  background-color: #871a8e;
  border-radius: 40rpx;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
}


.circle {
  position: absolute;
  display: block;
  border-radius: 50%;
  height: 20rpx;
  width: 20rpx;
}

.content-out {
  position: absolute;
  text-align: center;
  height: 150rpx;
  width: 166.6666rpx;
  background-color: #f5f0fc;
  border-radius: 15rpx;
  box-shadow: 0 5px 0 #d87fde;
  color: #f6251e;
  line-height: 150rpx;
}

/**居中 加粗*/

.start-btn {
  position: absolute;
  margin: auto;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  border-radius: 15rpx;
  height: 150rpx;
  width: 166.6666rpx;
  background-color: #ffe400;
  box-shadow: 0 5px 0 #e7930a;
  color: #f6251e;
  text-align: center;
  font-size: 55rpx;
  font-weight: bolder;
  line-height: 150rpx;
}

  1. 首先通过git commit --amend这个命令打开最近一次提交的信息,第一行就是你的注释,通过vim编辑器进行编辑,编辑之后保存就可以了。
  2. 通过git push --force sunxiaoning sunxiaoning强行推送到你的代码库。