Skip to content

Instantly share code, notes, and snippets.

@pmav99
pmav99 / config2.json
Last active June 15, 2022 14:56
Python logging configuration using JSON. If you want an updated example also covering YAML files, check here: https://github.com/pmav99/python-logging-example
{
"logging": {
"version": 1,
"disable_existing_loggers": true,
"formatters": {
"brief": {
"class": "logging.Formatter",
"datefmt": "%I:%M:%S",
"format": "%(levelname)-8s; %(name)-15s; %(message)s"
},
@pmav99
pmav99 / BootstrapTable.py
Created January 19, 2015 17:35
Bootstrap Table Helper
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: Panagiotis Mavrogiorgos
# email: gmail, pmav99
"""
A help class for generating bootstrap tables.
"""
from __future__ import division
@pmav99
pmav99 / foo.pgn
Created February 27, 2015 17:34
me vs malakas - correspondence game 1
[Event "Let's Play!"]
[Site "Chess.com"]
[Date "2015.02.18"]
[Round "?"]
[White "pmav99"]
[Black "RedPawn81"]
[Result "*"]
[WhiteElo "1913"]
[BlackElo "1564"]
[TimeControl "1 in 5 days"]
@pmav99
pmav99 / linspace.py
Created April 28, 2015 14:05
Pure python linspace / logspace implementation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: Panagiotis Mavrogiorgos
# email: gmail, pmav99
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import
@pmav99
pmav99 / nearly_equal.py
Last active August 29, 2015 14:20
A pure python "nearly_equal" implementation
def nearly_equal(a, b, epsilon):
"""
Return `True` if the "difference" between `a` and `b` is smaller than `epsilon`, `False` otherwise.
This function tries to solve the problem of float comparison in a way that handles all cases
(i.e. comparing floats with `inf`, `nan` etc).
Do take note that when the difference between `a` and `b` is "equal" to `epsilon` then the
results may not be what you expect them to be... For example::
a = 1
b = a + 1e-7
epsilon = 1e-7
@pmav99
pmav99 / von_mises.py
Created May 4, 2015 08:45
Modified von Mises
def von_mises(S11, S22, S12, fc, ft):
"""
Returns the type of failure according to the modified Von Mises
failure criterion.
Input
-----
S11 : float
Normal stresses (σx)
S22 : float
@pmav99
pmav99 / virtualenv.md
Last active August 29, 2015 14:24
virtualenv + virtualenvwrapper instructions

Tested under zsh, should work under bash too.

  1. Install virtualenv & virtualenvwrapper. Depends on the distribution.

  2. Put in .zshrc (.bashrc if you use bash):

    # Virtualenvs
    if which virtualenvwrapper.sh &> /dev/null; then
        mkdir -p $HOME/Prog

export WORKON_HOME=$HOME/.virtualenvs

@pmav99
pmav99 / makefile
Created May 26, 2016 08:45
makefile template
.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
@pmav99
pmav99 / circle_ci_example.py
Created June 30, 2016 12:54
An example of using circle CI with hammock
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# module: circle_ci_example.py
# author: Panagiotis Mavrogiorgos (pmav99)
"""
An example of using Circle-CI's REST API using hammock.
For more info on how to use hammock check the documentation:
https://github.com/kadirpekel/hammock