Skip to content

Instantly share code, notes, and snippets.

View bitmingw's full-sized avatar

Ming Wen bitmingw

View GitHub Profile
@bitmingw
bitmingw / compound_interest.py
Last active December 31, 2020 23:58
Calculate compound interest
#!/usr/bin/env python3
"""
Author: Ming Wen ([email protected])
This python script calculates compound interest:
1. Given (initial assets value, investment per year, growth rate, number of years),
find out final assets value.
#!/usr/bin/env python3
import collections
import json
def parse(filename):
res = []
with open(filename, "r") as fd:
lines = fd.readlines()
for line in lines:
@bitmingw
bitmingw / increase_cpu.py
Last active June 11, 2020 02:36
Scripts to increase system CPU, memory and fill up the disk in linux. Tested on ubuntu system.
#!/usr/bin/env python3
from argparse import ArgumentParser
from datetime import datetime, timedelta
from multiprocessing import Process
import random
def work(t):
current_time = datetime.now()
delta = timedelta(seconds=t)
@bitmingw
bitmingw / git_batch_resolver.py
Last active September 18, 2023 08:20
Batch script to resolve large git conflicts.
#!/usr/bin/env python3
"""
Author: Ming Wen ([email protected])
When resolving conflicts on a merge or rebase, this script
automates `git add/rm` and `git checkout` with --ours or --theirs
for a large batch of changes.
Usage: `python3 git_batch_resolver.py` in your git repository.
@bitmingw
bitmingw / github_sync.py
Last active April 11, 2024 07:33
Auto update local repository with remote github repository.
#!/usr/bin/env python3
"""
Author: Ming Wen ([email protected])
This script is used to track the changes in the github, and if a new commit
is found, update the local repository accordingly.
"""
from urllib.request import urlopen
#!/usr/bin/env python3
"""
Web crawler and analysis of matrix67's ideagen
Author: Ming Wen
"""
from bs4 import BeautifulSoup
from urllib.request import urlopen