Skip to content

Instantly share code, notes, and snippets.

View pigeonflight's full-sized avatar

David Bain pigeonflight

View GitHub Profile
@pigeonflight
pigeonflight / README.md
Last active March 10, 2024 14:43
This is an ugly script to just extract/unpack the ICD-11 codes from a local docker instance of the ICD-11 api

Assumptions

You have Python. You've installed the requests library. You have docker on your machine.

Usage

  1. Launch the ICD-11 docker container
docker run -p 80:80  --env "acceptLicense=true" --env "saveAnalytics=true" --env "includeIp=false" whoicd/icd11_sw_1904_mms_en
@pigeonflight
pigeonflight / cleanup-querystrings.py
Created October 22, 2017 10:39
remove query strings on static resources downloaded with wget
"""
Often after performing a wget -p -k http://example.com
The resulting files will include static resources with query strings appended.
For example:
wp-content/themes/salient/css/fonts/fontawesome-webfont.woff?v=4.2
etc..
This script strips away the query strings so that you can serve the site statically.
This is the first step in porting a theme from another CMS to a Diazo based Plone theme
"""
import os
@pigeonflight
pigeonflight / setup-postgresql-for-current-user.md
Created August 31, 2019 20:41
When working with postgresql on local machine, you don't need a password

Install postgresql and create a user and database. The trick is to give the database and user the same name as the current user

sudo apt-get install postgresql
sudo su - postgres -c "psql  -c \"create user $USER;\""
sudo su - postgres -c "createdb $USER"

Now as the current user you have your own personal database which doesn't require a password. Great for development.

@pigeonflight
pigeonflight / icd11-code-interpreter.py
Last active January 7, 2023 08:26
ICD-11 Code Interpreter . This python script passes an ICD-11 code cluster and returns the interpretation (in English only at the moment)
import requests
import sys
#uri = 'http://localhost/icd/release/11/2019-04/mms/codeinfo/'
base_uri = 'http://localhost/icd/release/11/2019-04/mms/codeinfo/{}'
mms_uri = 'http://localhost/icd/release/11/2019-04/mms{}'
cluster_output = []
last_splitter = ""
try:
sample_cluster_code = sys.argv[1]
except IndexError:
@pigeonflight
pigeonflight / install-python-2.7.14.sh
Created May 22, 2018 11:19
Install Python 2.7.14 on Ubuntu 14.04
# usage
# bash install-python-2.7.14.sh
sudo apt-get update
sudo apt-get install build-essential checkinstall -y
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -y
cd /usr/src
sudo wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz
sudo tar xzf Python-2.7.14.tgz
cd Python-2.7.14
sudo ./configure --enable-optimizations
@pigeonflight
pigeonflight / README.rst
Created April 16, 2017 04:22
Script to mount hetzner backup space

Setup

All commands here are run as root Install sshfs and autofs :

apt-get update
apt-get install sshfs autofs

Ensure you have an ssh key:

@pigeonflight
pigeonflight / EventView.jsx
Last active January 17, 2022 07:09
example of relatedItems on an EventView
/**
* EventView view component.
* @module components/theme/View/EventView
*/
import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import { flattenHTMLToAppURL } from '@plone/volto/helpers';
import { Container, Image, Segment, Header, List } from 'semantic-ui-react';
@pigeonflight
pigeonflight / buildout.cfg
Created July 7, 2021 01:45
Valid buildout.cfg for Senaite LIMS July 6, 2021
[buildout]
extends =
base.cfg
versions.cfg
# http://dist.plone.org/release/4.3.19/versions.cfg
# If you change your Plone version, you'll also need to update
# the repository link below.
find-links +=
http://dist.plone.org/release/4.3.19
@pigeonflight
pigeonflight / main.py
Created July 6, 2021 13:11
Fast API with deta.sh and Paypal IPN (first working test)
from fastapi import FastAPI, Request
import sys
import urllib.parse
import requests
app = FastAPI()
VERIFY_URL_PROD = 'https://ipnpb.paypal.com/cgi-bin/webscr'
VERIFY_URL_TEST = 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr'
# Switch as appropriate
@pigeonflight
pigeonflight / README.md
Last active April 22, 2021 05:40
Python script to remove unused images from a web project folder, works for webflow projects but should work in other circumstances as well

Background

This is a horribly ugly (and lazy) implementation. The goal is to remove images that are not referenced by either the css or html files of a web project.

Additionally it converts large png files (Large png is bigger than 250000 bytes) into jpg files since these are most often photographs. It then goes into each file and replaces the reference to the png with the reference to the jpg file. Finally, it removes the old png files to reduce the overall site folder size. It also skips externally stored images.

The script includes a 'sed-like' function based on something found at stackoverflow (https://stackoverflow.com/questions/12714415/python-equivalent-to-sed/40843600#40843600)

Assumption