Skip to content

Instantly share code, notes, and snippets.

View matteoferla's full-sized avatar

Matteo Ferla matteoferla

View GitHub Profile
@matteoferla
matteoferla / job.sh
Last active October 12, 2023 13:02
Example of how I run a Fragmenstein analysis in Diamond
#! bin/bash
# For scripts required see: https://gist.github.com/matteoferla/e0496d5766c12a0ae1738b943b41a536
# A few things don't work in CentOS 7 due to GNU lib C (glibc) 2.17, so it has to be run in a Singularity container
: << USAGE
export JOB_SCRIPT=/data/xchem-fragalysis/shared/singularity.sh;
export APPTAINER_CONTAINER=/data/xchem-fragalysis/shared/singularity/rockyplus.sif;
export JOB_INNER_SCRIPT=/data/xchem-fragalysis/mferla/Zika/job.sh;
condor_submit /data/xchem-fragalysis/shared/target_script.condor
@matteoferla
matteoferla / wooden_gcode_wobble.py
Created August 24, 2023 11:09
Add random M104 codes to a gcode for a 3D print in wood PLA to make stripes (old script, may be better out there)
# Randomize layer temperatures for wood PLA.
import argparse
import re
import random
import os
gcode_folder = '../../3DPrints/gcodes/'
filename = 'scrabble_hold_10v3.gcode'
@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 / 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 / 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