Skip to content

Instantly share code, notes, and snippets.

View cdeitrick's full-sized avatar

Christopher Deitrick cdeitrick

View GitHub Profile
@cdeitrick
cdeitrick / Download OneDrive files in terminal.txt
Created March 16, 2024 21:10
Download OneDrive files in terminal
Google Chrome as well as Mozilla Firerfox both provide an option to copy download link specifically for cURL. This option will generate cURL with all required things such as User agent for downloading things from the side. To get that,
1. Open the URL in either of the browser.
2. Open Developer options using Ctrl+Shift+I.
3. Go to Network tab.
4. Now click on download. Saving file isn't required. We only need the network activity while browser requests the file from the server.
5. A new entry will appear which would look like "download.aspx?...".
6. Right click on that and Copy → Copy as cURL.
7. Paste the copied content directly in the terminal and append --output file.extension to save the content in file.extension since terminal isn't capable of showing binary data.
@cdeitrick
cdeitrick / channel_to_array
Last active October 13, 2023 01:14
Pillow code to convert a single channel into an RGB array
def convert_to_rgb_array(channel: numpy.ndarray, rgb_base: Tuple[int, int, int], alpha: None | float | int | numpy.ndarray = None,
mode: Literal['RGB', 'RGBA'] = 'RGB') -> numpy.ndarray:
"""
Parameters
----------
channel: numpy.ndarray
A 2D floating-point array with values in the range [0, 1]
rgb_base: Tuple[int,int,int]
A single rgb color which will be used as the base color of the array.
The resulting color of each pixel is generated by multiplying the pixel value by `rgb_base`.
# Install packages suggested by apt when install a program.
apt-get -o APT::Install-Suggests="true" install {package}
@cdeitrick
cdeitrick / mp3gain
Created February 26, 2023 02:49
mp3gain
Take a look @ mp3gain which for me is even better than normalize-audio
mp3gain -r *.mp3
another useful version could be the -c which prevent to ask if you want to do the changes for many files:
mp3gain -c -r *.mp3
@cdeitrick
cdeitrick / code_snippets_for_data
Created January 5, 2023 04:53
Code Snippets for Data
# Size in memory of a numpy array
array_size = array.size
array_itemsize = array.itemsize
array_total = array_size * array_itemsize
@cdeitrick
cdeitrick / matplotlib_snippets
Last active May 21, 2025 15:39
Matplotlib Snippets
#Add padding to a figure after the plot is generated
plt.gcf().subplots_adjust(left = 0.30)
########################### Change grid spacing ################################
import numpy as np
import matplotlib.pyplot as plt
@cdeitrick
cdeitrick / Download all links within an rss file
Created September 6, 2022 04:33
Download all links within an rss file
@cdeitrick
cdeitrick / enable_right_click.txt
Created August 29, 2022 23:00
Enable Right Click
javascript:void(document.oncontextmenu=null);
@cdeitrick
cdeitrick / matplotlib_snippets.py
Last active November 21, 2023 17:53
Matplotlib Snippets
# Change ticklabel size
plt.yticks(fontsize=20)
ax.tick_params(axis='x', labelsize=20)
# Remove tick labels
ax.xaxis.set_visible(True)
ax.axis('off')
ax.set_axis_off()
ax.get_xaxis().set_visible(False)
@cdeitrick
cdeitrick / change_mp3_bitrate
Created July 29, 2022 13:04
Change mp3 bitrate
ffmpeg -i input.file -map 0:a:0 -b:a 96k output.mp3