These two files contain my idea of proper C++ coding conventions. Please feel free to comment below (and I can update).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - Configure options for Geant4 UI/Vis requiring Third Party Libraries | |
# All core Interfaces not requiring third party support are built | |
# automatically with platform differences taken into account. | |
# These are: | |
# | |
# UI Category : Always built on supported platforms | |
# G4UIterminal : UNIX, WIN32 | |
# + - G4UItcsh : UNIX only. | |
# + - G4UIcsh : UNIX, WIN32 | |
# G4UIWin32 : WIN32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# module load cmake/3.4.3 | |
export SW_NAME=geant4 | |
export PACKAGE_VERSION=10.02 | |
export PACKAGE_NAME=$SW_NAME.$PACKAGE_VERSION | |
export PACKAGE_DIR=$HOME/install/packages | |
export PACKAGE_FILE=$PACKAGE_DIR/$PACKAGE_NAME.tar.gz | |
export URL=http://geant4.cern.ch/support/source/$PACKAGE_NAME.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_cnb_year(year): | |
"""Read the whole history of Czech National Bank rates in one year. | |
:param year: 1991-2016 (or "today's year") | |
""" | |
import urllib.request | |
from io import StringIO | |
import pandas as pd | |
url = "https://www.cnb.cz/cs/financni_trhy/devizovy_trh/kurzy_devizoveho_trhu/rok.txt?rok={0}".format(year) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def multiply_rows(df, n, group=True): | |
"""Make multiple copies of each row in pandas. | |
:param df: the dataframe | |
:param n: how many copies | |
:param group: whether to group copies next to each other (AABB) or not (ABAB) | |
""" | |
new_df = pd.DataFrame() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import math | |
def rename(basename, basename2=None, extension=None, directory="."): | |
"""Rename all XXX1.ext, XXX123.ext files to XXX001.ext, ...""" | |
if basename2 is None: | |
basename2 = basename | |
files = [name for name in os.listdir(directory) if name.startswith(basename)] | |
if extension: | |
files = [name for name in files if name.endswith(extension)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import OrderedDict | |
elements = OrderedDict([(1, 'H'), | |
(2, 'He'), | |
(3, 'Li'), | |
(4, 'Be'), | |
(5, 'B'), | |
(6, 'C'), | |
(7, 'N'), | |
(8, 'O'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4 import QtCore, QtGui, QtWebKit | |
import sys | |
app = QtGui.QApplication(sys.argv) | |
# Define content | |
head = """ | |
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$']]}});</script> | |
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"></script>""" | |
body = "$x + 4$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import islice | |
from toolz.itertoolz import sliding_window, last | |
import codecs | |
import os | |
def head(path, n=10, encoding="utf-8"): | |
with codecs.open(os.path.expanduser(path), encoding=encoding) as f: | |
yield from map(lambda x: x.rstrip(), islice(f, n)) | |
def tail(path, n=10, encoding="utf-8"): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
munros = pd.read_csv("../physt/example/munrotab_v6.csv", encoding="latin-1") | |
munros = munros[munros["Post 1997"] == "MUN"] | |
munros["name"] = munros["Name"] | |
munros["height"] = munros["Height (m)"] | |
from bng_to_latlon import OSGB36toWGS84 | |
munros["lat"], munros["long"] = tuple(zip(*[OSGB36toWGS84(*pair) for pair in (zip(munros.xcoord, munros.ycoord))])) | |
munros = munros[["name", "height", "long", "lat"]].reset_index(drop=True) |