Skip to content

Instantly share code, notes, and snippets.

View EscVector's full-sized avatar

EscVector EscVector

View GitHub Profile
@EscVector
EscVector / gist:da320bb712844136a76e89167185f92b
Last active August 23, 2023 17:49
Curl Fun with Google Drive - File Uploads
# Script to upload file to Google Drive using Device Authorization
# https://developers.google.com/identity/protocols/oauth2/limited-input-device
# Authorization is granted by entering the User_Code and accepting via https://google.com/device
# this is a manual step that must be completed
# Prerequisite - Google Project Device Credentials Client_id and Client_Secret and google.drive API Enabled
#!/bin/bash
# https://developers.google.com/identity/protocols/oauth2/limited-input-device
@EscVector
EscVector / animated-continuous-sections-with-gsap-observer.markdown
Created August 1, 2023 13:19
Animated Continuous Sections with GSAP Observer
@EscVector
EscVector / gist:eeea7b35007be86c7d698af0ab5703bd
Last active June 27, 2023 18:04
OCI List Specific Images for All Regions
# Region ID is embeded in Image ID format: ocid1.image.oc1.REGION.ImageID
set CID=compartmentid
for /F %i IN (AvailableRegions.txt) DO (oci compute image list --compartment-id=%CID% --all --display-name Canonical-Ubuntu-20.04-2023.04.18-0 --region %i --query "data[].[\"id\"]")
# Save File with regions
af-johannesburg-1
ap-chuncheon-1
ap-hyderabad-1
import requests
import wget
import os
BaseFolder ='https://s3-us-gov-west-1.amazonaws.com/cg-d4b776d0-d898-4153-90c8-8336f86bdfec/masters/'
datalist = ['arson','asr','cargo-theft','hate-crime','human-trafficking','pe','nibrs','reta','shr','supp']
try:
if not os.path.exists('./data/'):
os.mkdir('./data/')
# AMI ID ami-0affd4508a5d2481b
sudo yum install vsftpd
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
#Local Command Line
oci ns get --auth instance_principal
export OCI_CLI_AUTH=instance_principal
# Downloading with oci os object command is much faster than using Signed URL when Service Gateway is configured.
# bulk load files
oci os object bulk-upload --bucket-name dmpfiles --src-dir dumpfiles/
# bulk download with filter
oci os object bulk-download --bucket-name dmpfiles --include warehouse_01* --download-dir .
from pathlib import Path
# Example load_files('c:/data/sqlfiles','sql')
def load_files(source_path,file_suffix):
filelist=[]
basepath = Path(source_path)
files = basepath.iterdir()
for file in files:
if file.suffix == "."+file_suffix:
fileinfo = str(file.name) + "," + str(file) + "," + str(file.stat().st_size) + str(file.stat().st_mtime)
#
#
# Todo: Jinja2 template
#
#
import oci
# from jinja2 import Template
import re
from datetime import datetime
@EscVector
EscVector / OCI-Features-By-Region.py
Last active January 31, 2022 14:56
OCI Features By Region
# pip install pandas
# pip install openpyxl
# pip install xlsxwriter
import pandas as pd
url='https://www.oracle.com/cloud/data-regions/#government'
df = pd.read_html(url)
writer = pd.ExcelWriter('OCI-Cloud-Active-Features.xlsx', engine='xlsxwriter')
sheets = {0:"North America DS",1:"North America OCI",2:"EMEA DS",3:"EMEA OCI",4:"LAD DS",5:"LAD OCI",6:"APAC DS",7:"APAC OCI",8:"Dedicated",9:"GovCloud"}
FOR /F %i IN (regions.txt) do @aws ssm get-parameters --names /aws/service/ami-windows-latest/Windows_Server-2019-English-Full-Base --query "Parameters[]" --region "%i" >> winami.json
FOR /F %i IN ('aws ec2 describe-instances --filters "Name=tag:Name,Values=tableau" --query "Reservations[*].Instances[*].{Instance:InstanceId}" --output text') DO echo start | aws ec2 start-instances --instance-ids %i
FOR /F %i IN (all_regions.txt) DO @FOR /F %q IN ('aws ec2 describe-vpcs --query "Vpcs[*].VpcId" --region %i --output text') DO @echo %i %q
FOR /L %i in (1,1,254) do ping -w 25 -n 1 10.0.0.%i | grep "Reply" >> n.txt