Skip to content

Instantly share code, notes, and snippets.

View karhunenloeve's full-sized avatar
🐍
Parselmouth

karhunenloeve karhunenloeve

🐍
Parselmouth
View GitHub Profile
@karhunenloeve
karhunenloeve / 7C.py
Created July 25, 2023 12:42 — forked from Chgtaxihe/7C.py
Codeforces Number Theory #Codeforces
def exgcd(a, b):
if 0 == b:
return 1, 0, a
x, y, q = exgcd(b, a % b)
x, y = y, (x - a // b * y)
return x, y, q
def main():
a, b, c = map(int, input().split())
#!/usr/bin/env python3
#
# Crypto & Number Theory
# N. P. O'Donnell, 2020
def odd(a):
"""
Is a odd?
"""
def factorint(n):
d = {}
p = 2
while p * p <= n:
while n % p == 0:
if p not in d:
d[p] = 0
d[p] += 1
n //= p
p += 1
@karhunenloeve
karhunenloeve / data.txt
Last active September 13, 2022 10:27 — forked from dasmithii/_SpringerMATH
A list of a bunch of math textbooks recently made free by Springer, plus some code to batch download them all. Put all these files in in a directory. Run downloader.go. Then you'll have #.pdf's all over the place. Run mut.py to generate an index of PDF's. Then move 'em wherever you'd like.
http://link.springer.com/content/pdf/10.1007/978-1-4757-1779-2.pdf
A Classical Introduction to Modern Number Theory
Kenneth Ireland, Michael Rosen
http://link.springer.com/content/pdf/10.1007/978-1-4757-2103-4.pdf
A Classical Introduction to Modern Number Theory
Kenneth Ireland, Michael Rosen
http://link.springer.com/content/pdf/10.1007/978-1-4684-9884-4.pdf
A Course in Arithmetic
@karhunenloeve
karhunenloeve / latex_bib_downloader.py
Last active September 13, 2022 10:21 — forked from haccanri/bib_downloader.py
A script to extract title from hand-written bib items and download the bibtex item from Google Scholar.
from subprocess import Popen, PIPE
import time
def extract_title(texFile, output='title.txt'):
lines = ''.join(open(texFile).readlines())
papers = lines.split('\\bibitem')
titles = []
for p in papers:
if p.strip() == '':
@karhunenloeve
karhunenloeve / simplicial_homology.py
Last active September 13, 2022 08:40 — forked from RCHowell/homology.py
Computing the Homology of a Simplicial Complex.
import numpy as np
import functools as func
import itertools as itertools
# spcx::Set<Tuple> --> int
def vertex_count(spcx):
# Reduce Set to max value amongst Tuples in the set
return func.reduce(lambda acc, e: max(acc, max(e)), spcx, 0) + 1
# spcx::Set<Tuple>, n::int --> Dict<Tuple, int>
@karhunenloeve
karhunenloeve / representations.py
Created September 13, 2022 08:39 — forked from HiddenBeginner/representations.py
A Giotto-tda compatible implementation of persistence vectors introduced in [C. Bresten & J.-H Jung, 2019].
import numpy as np
from joblib import Parallel, delayed, effective_n_jobs
from gtda.utils.intervals import Interval
from gtda.utils.validation import validate_params, check_diagrams
from gtda.diagrams._utils import _subdiagrams, _bin, _make_homology_dimensions_mapping, _homology_dimensions_to_sorted_ints
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.utils import gen_even_slices
from sklearn.utils.validation import check_is_fitted
@karhunenloeve
karhunenloeve / AutoencoderTest.ipynb
Last active September 13, 2022 08:34 — forked from ctralie/AutoencoderTest.ipynb
Experiments with autoencoders of MNIST Data in pytorch, with a visualization of projection to 2D latent space.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@karhunenloeve
karhunenloeve / latex_markdown.md
Last active June 11, 2022 19:29
A hack for showing LaTeX formulas in GitHub markdown.

Showing LaTeX Formulas in Markdown

A lot of GitHub projects need to have pretty math formulas in READMEs, wikis or other markdown pages. The desired approach would be to just write inline LaTeX-style formulas like this:

$e^{i \pi} = -1$

Unfortunately, GitHub does not support inline formulas. The issue is tracked here.

Investigation

@karhunenloeve
karhunenloeve / git-pushing-multiple.md
Last active May 2, 2022 11:22 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync. Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go. If in doubt about what git is doing when you run these commands, just edit .git/config (git-config(1)_) and see what it's put there.

Remotes

Suppose your git remotes are set up like this::

    git remote add github git@github.com:karhunenloeve/my-project.git
 git remote add bb git@gitlab.org:cckarhunenloeve/my-project.git