Skip to content

Instantly share code, notes, and snippets.

@ibrezm1
ibrezm1 / Windows installation.ps1
Last active November 25, 2022 09:49
Windows installation
sudo grub-reboot 2 && sudo reboot
sudo grub-set-default <num>
27 systemd-analyze
28 systemd-analyze blame
# Enable RDB from system properties
# Enable Lan from Turn off on windows features
@ibrezm1
ibrezm1 / flask-apshedular.py
Last active November 6, 2022 04:45
Flask demo for ap shedular cron type , Delete the sqlite file first
""" Demonstrating APScheduler feature for small Flask App. """
from apscheduler.schedulers.background import BackgroundScheduler
from flask import Flask
from datetime import datetime
from pytz import timezone
tz = timezone('US/Eastern')
print(datetime.now(tz) )
# https://gist.github.com/ivanleoncz/21293b00d0ea54db8ee3b57fb1170ddf
# 341 vi ~/.profile
# 342 ssh-copy-id [email protected]
# 344 source ~/.profile
# 343 pls
# Usage
# Backup current folder ( will exclude . files )
# pbkp
# List remote
# $ pls
@ibrezm1
ibrezm1 / main.tf
Created September 29, 2022 05:23
Teraform setup and learn
# install terraform steps and interactive web browser
# https://learn.hashicorp.com/tutorials/terraform/install-cli
provider "google" {
#version = "3.5.0"
# credentials = file("/downloads/compute-instance.json")
# OR
# use gcloud auth application-default login/revoke
project = "zeta-yen-319702"
region = "us-central1"
@ibrezm1
ibrezm1 / movepythonpackages.sh
Last active September 28, 2022 02:44
Pip file movement to prod servers
# Reference
# https://stackoverflow.com/questions/7300321/how-to-use-pythons-pip-to-download-and-keep-the-zipped-files-for-a-package
mkdir /temp/pypack
pip freeze > requirements.txt
pip download -d /tmp -r requirements.txt
# zip and move te requirements file also so that it can e used on target
@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"