Skip to content

Instantly share code, notes, and snippets.

View mcs07's full-sized avatar

Matt Swain mcs07

View GitHub Profile
@mcs07
mcs07 / backup_db.py
Last active August 14, 2019 20:50
Simple versioned backups for MongoDB
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Save versioned backups of collections in MongoDB. Quick and dirty. """
import datetime
import shutil
import os
import subprocess
import zipfile
@mcs07
mcs07 / customwriter.cpp
Last active August 10, 2016 10:53
A custom writer class for JsonCpp that allows more control over the output formatting of the JSON. Allows custom indenting, custom line wrap width, and custom whitespace around brackets, colons and commas.
/**********************************************************************
Copyright (c) 2013 by Matt Swain <m.swain@me.com>
The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@mcs07
mcs07 / inchi-osx.diff
Last active July 4, 2022 13:08
A patch for the InChI 1.04 makefile to support Mac OS X. This is needed because the OS X linker does not support `soname` or `version-script`.
diff --git a/INCHI_API/gcc_so_makefile/libinchi.map b/INCHI_API/gcc_so_makefile/libinchi.map
index 0526992..0f768c8 100755
--- a/INCHI_API/gcc_so_makefile/libinchi.map
+++ b/INCHI_API/gcc_so_makefile/libinchi.map
@@ -1,5 +1,32 @@
-{
-global: CheckINCHI; CheckINCHIKey; FreeINCHI; FreeStdINCHI; FreeStructFromINCHI; FreeStructFromStdINCHI; Free_inchi_Input; Free_std_inchi_Input; GetINCHI; GetINCHIKeyFromINCHI; GetINCHIfromINCHI; GetStdINCHI; GetStdINCHIKeyFromStdINCHI; GetStringLength; GetStructFromINCHI; GetStructFromStdINCHI; Get_inchi_Input_FromAuxInfo; Get_std_inchi_Input_FromAuxInfo; INCHIGEN_Create; INCHIGEN_Destroy; INCHIGEN_DoCanonicalization; INCHIGEN_DoNormalization; INCHIGEN_DoSerialization; INCHIGEN_Reset; INCHIGEN_Setup; STDINCHIGEN_Create; STDINCHIGEN_Destroy; STDINCHIGEN_DoCanonicalization; STDINCHIGEN_DoNormalization; STDINCHIGEN_DoSerialization; STDINCHIGEN_Reset; STDINCHIGEN_Setup;
-local: *;
-};
-
@mcs07
mcs07 / gocr-libs.diff
Created August 14, 2013 09:02
A patch for the gocr makefile so `make libs` works properly.
diff --git a/src/Makefile.in b/src/Makefile.in
index bf4181f..883fec2
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -10,7 +10,7 @@ PROGRAM = gocr$(EXEEXT)
PGMASCLIB = Pgm2asc
#LIBPGMASCLIB = lib$(PGMASCLIB).a
# ToDo: need a better pgm2asc.h for lib users
-#INCLUDEFILES = gocr.h
+INCLUDEFILES = pgm2asc.h output.h list.h unicode.h gocr.h pnm.h
@mcs07
mcs07 / openbabel-parsmart.diff
Created November 1, 2013 11:51
A patch to prevent segmentation faults in Open Babel.
diff --git a/src/parsmart.cpp b/src/parsmart.cpp
index 120963e..22fe56e 100644
--- a/src/parsmart.cpp
+++ b/src/parsmart.cpp
@@ -1181,7 +1181,6 @@ namespace OpenBabel
FreeAtomExpr(expr1);
return (AtomExpr*)0;
}
- delete expr1;
expr1 = BuildAtomBin(AE_ANDLO,expr1,expr2);
@mcs07
mcs07 / rdkit-mavericks.diff
Created November 6, 2013 11:52
A patch for RDKit 2013.09.1 to compile with libc++ which is now the default in Mavericks.
diff --git a/Code/RDGeneral/Dict.h b/Code/RDGeneral/Dict.h
index 6d368a4..6f586a8 100644
--- a/Code/RDGeneral/Dict.h
+++ b/Code/RDGeneral/Dict.h
@@ -32,14 +32,12 @@
//!
class Dict {
public:
- typedef std::map<const std::string, boost::any> DataType;
+ typedef std::map<std::string, boost::any> DataType;
@mcs07
mcs07 / ocrad-mavericks.diff
Last active December 30, 2015 00:39
A patch for ocrad 0.22 to compile with libc++ which is now the default in OS X Mavericks.
diff --git a/character_r11.cc b/character_r11.cc
index 9b054e1..794e9c0 100644
--- a/character_r11.cc
+++ b/character_r11.cc
@@ -18,6 +18,7 @@
#include <algorithm>
#include <cstdio>
+#include <cstdlib>
#include <vector>
@mcs07
mcs07 / tautomer.py
Created April 3, 2014 15:20
Rough first go at tautomer enumeration and canonicalization using RDKit in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import copy
from itertools import tee, izip
import logging
from rdkit import Chem
from rdkit.Chem.rdchem import BondType, BondStereo, BondDir
__author__ = 'Matt Swain'
@mcs07
mcs07 / cinema.scpt
Created April 6, 2014 11:40
Parse booking confirmation emails from Cinema and add Calendar event.
-- Parse booking confirmation emails from Cinema and add Calendar event
-- Author: Matt Swain <m.swain@me.com>, Version 1.0, License: MIT
-- Triggered by Mail rule.
using terms from application "Mail"
on perform mail action with messages msgs for rule theRule
tell application "Mail"
repeat with msg in msgs
try
set msgcontent to content of msg
@mcs07
mcs07 / lilly.diff
Created May 18, 2014 18:08
Patch for Lilly MedChem Rules to compile on OS X Mavericks with clang.
diff --git a/include/iwaray.h b/include/iwaray.h
index 1b58e95..213f25a 100644
--- a/include/iwaray.h
+++ b/include/iwaray.h
@@ -341,7 +341,7 @@ resizable_array_p<T>::resizable_array_p (int n)
template <typename T>
resizable_array_p<T>::resizable_array_p (T * item)
{
- add (item);
+ this->add (item);