Skip to content

Instantly share code, notes, and snippets.

View albertofwb's full-sized avatar

Albert Wang albertofwb

View GitHub Profile
@albertofwb
albertofwb / make_commits.py
Last active April 18, 2018 05:49
使用脚本模拟多次提交记录,主要是为了练习 git 二分法定位bug (git bisect) ,参见博客:http://www.oschina.net/translate/letting-git-bisect-help-you
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time : 2017/4/30 12:00
# Author : Albert
# Email : albertofwb@gmail.com
# Site : http://cnblogs.com/albertofwb
# File : make_commits.py
# Editor : PyCharm
@albertofwb
albertofwb / VerifyRepeatedMd5.py
Last active June 14, 2017 13:37
为什么应该放弃或减少使用MD5
# MD5 在现实中已经被发现有相当多的数据都可能导致冲突。举例而言,如下两段数据的MD5哈希值就是完全一样的
# ref: blog.jianguoyun.com/?p=481
# date: 2012-09-20
import os
from hashlib import md5
def save_strs2bin(text, file_name):
if not isinstance(text, str):
@albertofwb
albertofwb / restart.bat
Created August 9, 2017 07:30
put this script in "C:\windows\system32" then you can simply type "restart AppName" to restart windows softwares
@echo off
set App=%1
set SleepSeconds=2
set PingIP=127.0.0.1
if "%App%" == "" (
goto usage
)
@albertofwb
albertofwb / pkill.bat
Created August 11, 2017 00:39
模仿linux下的pkill 命令实现。 将该脚本放入 PATH 中。关闭任何程序只需要 pkill ProcessName. 比如关闭 Chrome.exe 只需要 pkill chrome
@echo off
set App=%1
if "%App%" == "" (
goto usage
)
if "%App:~-3%" neq "exe" (
set App=%App%.exe

Git 常用命令总结

在使用git进行团队开发工作中,有些常用命令频繁使用,也有关于git的一些使用技巧。
在这里做一个记录分享给大家。如果有人能从这个文档里得到帮助,我会感到很开心o(* ̄▽ ̄*)ブ。
下面的总结都是本人在实际使用过程中的心得,如果有什么纰漏,请协助我完善这个文档

版本控制

给指定提交打上标签
@albertofwb
albertofwb / shadowsocks-server.service
Created January 7, 2018 05:39 — forked from guyskk/shadowsocks-server.service
shadowsocks server systemd service
[Unit]
Description=Shadowsocks Server
After=network.target
[Service]
ExecStart=/usr/local/bin/ssserver -c /etc/shadowsocks/ss-config.json
Restart=on-abort
[Install]
WantedBy=multi-user.target
@albertofwb
albertofwb / WarmMyMac.py
Created February 3, 2018 04:44
早上给 MAC 插上电源就出去了,回来发现电量还是28%.电池图标显示“电池没有在充电”.网上搜索一番,网友们说是温度太低就不能充电.于是我用python 写了两行代码,十几秒之后就正常充电了
import multiprocessing
def worker():
while True:
pass
if __name__ == '__main__':
jobs = []
cpu_count = multiprocessing.cpu_count()
print("About to start %d process to warm your mac" % cpu_count)
@albertofwb
albertofwb / bing_wallpapper.py
Last active April 26, 2018 06:09
every time you execute this script will set your wallpaper to a random picture from bingwallpaper.com
#! /usr/bin/env python3d
import requests
from bs4 import BeautifulSoup
import os
import sys
import datetime
import random
import hashlib
@albertofwb
albertofwb / Program.cs
Last active July 6, 2018 02:11
test call File.Replace() multiple times check if that will cause file locke by kernel
using System;
using System.IO;
using System.Text;
namespace TestDemo
{
public class Atomic
{
private readonly object _lock = new object();
@albertofwb
albertofwb / AnimatedGif.java
Created July 10, 2018 02:13
swt custom widget support gif animation
// copy from: https://stackoverflow.com/questions/13479833/java-swt-animated-gif
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.widgets.Canvas;