Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View javiergarciad's full-sized avatar
🌍

Javier Garcia javiergarciad

🌍
  • Worldwide
  • 06:25 (UTC -05:00)
View GitHub Profile
@javiergarciad
javiergarciad / clickhouse.py
Created June 28, 2023 15:36
ClickHouse Database handler
import logging
from clickhouse_driver import Client, connect, errors
from clickhouse_driver.dbapi.cursor import Cursor
logger = logging.getLogger(__name__)
class ClickHouseDB:
"""
Class for working with a ClickHouse server
"""
@javiergarciad
javiergarciad / config.py
Last active June 28, 2023 15:35
Config class for storing and accessing configurations.
from dotenv import dotenv_values
class Config:
"""
v0.2
Config class for storing and accessing configurations.
This class loads configurations from different sources, such as '.env' files and environment variables,
and provides a convenient way to access the configuration values.
@javiergarciad
javiergarciad / database.py
Last active May 28, 2023 20:59
Sqlachemy Database Manager Class
import os
from pathlib import Path
from datetime import datetime
from typing import List
from contextlib import contextmanager
from sqlalchemy import create_engine, select
from sqlalchemy.orm import sessionmaker
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, DateTime
@javiergarciad
javiergarciad / index.js
Created May 26, 2023 23:41 — forked from ymdx/index.js
How to download CSV File from HttpResponse with Ajax
success: function(data) {
var blob=new Blob([data]);
var link=document.createElement('a');
link.href=window.URL.createObjectURL(blob);
link.download="<FILENAME_TO_SAVE_WITH_EXTENSION>";
link.click();
}
@javiergarciad
javiergarciad / Exclude_tables.md
Created June 2, 2020 01:59 — forked from utek/Exclude_tables.md
Define ignored tables in alembic.ini

Add this in your ini file:

[alembic:exclude]
tables = spatial_ref_sys

In env.py:

def exclude_tables_from_config(config_):
    tables_ = config_.get("tables", None)

if tables_ is not None:

@javiergarciad
javiergarciad / create_ansible_structure
Created November 8, 2018 19:06
Script to create ansible basic project directory structure
#!/bin/bash
# Script to create ansible basic project directory structure
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html
#production # inventory file for production servers
#staging # inventory file for staging environment
#
#group_vars/
import pathlib
import logging
import re
FORMAT = '%(asctime)s %(levelname)-7s %(message)-70s %(name)s.%(funcName)s'
def setup_logging():
@javiergarciad
javiergarciad / init.el
Last active April 21, 2017 22:03
Emacs init
;;;; Javier's .emacs file
;;; Javier Garcia
;;; 18 April 2017
;;;;-------------------------------------------
;;;; GENERAL SETTINGS
;;;;-------------------------------------------
@javiergarciad
javiergarciad / financial_func.py
Created April 28, 2016 03:08
Some financial functios
'''
Created on Mar 28, 2016
@author: Javier Garcia
'''
import numpy as np
from datetime import date
from scipy.optimize import newton
@javiergarciad
javiergarciad / python_resources.md
Last active August 29, 2015 14:10 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides