V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
prasanta
V2EX  ›  Python

无聊之极,写了一个自动填满 github 绿格子的脚本!365 天全绿哟!

  •  
  •   prasanta · 2017 年 3 月 28 日 · 7125 次点击
    这是一个创建于 3218 天前的主题,其中的信息可能已经有所发展或是发生改变。

    申明:仅供测试,仅供娱乐

    代码行数: 29 行

    效果

    result

    用法

    1. fork
    2. clone
    3. run python greenbox.py
    4. push

    项目地址

    https://github.com/gaojiuli/greenbox

    申明

    仅供娱乐

    第 1 条附言  ·  2017 年 3 月 28 日
    别人 fork 的备份, https://github.com/xia0ming/greenbox
    第 2 条附言  ·  2017 年 3 月 28 日

    https://github.com/xia0ming/greenbox/raw/master/result.png

    30 条回复    2017-08-28 13:39:10 +08:00
    ansheng
        1
    ansheng  
       2017 年 3 月 28 日
    刚测了一下,并没有成功
    prasanta
        2
    prasanta  
    OP
       2017 年 3 月 28 日
    @ansheng 如果没有成功,你可以直接把里面的 python 脚本到自己的任何一个项目,然后运行它,然后 push 到自己的项目
    prasanta
        3
    prasanta  
    OP
       2017 年 3 月 28 日
    我去删除项目了

    ## 代码如下

    ```python
    import datetime
    import os
    from random import randint

    now = datetime.datetime.now()
    start = now.replace(year=2016)


    def change_day():
    return datetime.timedelta(days=1, seconds=randint(0, 60), minutes=randint(0, 60), hours=randint(0, 24))


    def change_time():
    return datetime.timedelta(seconds=randint(0, 60), minutes=randint(0, 60))


    commit_date = (start + change_day())
    times = randint(5, 30)

    while commit_date < now:

    commit_date = commit_date + change_day()
    for i in range(times):
    f = open('data.txt', 'a+')
    commit_date = commit_date + change_time()
    f.writelines(commit_date.isoformat() + '\n')
    f.close()
    os.system('git add .')
    os.system('git commit --date={time} -m "Update {time}"'.format(time=commit_date.isoformat()))
    ```
    ansheng
        4
    ansheng  
       2017 年 3 月 28 日
    @prasanta 我就是新建一个仓库,然后脚本复制过去执行提交,然而- -。
    prasanta
        5
    prasanta  
    OP
       2017 年 3 月 28 日
    @ansheng push 后大约 30 秒, github 会统计出来. 你甚至可以放到你的其它项目里面执行
    to2false
        6
    to2false  
       2017 年 3 月 28 日
    你把项目删了, f = open('data.txt', 'a+') 怎么破
    prasanta
        7
    prasanta  
    OP
       2017 年 3 月 28 日
    @to2false  脚本在上面,哪里有问题吗
    to2false
        8
    to2false  
       2017 年 3 月 28 日
    @prasanta 没事了
    ansheng
        9
    ansheng  
       2017 年 3 月 28 日
    @prasanta 然而我就成功了,不知道会不会被删除。
    yoa1q7y
        10
    yoa1q7y  
       2017 年 3 月 28 日
    能不能不要这样...
    to2false
        11
    to2false  
       2017 年 3 月 28 日
    @prasanta 本地跑了下, git commit 的时间都 3.29 了=-=
    martint028
        12
    martint028  
       2017 年 3 月 28 日
    很爽啊,楼主自学 python ?
    wolfan
        13
    wolfan  
       2017 年 3 月 28 日
    没事还是多陪陪媳妇不好?不要那啥也绿了, python 可刷不红啊。
    prasanta
        14
    prasanta  
    OP
       2017 年 3 月 28 日
    @to2false 你一定是哪里操作错了
    prasanta
        15
    prasanta  
    OP
       2017 年 3 月 28 日
    @yoa1q7y 嘻嘻
    0x5e
        16
    0x5e  
       2017 年 3 月 28 日
    @wolfan 前提是。。。
    prasanta
        17
    prasanta  
    OP
       2017 年 3 月 28 日
    @martint028 自学的啊
    prasanta
        18
    prasanta  
    OP
       2017 年 3 月 28 日
    @wolfan 下班后才陪媳妇儿呀
    prasanta
        19
    prasanta  
    OP
       2017 年 3 月 28 日
    @0x5e 你猜错啦
    zhidian
        20
    zhidian  
       2017 年 3 月 28 日   ❤️ 1
    还可以把 git 的邮箱名改成 Linus Torvalds 等各路大神的,再 commit ,然后发现你的 repo 真是众星云集啊!不过,这并没有什么卵用。
    xiubin
        21
    xiubin  
       2017 年 3 月 28 日
    Jackeriss
        22
    Jackeriss  
       2017 年 3 月 28 日 via iPhone
    @prasanta 上班时间无聊之极……楼主是哪个单位的?
    licraft
        23
    licraft  
       2017 年 3 月 29 日
    所以,自动填满格子意义何在?
    winfirm
        24
    winfirm  
       2017 年 3 月 29 日
    @licraft 呵呵,感觉没啥实际用途。
    zoffy
        25
    zoffy  
       2017 年 3 月 29 日
    骗人骗己
    lollitop
        26
    lollitop  
       2017 年 3 月 29 日
    好无趣的玩意。。
    nyanyh
        27
    nyanyh  
       2017 年 3 月 29 日
    全刷绿,再到淘宝买 GitHub 刷 star 服务,短时间内成为开源大神
    CareiOS
        28
    CareiOS  
       2017 年 3 月 29 日
    果然无聊之极。
    cocoakekeyu
        29
    cocoakekeyu  
       2017 年 4 月 4 日
    请问楼主单位还招人吗
    changdaye
        30
    changdaye  
       2017 年 8 月 28 日
    为什么没有成功??
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3798 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 05:06 · PVG 13:06 · LAX 21:06 · JFK 00:06
    ♥ Do have faith in what you're doing.