Skip to content

Instantly share code, notes, and snippets.

Avatar

Shilo Shilo

View GitHub Profile
@Shilo
Shilo / HttpClientManager.java
Created Jun 25, 2022
Android Java helper class for handling HTTP GET requests. (Requires Java 11+)
View HttpClientManager.java
package com.shilocity.http;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
View Search my gists.md

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@Shilo
Shilo / Gists.md
Created Jun 25, 2022 — forked from BoQsc/Gists.md
How to search my own Gists
View Gists.md
@Shilo
Shilo / App.java
Last active Jun 25, 2022
Java helper class for handling HTTP GET requests. (Requires Java 11+)
View App.java
public class App {
public static void main(String[] args) throws Exception {
String ip = "www.google.com";
int port = 80;
boolean isSecure = true;
String url = HttpClientManager.addressToUrl(ip, port, isSecure);
exampleSendSync(url, isSecure);
exampleSendAsync(url, isSecure);
@Shilo
Shilo / Benchmark.java
Last active Jun 24, 2022
Dirty benchmarking for legacy and new networking GET requests. (Java)
View Benchmark.java
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
@Shilo
Shilo / Utils.java
Last active Jun 21, 2022
Java mimic Javascript timeout.
View Utils.java
package de.xida;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public class Utils {
public static ScheduledFuture<?> setTimeout(long delayMilliseconds, Runnable runnable) {
var executor = Executors.newSingleThreadScheduledExecutor();
return executor.schedule(runnable, delayMilliseconds, TimeUnit.MILLISECONDS);
}
@Shilo
Shilo / String+Addition.swift
Created Jun 8, 2022
String additions to simplify handling.
View String+Addition.swift
//
// String+Additions.swift
//
//
// Created by Shilo White on 6/6/22.
//
import Foundation
extension String {
@Shilo
Shilo / Clamp.swift
Created Jun 8, 2022 — forked from leemorgan/Clamp.swift
clamp() in Swift
View Clamp.swift
///Returns the input value clamped to the lower and upper limits.
func clamp<T: Comparable>(value: T, lower: T, upper: T) -> T {
return min(max(value, lower), upper)
}
//-----------------------------------------------
// Example usage
let proposedIndex = 6
@Shilo
Shilo / Bundle+Additions.swift
Created Jun 6, 2022
Swift extension for getting app info.
View Bundle+Additions.swift
//
// Bundle+Addition.swift
//
//
// Created by Shilo White on 6/3/22.
//
import Foundation
extension Bundle {
@Shilo
Shilo / Task+Addition.swift
Created Jun 6, 2022
Swift extension for Task sleeping in milliseconds.
View Task+Addition.swift
//
// Task+Addition.swift
//
//
// Created by Shilo White on 6/5/22.
//
import Foundation
public extension Task where Success == Never, Failure == Never {