Skip to content

Instantly share code, notes, and snippets.

View charnley's full-sized avatar

Jimmy C. Kromann charnley

View GitHub Profile
@charnley
charnley / doi2bib.sh
Created April 18, 2016 11:22 — forked from mlund/doi2bib.sh
Convert Digital Object Identifier (DOI) to BibTeX using crosscite.org
#!/bin/bash
curl -LH "Accept: application/x-bibtex;q=1" http://dx.doi.org/$1
echo
@charnley
charnley / import_switch.py
Last active May 17, 2017 16:26
python 2/3 range
from builtins import range
print(type(range(0)))
@charnley
charnley / cVim.conf
Last active October 25, 2018 14:01 — forked from pgericson/cVim.conf
cVim config
map <Leader>pt :pintab<CR>
map <Leader>ut :unpintab<CR>
set noautofocus
let mapleader = ","
let hintcharacters = "sadfjklewcmpgh"
site '*://(soundcloud|(hangouts|mail|inbox|calendar).google|*\.todoist.|*\.messenger).com/*' {
call :pintab
}
let blacklists = ["http://regiosqm.org/*","https://www.messenger.com/*","https://mail.google.com/*","https://drive.google.com/*","http://localhost/*","http://hackertyper.com/*"]
44
structure 44
N 3.43546000 -1.39128000 0.03454000
C 3.05470000 -0.12617000 -0.19176000
C 1.76133000 0.17977000 -0.62198000
C 0.76863000 -0.81576000 -0.78890000
C -0.65327000 -0.34931000 -1.22433000
O 0.90556000 -2.03611000 -0.62312000
C -1.70339000 -0.50569000 -0.07676000
C -3.06562000 0.24255000 -0.29363000
@charnley
charnley / fix_hydrogens.py
Last active August 31, 2020 14:26
Hacking SMILES to get correct Hydrogens on molecule fragments with RDkit
import numpy as np
from rdkit import Chem
# examples
# C=[NH+]C
component = "C=[NH+]"
component = "[NH+]C"
# C[S+](C)C
component = "C[S+]"
@charnley
charnley / kpca.py
Created October 18, 2018 09:19 — forked from andersx/kpca.py
Kernel PCA for QML kernels (ndarray)
import numpy as np
import scipy
def kpca(K, n=2, centering=True):
assert K.shape[0] == K.shape[1], "Square matrix required for Kernel PCA."
assert np.allclose(K, K.T, atol=1e-8), "Symmetric matrix required for Kernel PCA."
# First center kernel.
@charnley
charnley / boomerang effect movie
Last active October 18, 2018 12:37
pymol snippts for pretty pictures of large set of molecules
files=("$@")
reverse() {
# first argument is the array to reverse
# second is the output array
declare -n arr="$1" rev="$2"
for i in "${arr[@]}"
do
rev=("$i" "${rev[@]}")
import numpy as np
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def interpnjck(q, qi, a, method="linear"):
# Warning:
@charnley
charnley / multiprocessing_example
Created January 31, 2019 12:11
multiprocessing
import multiprocessing as mp
workers = mp.cpu_count()
multithread = False
if multithread:
workers /= 2
def submit_molecule(mol):
@charnley
charnley / Makefile
Created September 4, 2019 18:36
Cute multiprocessing of task coming from stdin pipe
PY=python3
all:
find data -name "*.txt" | ${PY} test.py
data:
mkdir -p data
for x in `seq 1 150`; do echo $$x; ./generate_password.sh > data/$$x.txt; done