Skip to content

Instantly share code, notes, and snippets.

View saamerm's full-sized avatar
💭
Answering Questions, & Questioning Answers

Saamer Mansoor saamerm

💭
Answering Questions, & Questioning Answers
View GitHub Profile
@saamerm
saamerm / ImageDownloader.py
Last active October 22, 2024 18:06
Python code to download images from the internet using URLs in a CSV/Google Sheet and resize them selectively
# Create a table with 7 rows in Google Sheets and Copy the data with the headers and paste it in here: https://codepen.io/saamerm/pen/NWVZyEm
# Then get the json from that codepen and replace the variable in line 8 with the new json
import os
import requests
import json
# Sample JSON data
hotels = [
{
"HotelId": "1085",
@saamerm
saamerm / imageResizer.py
Last active October 21, 2024 19:28
Python Image Resizer AspectFit, using `brew install pillow`
import os
from PIL import Image
# Folder containing your images
folder_path = os.getcwd()
# Desired output size
target_size = (450, 180)
# Iterate over files in the folder
@saamerm
saamerm / PostGetAndPrintMultipleAPI.sh
Last active July 16, 2024 20:09
Perform an Salesforce Marketing Cloud Post API call, then wait 2 seconds and take the response to Get the status of the email sent and Print, while using multiple bodies within your powershelgl code
function Invoke-EmailAPI {
param (
[hashtable]$body
)
# Define the API endpoint
$url = "{URL}"
# Define the authorization token
$token = "afasfa23414"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@saamerm
saamerm / UDPLiveStreamAudioPlay.py
Last active May 17, 2024 14:29
UDP Live Stream Audio and Play from byte stream in Mulaw format
import socket # Doesn't need installation
import pyaudio # Requires another package
import audioop # Doesn't need installation until python 3.13
import time
# Constants for the UDP socket
UDP_IP = "192.168.0.194" # Listen on all local IPs
UDP_PORT = 9444 # Port number to listen on
SUBSCRIBE_INTERVAL = 15 # in seconds
@saamerm
saamerm / NetworkMonitor.swift
Created March 26, 2024 18:47
An Internet Connectivity class in swift language, to add a check to see if the device is connected to the internet, and an example of how it is implemented in SwiftUI
import Network
class NetworkMonitor: ObservableObject {
@Published var isInternetAvailable = false
init() {
startMonitoring()
}
@saamerm
saamerm / AppScript.js
Last active January 5, 2024 02:15
App Script to get info from a tracker connected to this https://codepen.io/saamerm/pen/yLwYvXe
function doGet(request){
var result = processRequest(request);
return ContentService
.createTextOutput(result)
.setMimeType(ContentService.MimeType.TEXT);
}
function processRequest(e)
{
// Open Google Sheet using ID
# N.B. When changing this file, run this in the Terminal to load the updated values: 'npm run start -- --reset-cache'
NODE_ENV=development
# the URL to the GraphQL api
API_URL=https://sonesta-gateway-test.azure-api.net/member/graphql
API_URL_GUEST=https://sonesta-gateway-test.azure-api.net/guest/graphql
API_URL_HEALTHCHECK=https://sonesta-gateway-test.azure-api.net/healthcheck/v1.1/heartbeat
API_SUBSCRIPTION_KEY=5e60f927beb2407195a1ca72583c1507
@saamerm
saamerm / EmailCollectionAppScript.js
Created January 10, 2023 14:23
Email Collection App Script javascript code
function doPost(request){
var resultObject = JSON.parse(request.postData.contents);
var result = processResult(resultObject);
return ContentService
.createTextOutput(JSON.stringify(result))
.setMimeType(ContentService.MimeType.JSON);
}
function processResult(resultObject)
{
@saamerm
saamerm / alertlottie.json
Created July 15, 2022 23:01
An alert Lottie json file
{"v":"5.7.1","fr":15,"ip":10,"op":45,"w":500,"h":500,"nm":"Comp 2","ddd":0,"assets":[{"id":"image_0","w":844,"h":821,"u":"","p":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA0wAAAM1CAMAAAB0boGMAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAACXBIWXMAAAABAAAAAQBPJcTWAAAARVBMVEVHcEz4t6j3ppT4r5770sn/9vP/8O3+4tz62tP/6eX5v7H7zMH2nYnzf2XzinH1lH7////xc1b5xbnwZ0fvWzntQhzuTys7zAZPAAAAF3RSTlMAYXdsPAwUJzIdVkWDrJ6QBbxOzd397XBBxq0AACAASURBVHja7J3Lduu4DkQ1MClx9UT//7X3nkQiUUCBpF+JHQNW/La7B96ngAJILUtERERERERExGzs5CoiImIGG31hV+r1iIgIjsbXvX/Hflyrq51C9fVkkBXxgRrUfv9f9/dvgvYDo6V3tezmrXulC744IuJTlKjJzyKwOAMemFjk3QpYxS2YivgAjBalPpagPkXyrerTS8sGBVUBVcSfgkhK0QLlz4NDyp2ANmQq4q/kdI2jqRTuMUxptEKmIt4/pavF0FwOl/4dc1dXSFVzOZbgKeKdSLJytPT5OfA47uz1ilEkX03qYz2lEkVWiFTEu1RHO5h1XQFKp8YkT5PIE/i0+PyUaIVIRbyHHi3GoKM6dCDAGEn/j3q1J/XE8exxl6hTArEbOoFLeBMRL1chLVj3OwglyZDC5zzasy5OxxvUQfK+QQKIvamIiNcQpN11vFvmJSESpNSH53VKQpkSQQnfKzkySDaoko/TEhIV8Qok+RSpZA5+7iA4CIcESjzeyWv2W/D7sSzrVVPLHnOzEb+b3PkoqVpIZ2RCeHYC0I2xI31WqByRWhCpUKiIn8Ooz