Skip to content

Instantly share code, notes, and snippets.

View Camerash's full-sized avatar
🪲
🌍🧑‍🚀 Wait, it's all... bugs? 🔫👩‍🚀 Always has been

Esmond Wong Camerash

🪲
🌍🧑‍🚀 Wait, it's all... bugs? 🔫👩‍🚀 Always has been
View GitHub Profile
@Camerash
Camerash / OkHttpUtils.java
Created April 20, 2021 08:26
Enable TCP Keepalive per application in Android using OkHttp
import okhttp3.OkHttpClient;
public class OkHttpUtil {
public static OkHttpClient getOkHttpClient() {
return new OkHttpClient.Builder()
.socketFactory(new TCPKeepaliveSocketFactory(60, 60, 5))
.build();
}
public static OkHttpClient getSSLOkHttpClient() {
@Camerash
Camerash / SmartArray.tpp
Created May 8, 2018 17:03
SmartArray add function
template <typename KeyType, typename ValueType>
bool SmartArray<KeyType, ValueType>::add(KeyType key, ValueType value) {
if(has(key)) return false;
// Init a bigger pointer array
Pair<KeyType, ValueType>** newData = new Pair<KeyType, ValueType>*[size+1];
if(size == 0) {
newData[0] = new Pair<KeyType, ValueType>(key, value);
} else {