Skip to content

Instantly share code, notes, and snippets.

@AoJ
AoJ / auth.py
Created December 11, 2019 13:18 — forked from ibeex/auth.py
Python LDAP (ActiveDirectory) authentication
import ldap
def check_credentials(username, password):
"""Verifies credentials for username and password.
Returns None on success or a string describing the error on failure
# Adapt to your needs
"""
LDAP_SERVER = 'ldap://xxx'
# fully qualified AD user name
LDAP_USERNAME = '%[email protected]' % username
@AoJ
AoJ / vmware-template.centos7.sh
Created October 10, 2019 09:50 — forked from efeldhusen/vmware-template.centos7.sh
Bash script for Centos 7.x VMware Template Images
#!/bin/bash
#Paths are for Centos 7.x
#stop logging services
/sbin/service rsyslog stop
/sbin/service auditd stop
#remove old kernels
/usr/bin/package-cleanup --oldkernels --count=1
@AoJ
AoJ / _summary.md
Created February 16, 2018 11:53 — forked from squito/_summary.md
spark sql timestamp semantics, and how they changed from 2.0.0 to 2.0.1 (see query_output_2_0_0.txt vs query_output_2_0_1.txt) changed by SPARK-16216

Spark "Timestamp" Behavior

Reading data in different timezones

Note that the ansi sql standard defines "timestamp" as equivalent to "timestamp without time zone". However Spark's behavior depends on both the version of spark and the file format

format \ spark version <= 2.0.0 >= 2.0.1
val grpcJavaVersion = "1.3.0"
val downloadJGrpc = {
val grpcArtifactId = "protoc-gen-grpc-java"
val jgrpcExeFileName = {
val os = if (scala.util.Properties.isMac) "osx-x86_64"
else if (scala.util.Properties.isWin) "windows-x86_64"
else "linux-x86_64"
# env
export KAFKA_HOST="my.kafka.hostname"
export KAFKA_OPTS="-Djava.security.auth.login.config=/etc/kafka/kafka_server_jaas.conf"
# create topics
kafka-topics --create --topic securing-kafka --replication-factor 1 --partitions 3 --zookeeper $KAFKA_HOST:2181
# producer acl
kafka-acls --authorizer-properties zookeeper.connect=$KAFKA_HOST:2181 --add --allow-principal User:kafkaclient --producer --topic securing-kafka
@AoJ
AoJ / flock_osx.c
Created June 2, 2017 06:23 — forked from ahti/flock_osx.c
Linux flock(2) 2.22.1 with some minor changes for compiling on OSX. I have not run any test but basic functionality works.
/* Copyright 2003-2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
@AoJ
AoJ / count.sh
Last active May 17, 2017 22:53 — forked from mehikmat/count.sh
Hadoop commnad to run bash script in hadoop cluster-This script counts the number of lines in input file and writes count to output file
#!/bin/sh
# 's_\^\*~_\n_g' is the line delimiter in input file replace with yours
sed 's_\^\*~_\n_g'| wc -l
@AoJ
AoJ / golang-tls.md
Created April 21, 2017 12:35 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
#!/usr/bin/env python
# Script to run dynamic dns for docker containers.
# DNS is served by dnsmasq running on the docker0 gateway ip, and dynamically
# updated at containers come and go.
#
# To use from docker, just provide the --dns option:
# docker run --dns <gateway> ...
# The gateway ip you need will be printed when this script is run.
@AoJ
AoJ / reconnect.js
Created October 26, 2015 12:48 — forked from carlhoerberg/reconnect.js
How to build reconnect logic for amqplib
var amqp = require('amqplib/callback_api');
// if the connection is closed or fails to be established at all, we will reconnect
var amqpConn = null;
function start() {
amqp.connect(process.env.CLOUDAMQP_URL + "?heartbeat=60", function(err, conn) {
if (err) {
console.error("[AMQP]", err.message);
return setTimeout(start, 1000);
}