Skip to content

Instantly share code, notes, and snippets.

View guanidene's full-sized avatar
💭
I may be slow to respond.

Pushpak Dagade guanidene

💭
I may be slow to respond.
View GitHub Profile
@guanidene
guanidene / logging_assertions_exceptions.py
Last active January 1, 2018 06:48
Code to log assertions and any uncaught exceptions without extra effort
# Put this code in the top most level module. Any assertions or uncaught exceptions firing within this module or any of the submodules would be caught by the logger.
def excepthook(*args):
logging.getLogger(<give_correct_logname_here>).error('Uncaught exception:', exc_info=args)
sys.excepthook = excepthook
# Test the above code...
assert 1==2, 'Something went wrong'
@guanidene
guanidene / logging.py
Last active December 30, 2017 12:55 — forked from kingspp/logging.py
Python Comprehensive Logging using YAML Configuration
import os
import yaml
import logging.config
import logging
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""
| **@author:** Prathyush SP
| Logging Setup
"""
@guanidene
guanidene / google_finance_intraday.py
Last active August 30, 2017 16:54 — forked from lebedov/google_finance_intraday.py
Retrieve intraday stock data from Google Finance.
#!/usr/bin/env python
"""
Retrieve intraday stock data from Google Finance.
"""
import csv
import datetime
import re
import pandas as pd
@guanidene
guanidene / all_sundays_saturdays.ipynb
Created February 18, 2017 14:07
IPython Notebook File for generating list of all Saturdays and Sundays for any given year
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@guanidene
guanidene / autoconfigure_display
Created April 28, 2014 13:58
Automatically configure display to detect and use external monitor, if connected.
#!/bin/bash
# Author: Pushpak Dagade
# This script automatically detects if an external monitor is connected,
# and if so, expands my screen with the monitor on the left and my
# laptop screen on the right. If my laptop lid is shut & an external
# monitor is connected, this script uses only the external monitor as
# the display.
#
@guanidene
guanidene / spherochromatism.py
Created September 28, 2012 11:02
Creates a plot of ray height vs. spherochromatism for a equiconvex lens.
#!/usr/bin/python -u
# -*- coding: utf-8 -*-
"""
Creates a plot of ray height vs. spherochromatism for a equiconvex lens.
The lens parameters have been hardcoded below. You can tweak them as required.
Conventions:
Angle made with the positive axis in couter clockwise fashion is positive.
All units, unless mentioned are in SI
@guanidene
guanidene / least_square_fitting_recursive_function.py
Created September 26, 2012 08:37
Curve fitting using least square technique (python)
#!/usr/bin/python -u
# -*- coding: utf-8 -*-
"""
Curve fitting using least square technique.
License: BSD
"""
__author__ = 'पुष्पक दगड़े (Pushpak Dagade) <guanidene@gmail.com>'
__date__ = 'Sun Sep 16 13:57:48 2012'