Skip to content

Instantly share code, notes, and snippets.

View exergonic's full-sized avatar
🏠
Working from home

Billy Wayne McCann exergonic

🏠
Working from home
View GitHub Profile
@exergonic
exergonic / beautiful_idiomatic_python.md
Created December 6, 2019 05:28 — forked from 0x4D31/beautiful_idiomatic_python.md
[Beautiful Idiomatic Python] Transforming Code into Beautiful, Idiomatic Python #python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@exergonic
exergonic / configure_vim.sh
Created August 3, 2017 03:22
Compile vim with lua, python, ruby
./configure --prefix=${HOME}/usr \
--enable-luainterp=yes \
--enable-pythoninterp=yes \
--enable-rubyinterp=yes \
--enable-gui=no \
--disable-nls \
--with-features=huge \
--enable-multibyte
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001
______
save as *.reg
#!/usr/bin/env python3
"""
ABOUT
Calculation Boltzmann population of conformers at 298K.
Relative energies (kcal/mol) are given as arguments to the script.
Output:
The percent abundance associated with each relative free energy
@exergonic
exergonic / assign_class.F
Created May 25, 2015 15:15
Systematic Assignment of Archetypal Organic Functional Groups
c-----------------------------------------------------------------------
c-----------------------------------------------------------------------
c Copyright (c) 2014 by Billy Wayne McCann, Ben Hay
c Chemical Sciences Division
c Chemical Separations Group
c Oak Ridge National Lab
c All rights reserved
c-----------------------------------------------------------------------
c-----------------------------------------------------------------------
c
@exergonic
exergonic / quaternion_rotation.F
Last active November 21, 2020 09:29
Fortran77 subroutine for rotation about an arbitrary axis
c Copyright (c) 2014 by Billy Wayne McCann
c All rights reserved.
c
c Redistribution and use in source and binary forms, with or without
c modification, are permitted provided that the following conditions
c are met:
c 1. Redistributions of source code must retain the above copyright
c notice, this list of conditions and the following disclaimer.
c 2. Redistributions in binary form must reproduce the above copyright
c notice, this list of conditions and the following disclaimer in the
c Copyright (c) 2014 by Billy Wayne McCann
c All rights reserved.
c
c Redistribution and use in source and binary forms, with or without
c modification, are permitted provided that the following conditions
c are met:
c 1. Redistributions of source code must retain the above copyright
c notice, this list of conditions and the following disclaimer.
c 2. Redistributions in binary form must reproduce the above copyright
c notice, this list of conditions and the following disclaimer in the

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@exergonic
exergonic / distance2plane.f77
Last active January 1, 2016 20:29
Fortran code for finding the distance from a point to a plane.
subroutine distance2plane(x, y, z, flat)
!
! Return the distance of a point to a plane. The plane is created by
! the first three coordinates. The point of interest is the fourth.
!
real x(4), y(4), z(4) ! the fourth coordinate is the coordinate
! which is off of the plane
real distance ! distance of central atom from plane
real threshhold ! threshhold for testing planarity
real vect1(3) ! vector created by point 3 and point 1
@exergonic
exergonic / pi-pi.py
Last active December 10, 2019 22:50
Solvent-solute Pi-Pi Stacking
#!/usr/bin/env python3
## README #####################################################################
#
# This script is meant to measure pi-pi stacking between the solute and solvent
# atoms. It will evaluate only those solvent atoms within a certain cutoff,
# defined by the user (below).
cutoff = 10.0