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-03-28 17:40:27 +08:00 · 6372 次点击
    这是一个创建于 2557 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    代码行数: 29 行

    效果

    result

    用法

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

    项目地址

    https://github.com/gaojiuli/greenbox

    申明

    仅供娱乐

    第 1 条附言  ·  2017-03-28 18:14:14 +08:00
    别人 fork 的备份, https://github.com/xia0ming/greenbox
    第 2 条附言  ·  2017-03-28 18:15:08 +08:00

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

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

    ## 代码如下

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