[PYTHON] Disguise the grass on GitHub and try to become an engineer.

"The grass doesn't grow ... I don't have time to grow ..."

This trouble that anyone who has a GitHub account and commits will visit. The moment you commit to GitLab on your personal server, it goes to your private repository on GitHub. When making a program that automatically recommits as a backup I've come up with a silly Python program that disguises grass, so I'll write it.

Main subject

First of all, you need a computer or server to run this program. It's a good idea to put it on your personal laptop or server as a starting point. The following assumes the case of Linux.

Things necessary

The installation method for Python and Git is different for each OS. Please check each one.

Also, the directory structure of the one I'm about to create looks like this. (As for the README, please)

your repository/
   ├ bot.py
   ├ bot.sh
   ├ bot.txt
   └ README.md

Creating a repository on GitHub

Would you like to appeal to someone who commits to your private repository every day? Also, let's make it a private repository in the sense that the commit contents will not be revealed. If you can, run git clone <Your GitHub repos URL> in a shell on your computer to clone it to a suitable folder.

It's a big deal, and let's put this program in the folder of this repository.

Creating a Python program


#Library import
import time
import os
import random

while True: #loop

#Find the current time
    tm = str(time.time()) 

#In the same folder as this program, put a txt file that records the value of the variable tm every rotation. You can write in w mode
    with open("bot.txt", mode = 'w') as f: 

#This is a statement that causes a shell on your computer to execute a command.
#It's annoying, so I wrote all the Git commit processing in the shell script

# 1-Randomly repeat every 40,000 seconds
    delay = random.randint(1,40000)

I wrote it in a few minutes, so I don't really care about the result. A level where you can move. Next, write a shell script. For Windows, write in a batch file.


#! /usr/bin/bash
git add .
git commit -m "autocommited"
git push -u origin master

Yes, this is also very simple.

bot.Since txt is written by a Python program, it can be empty.

#### **`bot.txt`**

Now let's run it in python.

python bot.py

 If you want to run even if you close the shell

#### **`python bot.py &`**
```py &

 If you want the server to ssh and run it even if the SSH is solved

#### **`nohup python bot.py &`**
```py &

 Adjust the value of `` `delay``` on the Python side as you like.
 The shell script may not work as it is, so once

#### **`chmod 755 bot.Let's secure authority by hitting sh`**
```Let's secure authority by hitting sh

## Finally

 -** This really works, but it's a joke program. ** **

 -** We do not take any responsibility for all events caused by the growth of false grass. Do it at your own risk. ** **

 ――For example, I think that some students who want to make an impression from a company think "I like this!" And execute the above program seriously. But, the contents of the code of `` `commit```, `` `push```, `` Python```, etc. in the shell script of how to create the repository of GitHub written above People who don't understand at all shouldn't do this. It's not good for me. There is more to do than doing this. definitely. I used to be like that, so with a sense of self-discipline ...

Recommended Posts

Disguise the grass on GitHub and try to become an engineer.
The road to installing Python and Flask on an offline PC
Put Cabocha 0.68 on Windows and try to analyze the dependency with Python
I tried to summarize until I quit the bank and became an engineer
I made a POST script to create an issue on Github and register it in the Project
Try CIing the pushed python code on GitHub.
Try to estimate the number of likes on Twitter
Try running a Schedule to start and stop an instance on AWS Lambda (Python)
Code to send an email based on the Excel email list
How to pass and study the Python 3 Engineer Certification Basic Exam
Quickly install OpenCV 2.4 (+ python) on OS X and try the sample
Try to write a program that abuses the program and sends 100 emails
Try to implement and understand the segment tree step by step (python)
Python 3.6 on Windows ... and to Xamarin.
1 Click to become an executive button
Try to introduce the theme to Pelican
Try Ajax on the Django page
Install fabric on Ubuntu and try
Cython to try in the shortest
The fastest way to try EfficientNet
The easiest way to try PyQtGraph
Study abroad, change jobs and become a Pyhon engineer from the 30s
Install ROS and ROS module for Roomba on RaspberryPi3 and try to run it
Work memo to migrate and update Python 2 series scripts on the cloud to 3 series
[Python] Create a linebot to write a name and age on an image
Scrap the published csv with Github Action and publish it on Github Pages
Try to build python and anaconda environment on Mac (by pyenv, conda)
Download all the images attached to the body of the pull request on Github
Try to write python code to generate go code --Try porting JSON-to-Go and so on
Try to separate the background and moving object of the video with OpenCV
An engineer who has noticed the emo of cryptography is trying to implement it in Python and defeat it
I'm an amateur on the 14th day of python, but I want to try machine learning with scikit-learn