Skip to content

Instantly share code, notes, and snippets.

@numpde
numpde / update_ip.py
Created January 20, 2019 16:37
Alibaba DNS record update python script
#!/usr/bin/env python3
#coding=utf-8
import subprocess
IP = subprocess.run("dig +short myip.opendns.com @resolver1.opendns.com".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode('UTF-8').split()[0]
print("IP:", IP)
# https://api.aliyun.com/new#/?product=Alidns&api=UpdateDomainRecord&params={}&tab=DEMO&lang=PYTHON
@numpde
numpde / makefile
Created January 22, 2019 07:22
A mechanism to .gitignore large files but keep a list of them on git
help:
@echo Put this script at the root of the git project.
@echo
@echo Add the following lines to the .gitignore file:
@echo " ""**/UV/**"
@echo " ""!**/UV/unversioned"
@echo
@echo Run
@echo " ""make unversioned"
@echo to create the listings of unversioned files in
@numpde
numpde / usualvenv.sh
Created August 11, 2019 23:05
The usual python venv
virtualenv -p python3.7 venv
source venv/bin/activate
pip install pandas numpy sklearn joblib progressbar2 matplotlib
@numpde
numpde / markov.py
Last active October 6, 2021 08:23
# RA, 2020-01-01
from numpy import sqrt, exp
import numpy as np
from scipy.special import binom, erf
import matplotlib.pyplot as plt
# Values of b
bb = [0.1, 0.5, 1.5]
# RA, 2020-01-02
from numpy import sqrt, exp, pi
import numpy as np
from scipy.special import binom
import matplotlib.pyplot as plt
fig: plt.Figure
ax: plt.Axes
@numpde
numpde / the_usual_imports.py
Created January 27, 2020 15:33
The usual "data science" Python imports
import numpy as np
import pandas as pd
import networkx as nx
import re
import json
import pickle
from pathlib import Path
@numpde
numpde / xrates.py
Created April 29, 2020 22:23
Download exchange rates
# RA, 2020-04-30
# Download exchange rates -- template
import json
import urllib.request
from retry import retry
from pathlib import Path
@numpde
numpde / affy_in_python
Last active September 14, 2020 04:35
How to process a CEL file from Python (via R)
# RA, 2020-09-12
# A look at the GSE60880:
# Human Lung Fibroblasts treated with TGFbeta, IL1, EGF and small molecule inhibitors of TGFBR1 and p38.
# HLF cells were incubated with each agent for 0.5 hours, 1 hour, 2 hours or 8 hours in standard conditions
# before total RNA was prepared and hybridised to Affymetrix microarrays.
# https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE60880
from tcga.utils import download
download = download.to(rel_path="download")
@numpde
numpde / view_paper_to_print.sh
Created September 24, 2020 14:31
Display a PDF file in 2x1 portrait format for printing
# Display a PDF file in 2x1 portrait format for printing
pdfjam --nup 2x1 --landscape "file.pdf" --outfile /dev/stdout | \
pdfjam --angle=90 /dev/stdin --outfile /dev/stdout | \
okular -
@numpde
numpde / 20201002_simbio_first.m
Last active October 2, 2020 15:06
SimBiology first script -- modified to index names of species
% 2020-HS Intro Bio Computers
% SimBiology first script -- modified to index names of species
% The trick
index_of = containers.Map();
for i = 1 : length(BioComp_1.Species)
index_of(BioComp_1.Species(i).Name) = i;
end
clear AB;