Skip to content

Instantly share code, notes, and snippets.

Albert Wang albertofwb

View GitHub Profile
@albertofwb
albertofwb / cpu_mon.sh
Last active Nov 13, 2018
send a notify message when process always use cpu too high
View cpu_mon.sh
#! /bin/bash
# File Name: cpu_mon
# Author: Albert
# mail: albertofwb@gmail.com
# Created Time: 2018 Nov 12 04:54:06 PM
#########################################################################
APP_NAME="cpu monitor"
CPU_WARN_PERCENT=95
View mainGUI.java
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class mainGUI {
private static final class Holder {
static final mainGUI instance_ = new mainGUI();
}
private static mainGUI instance() {
View SimpleHTTPServerWithUpload.py
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@albertofwb
albertofwb / crack.py
Created Oct 1, 2018
python hack attack visual affects
View crack.py
#! /usr/bin/env python
# encoding: utf-8
# Edit time: 2018-06-05 20:32
# This scripts print some hack attack affect
# Just makes ordinary people think about we are hacking an account
import sys
from time import sleep
import random
import string
@albertofwb
albertofwb / drawStep.java
Created Aug 3, 2018
java swt circle label step
View drawStep.java
private void drawStep(Composite composite, final int curPosition) {
Preconditions.checkState(curPosition >= 0, "step can't less than 0");
final int stepX = 336;
final int stepY = 30;
final int connectorHeight = 4;
final int connectorWidth = 84;
final int totalStep = 3;
final int diameter = 24;
final int stepRadius = diameter / 2;
@albertofwb
albertofwb / AnimatedGif.java
Created Jul 10, 2018
swt custom widget support gif animation
View AnimatedGif.java
// 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;
@albertofwb
albertofwb / Program.cs
Last active Jul 6, 2018
test call File.Replace() multiple times check if that will cause file locke by kernel
View Program.cs
using System;
using System.IO;
using System.Text;
namespace TestDemo
{
public class Atomic
{
private readonly object _lock = new object();
@albertofwb
albertofwb / bing_wallpapper.py
Last active Apr 26, 2018
every time you execute this script will set your wallpaper to a random picture from bingwallpaper.com
View bing_wallpapper.py
#! /usr/bin/env python3d
import requests
from bs4 import BeautifulSoup
import os
import sys
import datetime
import random
import hashlib
@albertofwb
albertofwb / WarmMyMac.py
Created Feb 3, 2018
早上给 MAC 插上电源就出去了,回来发现电量还是28%.电池图标显示“电池没有在充电”.网上搜索一番,网友们说是温度太低就不能充电.于是我用python 写了两行代码,十几秒之后就正常充电了
View WarmMyMac.py
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 / shadowsocks-server.service
Created Jan 7, 2018 — forked from guyskk/shadowsocks-server.service
shadowsocks server systemd service
View shadowsocks-server.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
You can’t perform that action at this time.