Skip to content

Instantly share code, notes, and snippets.

def ExecuteCommandReturningStatusStdoutAndStderr(cmd, input=None, cwd=None, env=None):
from subprocess import Popen, PIPE
pipe = Popen(cmd, shell=False, cwd=cwd, env=env, stdout=PIPE, stderr=PIPE)
(output, errout) = pipe.communicate(input=input)
status = pipe.returncode
return (status, output, errout)
@tadeu
tadeu / download-python-sources.bat
Last active February 22, 2018 07:34
download-python-sources.bat
@echo off
mkdir D:\Workspaces
subst W: D:\Workspaces
cdd W:\
mkdir dist__12.0-win32-builddist
cdd W:\dist__12.0-win32-builddist
:: aa dist.build python --no-build --no-package
@tadeu
tadeu / pH.py
Last active December 18, 2015 11:39
pH.py
(C_co2_o, m_co2, V_g, P_co2, V_o, V_w, C_co2_w, C_hco3, C_co3, m_h2s, P_h2s, C_h2s_o, C_h2s_w, C_hs, alk_tot, C_oh, C_h, K1, K2, K_h2s) = symbols(
'C_co2_o m_co2 V_g P_co2 V_o V_w C_co2_w C_hco3 C_co3 m_h2s P_h2s C_h2s_o C_h2s_w C_hs alk_tot C_oh C_h K1 K2 K_h2s')
eq_co2_mass = ( m_co2 - V_g * P_co2 + V_o * C_co2_o + V_w * (C_co2_w + C_hco3 + C_co3) )
eq_h2s_mass = ( m_h2s - V_g * P_h2s + V_o * C_h2s_o + V_w * (C_h2s_w + C_hs) )
eq_alk = ( alk_tot - C_hco3 + 2 * C_co3 + C_hs + C_oh - C_h )
eq_h2co3_1st = (K1 - C_h * C_hco3 / C_co2_w)
eq_h2co3_2nd = (K2 - C_h * C_co3 / C_hco3)
eq_h2s_dissoc = (K_h2s - C_hs * C_h / C_h2s_w)
solve for (C_co2_o, C_h2s_o, C_h, C_hco3, C_co3, C_h2s_w), m_co2 = V_g * P_co2 + V_o * C_co2_o + V_w * (C_co2_w + C_hco3 + C_co3), m_h2s = V_g * P_h2s + V_o * C_h2s_o + V_w * (C_h2s_w + C_hs), alk_tot = C_hco3 + 2 * C_co3 + C_hs + C_oh - C_h, K1 = C_h * C_hco3 / C_co2_w, K2 = C_h * C_co3 / C_hco3, K_h2s = C_hs * C_h / C_h2s_w
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tadeu
tadeu / effective_modern_cmake.md
Created June 29, 2018 20:00 — forked from mbinna/effective_modern_cmake.md
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@tadeu
tadeu / conda_debug_1.70.txt
Last active June 11, 2019 21:23
Conda slowdown due to boost package
# Command:
# conda env update --debug --file environment-boost-1.70.yml --prune >conda_debug_1.70.txt 2>&1
DEBUG conda.gateways.logging:set_verbosity(231): verbosity set to 2
DEBUG conda.core.solve:solve_final_state(212): solving prefix W:\Miniconda3\envs\test_boost_170
specs_to_remove: frozenset()
specs_to_add: frozenset({MatchSpec("sqlalchemy-utils==0.33.6"), MatchSpec("flask-allows==0.4"), MatchSpec("conda-wrappers"), MatchSpec("freetype=2.9.1"), MatchSpec("setuptools==40.5.0"), MatchSpec("sqlalchemy-utc==0.10.0"), MatchSpec("pytest-timeout==1.3.3"), MatchSpec("seaborn==0.9.0"), MatchSpec("hypothesis==3.57.0"), MatchSpec("ipykernel==4.8.2"), MatchSpec("pyqt==5.6.0"), MatchSpec("mkl==2019.3"), MatchSpec("exec-wrappers==1.0.3"), MatchSpec("sphinx==1.7.4"), MatchSpec("itsdangerous==0.24"), MatchSpec("ninja=1.9.0"), MatchSpec("mkl-devel==2019.3"), MatchSpec("execnet==1.5.0"), MatchSpec("pytest-mock==1.10.0"), MatchSpec("icc_rt==2019.0.0"), MatchSpec("six==1.11.0"), MatchSpec("py==1.7.0"), MatchSpec("noteb