Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Life is good

Michele micheleberardi

:octocat:
Life is good
View GitHub Profile
@micheleberardi
micheleberardi / nginx.conf
Last active November 7, 2022 19:11
nginx conf for nextJS
View nginx.conf
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;
View gist:a06ed514c121c548205026b0b946bfa6
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
View gist:a7e75777b80571e6ef185cdb427b2bdb
[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
View response_ig_user_media.dict
{
 'data': [
 {
 'name': 'impressions',
 'period': 'lifetime',
 'values': [
 {
 'value': 13
 }
 ],
View def_ig_media_insights.py
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
View def_ig_media.py
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
View 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
View example_dict.txt
{"id": sku,"categories":categories],"title":description,"priceInfo":[{"currencyCode":"USD"},{"price":float(exact_price)},{"originalPrice":float(exact_price)},{"cost":float(exact_price)}]}
View schema_google_retail.json
[
{
"name": "product_metadata",
"type": "RECORD",
"mode": "NULLABLE",
"fields": [
{
"name": "images",
"type": "RECORD",
"mode": "REPEATED",
@micheleberardi
micheleberardi / google_importer.py
Last active February 19, 2022 22:56
Google Retail import into Big Query
View google_importer.py
from modules import defines
import ndjson
from google.cloud import bigquery
import pymysql
database = pymysql.connect(host='IP', user='USER', passwd='PWD', db='DB_NAME',use_unicode=True, cursorclass=pymysql.cursors.DictCursor, charset="utf8")
def select_exe(query_select):
mydb = pymysql.connect(host='IP', user='USER', passwd='PWD', db='DB_NAME',use_unicode=True, cursorclass=pymysql.cursors.DictCursor, charset="utf8")
try: