This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from contextlib import ContextDecorator | |
class Stopwatch(ContextDecorator): | |
""" | |
Context manager to time the duration of operations. | |
Example: | |
>>> import time | |
>>> with Stopwatch(timer='wall') as sw: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def si_parse(s): | |
""" | |
Convert a string `s` with SI prefix scaling to a float. | |
Example: | |
>>> si_parse('1k') | |
1000.0 | |
>>> si_parse('1000 mm') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def si_format(number, unit=''): | |
""" | |
Formats a number with the appropriate SI prefix. | |
Example: | |
>>> si_format(500000, unit='B') | |
'500 KB' | |
>>> si_format(2000000, unit='B') | |
'2 MB' | |
>>> si_format(1e-6, unit='m') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Edit or create /etc/apt/preferences | |
Package: firefox | |
Pin: origin "archive.ubuntu.com" | |
Pin-Priority: 999 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
exitcode=1 | |
mountpoints="/run/user/1000/gvfs" | |
#do check if the correct usb mtp device is mounted | |
for mountpoint in $mountpoints/mtp*/; | |
do | |
echo "Testing $mountpoint" | |
sync_folder="$mountpoint/Internal shared storage" | |
#if the device contains a .sync_boox file in internal storage, proceed | |
if test -e "$sync_folder/.sync_boox";then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# choco list --local-only --id-only | |
# Chocolatey v0.10.11 | |
7zip | |
7zip.install | |
adb | |
adobereader | |
android-sdk | |
astrogrep | |
audacity | |
autohotkey.portable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# creates a LaTeX representation of the math for a scipy linregress straight line fit object | |
def fit_latex(fit, precision=2, xname='x', yname='y', xunit='', yunit='', stats_precision=4, show_R2=True, show_standard_error=True): | |
return '${y}={slope}{x}{unit_conversion} {sign} {intercept}{yunit}${stats}'.format(slope=round(fit.slope, precision), | |
intercept=round(abs(fit.intercept), precision), | |
x=xname, | |
y=yname, | |
sign='+' if fit.intercept >= 0 else '-', | |
yunit=r'\,\mathrm{{{}}}'.format(yunit) if yunit else '', | |
unit_conversion=r'\,\frac{{\mathrm{{{yunit}}}}}{{\mathrm{{{xunit}}}}}'.format(yunit=yunit, xunit=xunit) if xunit or yuni |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# systemctl edit getty@tty1 | |
[Service] | |
ExecStart= | |
ExecStart=-/sbin/agetty --autologin user --noclear %I $TERM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import os | |
import locale | |
import subprocess | |
import sys | |
import shutil | |
from dialog import Dialog |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#removes first audio stream without transcoding | |
ffmpeg -i file.mp4 -map 0:0 -map 0:2 -acodec copy -vcodec copy new_file.mp4 | |
#!/bin/bash | |
for name in *.mkv; do | |
ffmpeg -i "$name" -map 0:0 -map 0:2 -acodec copy -vcodec copy "converted/$name" | |
done |
NewerOlder