Skip to content

Instantly share code, notes, and snippets.

function isPrivateIPv4(ip) {
// Regular expression for IPv4 validation
const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
// Check if IP matches IPv4 format
if (!ipv4Regex.test(ip)) {
return `${ip} : is not a valid IPv4 address`;
}
const ipParts = ip.split('.').map(part => parseInt(part));
@amithn
amithn / metadata.json
Created September 8, 2021 22:41
New Project
{"valueParameterDescriptions":[],"slotParameterDescriptions":[],"roleDescriptions":[],"contractType":"O","contractName":"","contractDescription":"","choiceDescriptions":[]}
apiVersion: crds.voicestreams.com/v1
kind: Text
metadata:
name: text-1
spec:
to: "Amith Nambiar"
phoneNumber: "+614XXXXXXX"
message: "Welcome to the world of Custom Resource Definition in Kubernetes"
apiVersion: crds.voicestreams.com/v1
kind: Call
metadata:
name: call-1
spec:
callee: "Amith Nambiar"
phoneNumber: "+6142XXXXXXX"
# Message to be played to the callee
message: "Welcome to the world of Custom Resource Definitions in Kubernetes"
@amithn
amithn / azure-outbound-ip-test.tf
Last active May 10, 2020 11:54
Azure Load Balancing Scenarios
# Configure the Microsoft Azure Provider
provider "azurerm" {
# The "feature" block is required for AzureRM provider 2.x.
# If you're using version 1.x, the "features" block is not allowed.
version = "=2.0.0"
features {}
subscription_id = var.subscription_id
tenant_id = var.tenant_id
client_id = var.client_id
@amithn
amithn / CharacterCount.scala
Last active August 29, 2015 14:25
Counting A-Z characters using Apache Spark
package com.voicestreams.app
import org.apache.spark.{SparkConf, SparkContext}
object CharacterCount extends App {
val sparkConf = new SparkConf().setAppName("Character Count Job")
.setMaster("local[4]")
val sc = new SparkContext(sparkConf)
@amithn
amithn / SparkJoin
Last active May 29, 2018 13:55
Example showing how to join 2 RDD's using Apache Spark's Java API
package com.voicestreams.spark;
import org.apache.commons.io.FileUtils;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.Function2;
import org.apache.spark.api.java.function.PairFunction;
@amithn
amithn / CharacterCountSparkJob.java
Last active August 29, 2015 14:19
Character Counter Job in Apache Spark using the Java API to manipulate RDD's.
package spark.poc;
import org.apache.commons.io.FileUtils;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.FlatMapFunction;
import org.apache.spark.api.java.function.Function2;
import org.apache.spark.api.java.function.PairFunction;