Skip to content

Instantly share code, notes, and snippets.

View lpellegr's full-sized avatar
Enjoying life every second of the day

Laurent Pellegrino lpellegr

Enjoying life every second of the day
View GitHub Profile
@lpellegr
lpellegr / TimeZoneList.java
Last active November 2, 2019 12:19
TimeZone List Generator from Java
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
public class TimeZoneList {
public static void main(String[] args) {
String[] zoneIds = TimeZone.getAvailableIDs();
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class LanguageTags {
public static void main(String[] args) {
Locale[] locales = Locale.getAvailableLocales();
List<LocaleEntry> entries = new ArrayList<>(locales.length);
@lpellegr
lpellegr / ipregistry-php-batch.php
Last active January 13, 2020 10:10
Retrieve IP Info in PHP for a list of IP addresses using ipregistry.co
<?php
$curl = curl_init();
$payload = json_encode(array("66.165.2.7", "1.1.1.1", "8.8.4.4"));
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.ipregistry.co/?key=tryout",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array('Content-Type:application/json'),
@lpellegr
lpellegr / DnsJavaTryOut.java
Created January 14, 2020 19:12
DnsJava Issue #8
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;
public class DnsJavaTryOut {
public static void main(String[] args) throws TextParseException {
Record[] records = new Lookup("4.4.8.8.in-addr.arpa", Type.PTR).run();
for (Record record : records) {
@lpellegr
lpellegr / IpregistryTest.java
Last active May 28, 2020 15:32
Consecutive private local IP lookup using Ipregistry API and apache HTTP client
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class IpregistryTest {
public static void main(String[] args) throws IOException, InterruptedException {
HttpClient client = HttpClient.newHttpClient();
@lpellegr
lpellegr / ScalewayStorageService.java
Last active June 25, 2021 00:38
Scaleway Object Storage in Java using Amazon S3 SDK
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import java.io.InputStream;
import java.net.URI;
import java.util.function.Consumer;
@lpellegr
lpellegr / microsoft-azure-datacenters.json
Last active May 30, 2024 07:30
Microsoft Azure Datacenters (including coordinates)
[
{
"displayName": "East US",
"id": "/subscriptions/41160c59-742a-4bb6-9a57-32c3cf05a343/locations/eastus",
"metadata": {
"geographyGroup": "US",
"latitude": "37.3719",
"longitude": "-79.8164",
"pairedRegion": [
{