Skip to content

Instantly share code, notes, and snippets.

@pozitron57
pozitron57 / button.html
Created February 12, 2023 22:21
Change button text onclick and show/hide element.
View button.html
<script>
function toggleHidden() {
document.getElementById("solution").classList.toggle('hidden');
if ( document.getElementById("solution").classList.contains('hidden') ) {
document.querySelector('#btn').innerText = 'Показать решение';
} else {
document.querySelector('#btn').innerText = 'Скрыть решение';
}
}
</script>
View air-length.py
import numpy as np
from sympy import *
from scipy import interpolate
import matplotlib.pyplot as plt
from matplotlib import rc, rcParams
# Plot and save trajectories y(x) for fixed v0, k and varying
# angle α.
# Last line prints an angle corresponding to the maximum length
@pozitron57
pozitron57 / ftr-a-mu.py
Created February 7, 2022 20:04
Plot friction force vs. angle
View ftr-a-mu.py
import numpy as np
# Triginometry {{{
def cos(x): return round( np.cos( np.radians(x) ), 10 )
def sin(x): return round( np.sin( np.radians(x) ), 10 )
def tg(x): return round( np.tan( np.radians(x) ), 10 )
def arctg(x): return np.degrees( np.arctan(x) )
def sins(x): return round( np.sin( np.radians(x) )**2, 10 )
def asin(x): return np.degrees( np.arcsin(x) )
#}}}
View r_t.py
import numpy as np
def cos(x):
return round( np.cos( np.radians(x) ), 10 )
def sin(x):
return round( np.sin( np.radians(x) ), 10 )
def asin(x):
return np.degrees( np.arcsin(x) )
# Plot setup {{{
@pozitron57
pozitron57 / kepler2alpha-1.py
Last active January 2, 2022 19:31
Plot for body launched at alpha to horizon with circular velocity
View kepler2alpha-1.py
import os
import numpy as np
from matplotlib.patches import Ellipse
import matplotlib as mpl
from matplotlib import pyplot as plt
from matplotlib import rc, rcParams
from matplotlib.ticker import AutoMinorLocator, MultipleLocator
from matplotlib.patches import Arc
# Trigonometry {{{
@pozitron57
pozitron57 / neglect.py
Created September 16, 2018 14:06
Literacy vs. physics level
View neglect.py
#! /usr/bin/env python
#coding=utf8
import numpy as np
from matplotlib import rc, rcParams
import matplotlib.pyplot as plt
from matplotlib.ticker import AutoMinorLocator, MultipleLocator
# Plot Setup {{{
rcParams['font.size'] = 16.
@pozitron57
pozitron57 / find-unused-latex-plots.py
Last active June 29, 2018 12:28
Python3 script to find and move unused plots in latex project
View find-unused-latex-plots.py
#! /usr/bin/env python
#coding=utf8
import re, os
path = '/home/slisakov/Dropbox/documents/science/thesis/'
plots = '/home/slisakov/Dropbox/documents/science/thesis/plots/'
used_plots = [] # present in tex
commented_plots = [] # present in tex, commented
@pozitron57
pozitron57 / gridspec.py
Created October 17, 2016 20:09
gridspec in python matplotlib
View gridspec.py
#! /usr/bin/env python
#coding=utf8
from pylab import *
from matplotlib import *
gs = gridspec.GridSpec(2, 1) #subplots ratio
f, (ax1, ax2) = plt.subplots(2, sharex=True)
ax1 = plt.subplot(gs[0, 0])
ax2 = plt.subplot(gs[1, 0])
@pozitron57
pozitron57 / decay.py
Created October 17, 2016 18:46
2-step decay chain Ni→Co→Fe
View decay.py
#coding=utf8
import numpy as np
from matplotlib import *
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from matplotlib.ticker import AutoMinorLocator
from math import exp
from distinct_colors import get_distinct
''' Decay of 56Ni '''
View 2-step decay chain Ni→Co→Fe
#coding=utf8
import numpy as np
from matplotlib import *
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from matplotlib.ticker import AutoMinorLocator
from math import exp
from distinct_colors import get_distinct
''' Decay of 56Ni '''