Skip to content

Instantly share code, notes, and snippets.

@shitana
shitana / get-env-aws.py
Created December 10, 2023 10:30
Get AWS Cred from SSO login
"""
Prerequistes
- AWS SSO login
- sso configure sso --profile <PROFILE_NAME>
- sso sso login --profile <PROFILE_NAME>
- SSO Cred json file cat .aws/sso/cache/d54a50b27ab3580ec5477511f9d40eb8f92b5649.json | jq
{
"startUrl": "https://d-90678c01fa.awsapps.com/start#",
"region": "us-east-1",
"accessToken": "aoaA..................SLRA",
Questions are not from any actual exam!!!
Q: Create a job that calculates pi to 2000 decimal points using the container with the image named perl
and the following commands issued to the container: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
Once the job has completed, check the logs to and export the result to pi-result.txt.
Solution:
@shitana
shitana / generate_toc.rb
Created February 17, 2019 20:24 — forked from albertodebortoli/generate_toc.rb
Generate Markdown TOC
#!/usr/bin/env ruby
File.open("your_file.md", 'r') do |f|
f.each_line do |line|
forbidden_words = ['Table of contents', 'define', 'pragma']
next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ }
title = line.gsub("#", "").strip
href = title.gsub(" ", "-").downcase
puts " " * (line.count("#")-1) + "* [#{title}](\##{href})"
@shitana
shitana / cRecurseFtp.py
Last active August 31, 2016 16:09 — forked from flibbertigibbet/recurse_ftp.py
Recursively fetch files from an FTP server directory. Here, it's downloading all the zip files found in or beneath the parent directory.
#!/usr/bin/env python
from ftplib import FTP
import os
class cRecursive:
my_dirs = [] # global
my_files = [] # global
all_dirs = [] # global
curdir = '' # global