Skip to content

Instantly share code, notes, and snippets.

View camilomartinez's full-sized avatar

Camilo Martinez camilomartinez

  • Amsterdam, Netherlands
View GitHub Profile
public static bool IsConnectedToInternet()
{
ConnectionProfile connectionProfile = NetworkInformation.GetInternetConnectionProfile();
return (connectionProfile!=null && connectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAcces);
}
@kastnerkyle
kastnerkyle / example_pairwise.py
Last active June 11, 2022 17:13
Example of pairwise processing with "smart broadcasting"
import numpy as np
def exponential_kernel(x1, x2):
# Broadcasting tricks to get every pairwise distance.
return np.exp(-((x1[np.newaxis, :, :] - x2[:, np.newaxis, :]) ** 2).sum(2)).T
a = np.random.randn(100, 5)
print(exponential_kernel(a, a).shape)