Skip to content

Instantly share code, notes, and snippets.

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

Laurent Pellegrino laurentpellegrino

Enjoying life every second of the day
View GitHub Profile
@laurentpellegrino
laurentpellegrino / noticeable.js
Last active December 29, 2025 10:18
Noticeable Widget rendering with custom settings based on conditions
const labelId = '83e6Z7u9rW83elan09Nx'
const widgetId = 'iTyk3i4j5sECMquDZLgP'
noticeable.on('widget:ready', widgetId, async function(event) {
const publications = event.detail.publications
if (publications.length > 0) {
if (publications[0].labels.includes(labelId)) {
const widgetOptions = {
backgroundColor: '#ff0000',
backgroundColorHover: 'darkred',
@laurentpellegrino
laurentpellegrino / create-publication.rb
Created December 24, 2025 11:12
Example to create a Noticeable Publication with segments using Ruby
#!/usr/bin/env ruby
require "json"
require "net/http"
require "uri"
endpoint = ENV.fetch("NOTICEABLE_GRAPHQL_ENDPOINT", "https://api.noticeable.io/graphql")
api_key = ENV.fetch("NOTICEABLE_API_KEY")
project_id = ENV.fetch("NOTICEABLE_PROJECT_ID")
@laurentpellegrino
laurentpellegrino / NoTypeAlias.java
Created January 31, 2025 17:41
Spring Data MongoDB without _class field on demand per class
package io.noticeable.data.autoconfigure;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface NoTypeAlias {
}
User-Agent Email Client
"AHC/2.1" Unknown
"Apache-HttpClient/4.5.1 (Java/1.8.0_172)" Unknown
"Apache-HttpClient/UNAVAILABLE (Java/17.0.11)" Unknown
"Apache-HttpClient/UNAVAILABLE (Java/1.8.0_362)" Unknown
"axios/0.19.2" Unknown
"curl/8.1.0" Unknown
"curl/8.4.0" Unknown
"Dalvik/2.1.0 (Linux; U; Android 10; NOH-NX9 Build/HUAWEINOH-N29)" Unknown
"Dalvik/2.1.0 (Linux; U; Android 12; 2107119DC Build/SKQ1.211006.001)" Unknown
@laurentpellegrino
laurentpellegrino / 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": [
{
@laurentpellegrino
laurentpellegrino / 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;
@laurentpellegrino
laurentpellegrino / 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();
@laurentpellegrino
laurentpellegrino / 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) {
@laurentpellegrino
laurentpellegrino / 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'),
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);