Skip to content

Instantly share code, notes, and snippets.

View micheleberardi's full-sized avatar
:octocat:
Life is good

Michele micheleberardi

:octocat:
Life is good
View GitHub Profile
import boto3
def update_route53_record(hosted_zone_id, domain_name, action, ip_address, ttl=300):
client = boto3.client('route53')
# Check if the action is valid
if action not in ('UPSERT', 'DELETE'):
print("Invalid action. Use 'UPSERT' to add/update or 'DELETE' to remove.")
return
@micheleberardi
micheleberardi / nginx.conf
Last active November 7, 2022 19:11
nginx conf for nextJS
server {
listen 80;
server_name sb.domain.com;
return 301 https://sb.domain.com$request_uri;
}
server {
listen 443 ssl http2;
server_name sb.domain.com;
bind 127.0.0.1
protected-mode yes
port 6379
tcp-backlog 65384
unixsocket /tmp/redis_6379.sock
unixsocketperm 700
timeout 0
tcp-keepalive 300
daemonize no
supervised no
[Unit]
Description=Redis persistent key-value database
After=network.target
[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf --daemonize no --supervised systemd
ExecStop=/usr/libexec/redis-shutdown
#Type=notify
User=redis
Group=redis
{
 'data': [
 {
 'name': 'impressions',
 'period': 'lifetime',
 'values': [
 {
 'value': 13
 }
 ],
import requests
def get_url(instagram_media_id,instagram_token):
 url = ""https://graph.facebook.com/v14.0/" + str(instagram_media_id) + "/insights?metric=impressions%2Cengagement%2Creach%2Csaved%2cvideo_views&access_token=" + str(instagram_token)
 r = requests.get(url)
 return r.json()
@micheleberardi
micheleberardi / def_ig_media.py
Created July 12, 2022 19:29
GET IG MEDIA LIST
import requests
def get_url(instagram_profile_id,instagram_token):
url = "https://graph.facebook.com/v14.0/"+str(instagram_profile_id)+"/media?fields=id%2Ccaption%2Cis_comment_enabled%2Ccomments_count%2Clike_count%2Cmedia_type%2Cmedia_url%2Cpermalink&access_token="+str(instagram_token)
r = requests.get(url)
return r.json()
@micheleberardi
micheleberardi / script_cron
Created February 19, 2022 23:16
script_cron
gcloud scheduler --project micheleone \
jobs create http import_catalog_xmq5ynl8i2i \
--time-zone='America/Los_Angeles' \
--schedule='0 0 * * *' \
--uri='https://retail.googleapis.com/v2alpha/projects/***********/locations/global/catalogs/default_catalog/branches/1/products:import' \
--description='Import Retail catalog data' \
--headers='Content-Type: application/json; charset=utf-8' \
--http-method='POST' \
--message-body='{"inputConfig":{"bigQuerySource":{"projectId":"project-id","datasetId":"retail","tableId":"catalog","dataSchema":"product"}},"reconciliationMode":"INCREMENTAL"}' \
--oauth-service-account-email=''
@micheleberardi
micheleberardi / example_dict.txt
Last active February 19, 2022 23:06
example_google_retails
{"id": sku,"categories":categories],"title":description,"priceInfo":[{"currencyCode":"USD"},{"price":float(exact_price)},{"originalPrice":float(exact_price)},{"cost":float(exact_price)}]}
[
{
"name": "product_metadata",
"type": "RECORD",
"mode": "NULLABLE",
"fields": [
{
"name": "images",
"type": "RECORD",
"mode": "REPEATED",