Skip to content

Instantly share code, notes, and snippets.

View matteoferla's full-sized avatar

Matteo Ferla matteoferla

View GitHub Profile
@matteoferla
matteoferla / Ecowitt_api.py
Last active August 10, 2023 06:22
My new weather station is an Ecowitt GW100 and its website returns the data. This is the bareboneiest code possible
# ## log-in
pwd ='👾👾👾'
base_url = 'http://👾.👾.👾.👾' # my router's DNS does not resolve hyphens `ws-gateway.local`
import base64
import requests
sesh = requests.session()
sesh.get(f'{base_url}/login.html')
response : requests.Response = sesh.post(f'{base_url}/set_login_info', {'pwd': base64.b64encode(pwd.encode())})
@matteoferla
matteoferla / color_madness.ipynb
Last active July 11, 2023 13:45
Colour choice?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matteoferla
matteoferla / download_REAL.py
Created July 2, 2023 07:58
Download Enamine REAL Database on a remote machine
import requests
class DownloadEnamine:
"""
This class is set up to download Enamine REAL database on a remote machine.
Instatiation requires plain ``username`` and ``password``.
.. code-block::python
de = DownloadEnamine('foo.bar@baz.ac.uk', 'Foo123')
de.download_all('REAL')
@matteoferla
matteoferla / import_searcher.py
Created June 1, 2023 15:35
Given a cloned GitHub repo traverse it to find what the imports actually are in order to get around a lazy pip freeze requirement
root = Path.home() / '👾👾👾'
reponame = '👾👾👾'
import os
import re
import sys
from pathlib import Path
import_lines = set()
for path in (root / reponame).glob('**/*.py'):
@matteoferla
matteoferla / Markovian_names.py
Last active May 29, 2023 18:09
Names generated by a simple Markov chain
from collections import defaultdict
import requests, json, operator
from typing import List, Optional
import random
class NameGen:
"""Super simple name genarator by Markov chain.
There are tons on the internet —dissociated press game.
It is so easy to write I made one rather than search...
"""
@matteoferla
matteoferla / dockbuster.ipynb
Created May 17, 2023 16:23
Martin's pretzels summary page in Michelanglo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matteoferla
matteoferla / fix_links.py
Last active April 3, 2023 10:10
Fix (absolute) symlinks in a copied folder
@matteoferla
matteoferla / whats-that-cmd-again.md
Last active July 9, 2023 07:32
Just a simple dump of PyMOL>print dir(cmd)

In PyMOL in Python (as a package, i.e. pymol2), the autocomplete for pymol2.PyMOL().cmd does not work. So I keep having to check what is present in the original pymol.

  • ALL_STATES
  • CURRENT_STATE
  • DEFAULT_ERROR
  • DEFAULT_SUCCESS
  • LockCM
  • QuietException
  • SafeEvalNS
@matteoferla
matteoferla / fauxalysis.py
Last active March 17, 2023 16:53
Personal/Flawed Fragment network merger workflow
from typing import List
import os
from rdkit import Chem
def make_fauxalysis(hits: List[Chem.Mol], target_name: str, base_folder='.') -> None:
"""
Given a list of hits, make a fragalysis-download-like folder structure
:param hits:
:param target_name:
@matteoferla
matteoferla / retro_response_munger.py
Last active March 1, 2023 15:03
In a Jupyter notebook, given the output of Postera API retrosynthesis display the reactions
from typing import TypedDict, Dict, Any, Union, List
import requests
from rdkit.Chem import Draw
from IPython.display import display, HTML
from rdkit.Chem import rdChemReactions as reactions
class RxnInfo(TypedDict):
name: str
reactantSmiles: str