Skip to content

Instantly share code, notes, and snippets.

Avatar

Ming Wen bitmingw

View GitHub Profile
@bitmingw
bitmingw / compound_interest.py
Last active Dec 31, 2020
Calculate compound interest
View compound_interest.py
#!/usr/bin/env python3
"""
Author: Ming Wen (bitmingw@gmail.com)
This python script calculates compound interest:
1. Given (initial assets value, investment per year, growth rate, number of years),
find out final assets value.
View druid_metrics_parser.py
#!/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 Jun 11, 2020
Scripts to increase system CPU, memory and fill up the disk in linux. Tested on ubuntu system.
View increase_cpu.py
#!/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 Jan 6, 2022
Batch script to resolve large git conflicts.
View git_batch_resolver.py
#!/usr/bin/env python3
"""
Author: Ming Wen (bitmingw@gmail.com)
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 Jun 13, 2022
Auto update local repository with remote github repository.
View github_sync.py
#!/usr/bin/env python3
"""
Author: Ming Wen (bitmingw@gmail.com)
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
View ideagen.py
#!/usr/bin/env python3
"""
Web crawler and analysis of matrix67's ideagen
Author: Ming Wen
"""
from bs4 import BeautifulSoup
from urllib.request import urlopen