Skip to content

Instantly share code, notes, and snippets.

View antonkratz's full-sized avatar

Anton Kratz antonkratz

View GitHub Profile
@antonkratz
antonkratz / avoid.txt
Last active February 8, 2024 08:36
An optic for stract
Rule {
Matches { Url("reddit.com") },
Matches { Url("quora.com") },
Matches { Url("vice.com") },
Matches { Url("9to5mac.com") },
Matches { Url("techdirt.com") },
Action(Discard)
};
@antonkratz
antonkratz / UTM.sh
Created November 14, 2023 02:54
quick fixes to Ubuntu under UTM
# When the network is down
sudo ip link set dev enp0s1 down
sudo ip link set dev enp0s1 up
# When the clock gets out of sync
sudo service ntp stop
sudo ntpd -gq
sudo service ntp start
@antonkratz
antonkratz / redact.md
Last active June 28, 2023 08:05
readact, flatten, PDF, Ubuntu

There is a sensitive document. Credit card statements. Reimbursement.

I want to redact (hide) parts of the document.

  1. Create a pitch black highlighter pen in Okular. Highlight the relevant text in black.
  2. The text is still there and can easily be seen, for example by highlighting (in the sense of Ctrl-A) the entire document.
  3. To flatten = actually remove the text beneath the black highlights:

pdf2ps in.pdf - | ps2pdf - out.pdf

@antonkratz
antonkratz / google.md
Last active January 12, 2023 06:00
Google Hacks

Google Hacks: Gmail, Docs

Gmail

Bookmarks to emails are persistent

You can bookmark individual emails. The bookmarks are persistent, apparently indefinitely (works for me with bookmarks made several years ago).

Add a 30 second delay before the email is actually sent

@antonkratz
antonkratz / symlog_trans.R
Created May 31, 2022 18:14 — forked from davidtedfordholt/symlog_trans.R
A `scales`/`ggplot2` implementation of the `symlog` transformation
#' symlog transformation
#'
#' `symlog_trans()` transforms data using `log(x)` for `abs(x) > thr`, where
#' `thr` is a tuneable threshold, but leaves the data linear for `abs(x) < thr`.
#' (credit for base code to https://stackoverflow.com/users/1320535/julius-vainora)
#'
#'
#' @param base base of logarithm
#' @param thr numeric threshold for transitioning from log to linear
#' @param scale numeric scaling factor for data
@antonkratz
antonkratz / repelling_labels.r
Created August 17, 2021 23:14
Getting coordinates for the label locations from ggrepel, Cytoscape, https://stackoverflow.com/questions/45065567/getting-coordinates-for-the-label-locations-from-ggrepel, tested and works under R 4.1.1
x = c(0.8846, 1.1554, 0.9317, 0.9703, 0.9053, 0.9454, 1.0146, 0.9012, 0.9055, 1.3307)
y = c(0.9828, 1.0329, 0.931, 1.3794, 0.9273, 0.9605, 1.0259, 0.9542, 0.9717, 0.9357)
ShortSci = c("MotAlb", "PruMod", "EriRub", "LusMeg", "PhoOch", "PhoPho",
"SaxRub", "TurMer", "TurPil", "TurPhi")
df <- data.frame(x = x, y = y, z = ShortSci)
library(ggplot2)
library(ggrepel)
p1 <- ggplot(data = df, aes(x = x, y = y)) + theme_bw() +
geom_text_repel(aes(label = z),
@antonkratz
antonkratz / getSmiles.py
Last active October 1, 2021 19:02
From drug NAME to SMILE string
import pubchempy as pcp
import pandas as pd
import numpy as np
from collections import OrderedDict
drugs_df = pd.read_csv('oli_drugs.csv')
def queryPubChem(compounds,batchlist = None,match='name'):
"""
This function queries the PubChem database to retrieve both the isomeric smile and CID of a compound.
@antonkratz
antonkratz / gist:f3a7d8564044830be2d3ccf09fde199e
Created July 14, 2020 18:54
how to remove all clipping masks in Illu!
Select All
`Object > Clipping mask > Release`
`Object > Path > Clean up`
Clipping masks. Deleting an object deletes random objects scattered throughout b.c they are connected thru the clipping mask. I do not want this.
@antonkratz
antonkratz / annoyance.md
Last active September 7, 2019 17:52
how to fix: conda adds an uncalled for `(base)` before my PS1 prompt
@antonkratz
antonkratz / gist:eec1507d7efb77da25217af0638d1d01
Last active September 3, 2019 16:30
[a mighty AWK script] pull out the lines from the table which match a key from a list

file1: A list of keys, one key one line

file2: A table, the keys are in column 1

what this does: pull out the lines from the table which match a key from a list

time awk -F'      ' 'NR==FNR{c[$1]++;next};c[$1] > 0' file1 file2 > output.txt