Skip to content

Instantly share code, notes, and snippets.

View kdheepak's full-sized avatar

Dheepak Krishnamurthy kdheepak

View GitHub Profile
import logging
log_format = (
"%(asctime)s - %(levelname)s [%(filename)s:%(lineno)d] : %(message)s"
)
logger = logging.getLogger(__name__)
s = logging.StreamHandler()
f = logging.Formatter(log_format)
s.setFormatter(f)
@kdheepak
kdheepak / pireceiver.py
Created August 24, 2018 17:01
ComboFederate Pi Exchange example
import helics as h
fedinitstring = "--federates=1"
deltat = 0.01
helicsversion = h.helicsGetVersion()
print("PI RECEIVER: Helics version = {}".format(helicsversion))
# Create Federate Info object that describes the federate properties */
# Change prefix key to `
unbind C-b
set -g prefix `
bind-key ` send-prefix
bind-key C-a set-option -g prefix C-a
bind-key C-b set-option -g prefix `
# we might need ` at some point, allow switching
bind-key C-a set-option -g prefix C-a
# Better Logging Format
## Author : Dheepak Krishnamurthy
## License : MIT
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# create formatter and add it to the handlers
formatter = logging.Formatter('%(asctime)s - [%(module)s(%(lineno)d)] - "%(name)s".%(levelname)s - %(message)s', "%Y-%m-%d %H:%M:%S")
ch.setFormatter(formatter)
from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
@kdheepak
kdheepak / Py_Macro_PyCall.ipynb
Created August 30, 2017 08:09
A @py macro for Python-like syntax in Julia
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
ls = log --graph --abbrev-commit --decorate --color=always --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) - %C(dim red)%an%C(reset)%C(bold yellow)%d%C(reset)' --all
lsa = log --graph --abbrev-commit --decorate --color=always --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) - %C(dim red)<%an, %cN>%C(reset)%C(bold yellow)%d%C(reset)' --all
Get-ChildItem HKLM:\Software\Classes -ErrorAction SilentlyContinue | Where-Object {
$_.PSChildName -match '^\w+\.\w+$' -and (Test-Path -Path "$($_.PSPath)\CLSID")
} | Select-Object -ExpandProperty PSChildName
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# set -o errexit
# set -o pipefail
# set -o nounset
def __repr__(self):
return '<%s.%s object at %s>' % (
self.__class__.__module__,
self.__class__.__name__,
hex(id(self))
)