Skip to content

Instantly share code, notes, and snippets.

View ibrezm1's full-sized avatar

MOHD SHARIQUE IBREZ AHEMED ibrezm1

View GitHub Profile
@ibrezm1
ibrezm1 / botdets.txt
Created August 10, 2022 05:08
Microsoft Bot
https://dev.botframework.com/bots
https://docs.microsoft.com/en-us/azure/bot-service/bot-service-quickstart-create-bot?view=azure-bot-service-4.0&tabs=csharp%2Cvs
https://www.youtube.com/watch?v=-FHc_lZ6jJY
https://youtu.be/RjGVOFm39j0?t=651
@ibrezm1
ibrezm1 / settings.json
Created July 23, 2022 18:17
settings.json for VScode
{
"terminal.integrated.profiles.windows": {
"PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" },
"GitBash": {
"path": "${env:windir}\\System32\\cmd.exe",
"args": ["/k","C:\\Tools\\cmder\\vendor\\git-for-windows\\bin\\bash.exe"]
},
"Cmder": {
"path": "${env:windir}\\System32\\cmd.exe",
"args": ["/k", "C:\\Tools\\cmder\\vendor\\bin\\vscode_init.cmd"]
#!/usr/bin/env python3
#$ python3 ip-to-hostname.py 216.58.196.4
#Address: 216.58.196.4
#Host: ('kul08s09-in-f4.1e100.net', [], ['216.58.196.4'])
import socket
import sys
address = sys.argv[1]
host = socket.gethostbyaddr(address)
@ibrezm1
ibrezm1 / subnet.py
Last active June 22, 2022 05:05 — forked from nboubakr/subnet.py
A simple python script converts a Classless Inter-Domain Routing (CIDR)-formatted IP address into an IP range and netmask.
#!/usr/bin/env python
# python subnet.py 200.100.33.65/26
# from: curl -O https://gist.github.com/ibrezm1/4b4274006dc2a5d5ad48e6b2c395633b/subnet.py
import sys
# Get address string and CIDR string from command line
(addrString, cidrString) = sys.argv[1].split('/')
# Split address into octets and turn CIDR into int
@ibrezm1
ibrezm1 / gcp-iam-restrict-user-bucket.sh
Created June 21, 2022 15:30 — forked from pydevops/gcp-iam-restrict-user-bucket.sh
Google Cloud Platform example to add IAM role restricting user to specific storage buckets with conditions
#!/usr/bin/env bash
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
export PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format="value(projectNumber)")
export IDNS=${PROJECT_ID}.svc.id.goog # workload identity domain
export GCP_REGION="us-central1"
export GCP_ZONE="us-central1-a"
@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
@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 / 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' >> (
# 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' >> (
# 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