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
@micheleberardi
micheleberardi / google_importer.py
Last active February 19, 2022 22:56
Google Retail import into Big Query
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:
import subprocess
import os
import subprocess
import requests
def is_service_running(name):
with open(os.devnull, 'wb') as hide_output:
exit_code = subprocess.Popen(['service', name, 'status'], stdout=hide_output, stderr=hide_output).wait()
return exit_code == 0
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
__author__ = "Michele Berardi"
__copyright__ = "Copyright 2020"
__license__ = "GPL"
__version__ = "1.0.8"
__maintainer__ = "Michele Berardi"
__email__ = "michele@linux.com"
__status__ = "Production"
@micheleberardi
micheleberardi / class_example
Created October 10, 2019 15:45
simple clss
import requests
class Authorization:
def __init__(self, username, password, company_uid):
self.username = username
self.password = password
self.company_uid = company_uid
def token(self):
url = "https://api.domain.com/3.0/login/?username=" + self.username + "&password=" + self.password + "&company_uid=" + self.company_uid + ""
@micheleberardi
micheleberardi / script_import_tensoflow
Created September 11, 2019 20:42
script_import_tensoflow
#sudo apt-get install libmysqlclient-dev
#pip install mysqlclient
import csv
import MySQLdb
import tensorflow as tf
mydb = MySQLdb.connect(host='localhost',
user='root',
passwd='root')
cursor = mydb.cursor()
@micheleberardi
micheleberardi / tensorflow
Created September 11, 2019 20:38
tensorflow
sudo yum -y install epel-release
sudo yum -y install gcc gcc-c++ python-pip python-devel atlas atlas-devel gcc-gfortran openssl-devel libffi-devel
# use pip or pip3 as you prefer for python or python3
pip install --upgrade virtualenv
virtualenv --system-site-packages ~/venvs/tensorflow
source ~/venvs/tensorflow/bin/activate
pip install --upgrade numpy scipy wheel cryptography #optional
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl
# or below if you want gpu, support, but cuda and cudnn are required, see docs for more install instructions
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl
@micheleberardi
micheleberardi / upgarde_checker
Created September 10, 2019 01:36
upgarde_checker
michelone@bd01$ ./mysqlsh root:@localhost:3307 -e "util.checkForServerUpgrade();"
mysqlsh: [Warning] Using a password on the command line interface can be insecure.
The MySQL server at localhost:3307 will now be checked for compatibility issues for upgrade to MySQL 8.0...
MySQL version: 5.7.24 - Source distribution
1) Usage of db objects with names conflicting with reserved keywords in 8.0
No issues found
2) Usage of utf8mb3 charset
No issues found
@micheleberardi
micheleberardi / dizionario_output
Created September 9, 2019 23:07
dizionario_output
{'data': [{'access_token': 'EAAHR3c1UymABAN6W47KDb08KLUcbNq8zJidVO4MJTx1SAZC{
'data': [
{
'access_token': 'EAAHR3c1UymABAN6W47KDb08KLUcbNq8zJidVO4MJTx1SAZCmAF6VqR92jesPIQt773U5ZCBxvnTE0HQC8t2HS8j1ctnZCvvqLIacKRLM6FhhLHNgf9Sqne61QIJ31Nt5MTI85rbm8xnHfAY7oabcfv6Oh3SWqLYDRLVn9dmwwZDZD',
'category': 'Blogger',
'category_list': [
{
'id': '361282040719868',
'name': 'Blogger'
}
@micheleberardi
micheleberardi / 3_VALUE
Created September 9, 2019 23:04
3_VALUE
app_id = '512225539574368'
app_secret = '9dc19451ce6a58d4e22e9634053f443f'
user_short_token = 'EAAHR3c1UymABAARMW95G9U3NlzSE8lvWbmnJtGr7GauH3aofCCCiZBcxBfZBNN1ZAxOOWMEzzFgJLZAR2QHYtvIMZChB4ykU5U6ZAgvjdRo3lKffPeLJTPDztQZC29lN3mG4rVFFzuQibSVGhbr9Onhzf6oxfGXNbOSD9Sag5D3XjTgoH2LrfEfkUrj0SeZCXoNr9xaT7ZBrFoAZDZD'