Skip to content

Instantly share code, notes, and snippets.

View FangYang970206's full-sized avatar
🐷
Focusing

StarPlatinum(JoJo) FangYang970206

🐷
Focusing
View GitHub Profile
@FangYang970206
FangYang970206 / FutureTest.java
Created May 27, 2021 16:57
Java测试future.get()是否抛出异常
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
public class FutureTest {
static class MyTask implements Callable<Integer> {
@Override
public Integer call() throws Exception {
Thread.sleep(1000);
throw new IllegalArgumentException("exception");
}
@FangYang970206
FangYang970206 / TrackingMemory.cpp
Created March 11, 2020 14:11
跟踪内存分配以及释放的方法,有助于检查是否有内存泄漏
#include <iostream>
#include <memory>
using namespace std;
struct AllocationMetrics{
uint32_t totalMemory = 0;
uint32_t totalFree = 0;
uint32_t getCurrentUsage() {return totalMemory - totalFree;}
};
@FangYang970206
FangYang970206 / BaiduTranslate.py
Last active December 28, 2019 09:32
百度翻译API的简单桌面GUI程序(modified from https://github.com/zachitect/B_Translate
import tkinter
from tkinter import ttk
from tkinter import filedialog
from tkinter import messagebox
import http.client
import hashlib
import urllib.parse
import random
import json