Skip to content

Instantly share code, notes, and snippets.

Hello

@asdaraujo
asdaraujo / ResolverHelper.java
Created December 18, 2020 13:30
Java reverse DNS name resolution
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
public class ResolverHelper {
public static void main(String[] args) throws UnknownHostException {
InetAddress ia = InetAddress.getByName(args[0]);
InetSocketAddress isa = new InetSocketAddress(args[0], 12345);
System.out.println(ia.getCanonicalHostName());
System.out.println(isa.getAddress().getCanonicalHostName());
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><template encoding-version="1.3">
<description/>
<groupId>7ba01444-0178-1000-0000-000065162889</groupId>
<name>collect-cloud-data-gcp</name>
<snippet>
<controllerServices>
<id>83014ebc-1df0-37b8-0000-000000000000</id>
<parentGroupId>c51c7c51-9f9b-3235-0000-000000000000</parentGroupId>
<bundle>
<artifact>nifi-gcp-nar</artifact>
This file has been truncated, but you can view the full file.
import avro.schema
import io
import os
import requests
from avro.io import DatumReader, BinaryDecoder
from cachetools import TTLCache
from kafka import KafkaConsumer
# Kafka broker
BROKERS = ['cdp.52.33.201.179.nip.io:9092']
@asdaraujo
asdaraujo / kafka-python-sasl-gssapi.py
Last active June 5, 2024 07:32
kafka-python example with Kerberos auth
# Requirements: kafka-python gssapi krbticket
import os
import time
from kafka import KafkaConsumer, KafkaProducer
from krbticket import KrbConfig, KrbCommand
try:
os.environ['KRB5CCNAME'] = '/tmp/krb5cc_<myusername>'
kconfig = KrbConfig(principal='araujo', keytab='/path/to/<myusername>.keytab')
KrbCommand.kinit(kconfig)
@asdaraujo
asdaraujo / sqlio_log_parser.py
Last active November 10, 2021 06:03
sqlio_log_parser.py
import os
import re
import sys
import subprocess
import time
from subprocess import Popen, PIPE
def ps(pid):
p = Popen('ps -ef | grep {}'.format(pid), shell=True, stdout=PIPE, stderr=PIPE)
stdout, _ = p.communicate()
{
"type": "record",
"name": "FinTransactions",
"fields": [
{ "name": "ts", "type": "string" },
{ "name": "account_id", "type": "string" },
{ "name": "transaction_id", "type": "string" },
{ "name": "amount", "type": "int" },
{ "name": "lat", "type": "double" },
{ "name": "lon", "type": "double" },
#!/bin/bash
set -u
set -e
# The following should be set if not already exported at the shell level
#export CDP_PROFILE=<cdp_profile_name>
#export AWS_PROFILE=<aws_profile_name>
ENV_NAME=$1
#!/bin/bash
set -u
set -e
export CDP_PROFILE=<CDP_PROFILE>
CLUSTER_NAME=<DATAHUB_NAME>
WORKLOAD_USR=<WORKLOAD_USER_NAME>
WORKLOAD_PWD=<WORKLOAD_PASSWORD>