Skip to content

Instantly share code, notes, and snippets.

@ibrezm1
ibrezm1 / ldap-adauth.js
Created October 9, 2021 15:20
Active directory authentication using activedirectory module in Nodejs
var ActiveDirectory = require('activedirectory');
var config = { url: 'ldap://ldap.forumsys.com',
bindDN: 'cn=read-only-admin,dc=example,dc=com',
baseDN:'ou=mathematicians,dc=example,dc=com',
password: 'password' }
var ad = new ActiveDirectory(config);
var username = 'uid=gauss,dc=example,dc=com';
var password = 'password';
letter loc1 loc2 loc3 loc4 loc5
a 0.0736901620806634 0.18036185450433473 0.09303932654856138 0.09957281065460485 0.08053775599949742
b 0.07167985927880387 0.006784771956275914 0.0280185953009172 0.018658122879758765 0.0060937303681367
c 0.07513506721949993 0.01595677848976002 0.03335846211835658 0.034049503706495794 0.01388365372534238
d 0.05032039200904636 0.008543786907903002 0.0322904887548687 0.03417514763161201 0.051262721447418017
e 0.026448046236964444 0.12375926623947732 0.0645181555471793 0.15762030405829877 0.11766553587134063
f 0.04297022238974746 0.0025128785023244126 0.012438748586505842 0.013506721949993718 0.006345018218369142
g 0.0462997864053273 0.006407840180927252 0.028960924739288855 0.02996607614021862 0.0121874607362734
h 0.03587134062068099 0.04523181304183943 0.013066968212086945 0.018092725216735772 0.031222515391380826
y 0.010491267747204422 0.01752732755371278 0.014386229425807261 0.010114335971855761 0.10585500691041588
@ibrezm1
ibrezm1 / rotatekeys.sh
Last active February 10, 2022 04:35
Rotate GCP google cloud serviceaccount keys
# From https://cloud.google.com/iam/docs/creating-managing-service-account-keys#iam-service-account-keys-create-gcloud
# Enable IAM API https://cloud.google.com/iam/docs/creating-managing-service-account-keys#iam-service-account-keys-create-gcloud
# following script will rotate all json keys present in the current folder
# Need the permission to roate keys to the current service accout key admin
mkdir -p backup
echo Starting key rotation
for filename in *.json; do
echo Starting $filename
cp $filename backup/$filename
@ibrezm1
ibrezm1 / Rotatekeys.ps1
Last active February 13, 2022 02:50
Rotatekeys for GCP google cloud powershell
# Enable IAM API https://cloud.google.com/iam/docs/creating-managing-service-account-keys#iam-service-account-keys-create-gcloud
# following script will rotate all json keys present in the current folder
# Need the permission to roate keys to the current service accout key admin
# Set-ExecutionPolicy -ExecutionPolicy Unrestricted
# Add CLOUDSDK_PYTHON variable e.g. D:\Programfiles\gcloud\google-cloud-sdk\platform\bundledpython\python.exe
# Import-Module GoogleCloud
# gcloud iam service-accounts keys create newfile.json --iam-account [email protected]
https://travelandtech.net/technology/tutorials/gcp/how-to-install-apache-airflow-on-gcp-ubuntu-instance-with-sequential-executor/
sudo su -
apt update
apt upgrade
adduser airflow
usermod -aG sudo airflow
su - airflow
# Sample Cloud execution on local
# pip install google-auth
# pip install --upgrade google-auth
import os
import json
import requests
import google.oauth2.id_token
import google.auth.transport.requests
# https://beam.apache.org/documentation/transforms/python/aggregation/combinevalues/
# http://shzhangji.com/blog/2017/09/12/apache-beam-quick-start-with-python/
import apache_beam as beam
import csv
if __name__ == '__main__':
with beam.Pipeline('DirectRunner') as pipeline:
(pipeline
| "Read File" >> beam.io.ReadFromText('test.txt')
| 'Split' >> (
@ibrezm1
ibrezm1 / basicBeam.py
Created April 22, 2022 23:31
Basic beam read file and operations
# https://beam.apache.org/documentation/transforms/python/aggregation/combinevalues/
#
import apache_beam as beam
import csv
if __name__ == '__main__':
with beam.Pipeline('DirectRunner') as pipeline:
(pipeline
| "Read File" >> beam.io.ReadFromText('test.txt')
| 'Split' >> (
@ibrezm1
ibrezm1 / Print Trace.py
Created April 24, 2022 03:14
Check trace for a function execution wrapper decorator
# Decorators
import sys, traceback
import time
# Create a function with function argument
def timerit(func):
#Create a wrapper to that function with args
def wrapper(*arg):
# function preporcessing
t=time.time()
@ibrezm1
ibrezm1 / AllYamlAttributes.yaml
Last active April 24, 2022 18:24
All types of YAML instances
--- # Start of yaml with ---
# https://yaml-online-parser.appspot.com/
# https://www.json2yaml.com/
# https://github.com/josephmachado/beginner_de_project/blob/master/docker-compose.yaml ( Sample usage of anchors )
# Sample YAml
- name: Test
str1: 'HEllo'
str2: 'HEllo2'
- numbers:
num: 1 # Dec