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 requests # pip install requests | |
# Adapted from answer at: https://stackoverflow.com/questions/16694907/download-large-file-in-python-with-requests | |
def download(url, filepath): | |
with requests.get(url, stream=True) as response: | |
response.raise_for_status() | |
with open(filepath, 'wb') as output_file: | |
for chunk in response.iter_content(chunk_size=8192): | |
# If you have chunk encoded response, then uncomment | |
# the `if` statement and set chunk_size parameter to `None`. |
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
<?php | |
/** | |
* Given a directory full of gzipped AVI files, | |
* outpu a JSON array with the list of zipped video files in the dir. | |
* | |
* If a GET query param is provided for `file` then that specific | |
* file is returned, uncompressed, with the .gz extension removed | |
*/ | |
if (isset($_GET['file'])) { |
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/sh | |
# Requires executable bit | |
# Move to `/etc/grub.d/99_dano_grub_colors` | |
# and run `sudo update-grub` | |
echo "set menu_color_normal=light-cyan/dark-gray" | |
echo "set menu_color_highlight=dark-gray/light-cyan" | |
echo "set color_normal=white/black" | |
echo "set color_highlight=black/white" | |
# To change image, update `/etc/default/grub` with the image path |
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/bash | |
sudo apt install -y cifs-utils | |
# `uid` and `gid` is the local Linux user and group you want to mount as | |
# `user` and `password` are the SMB drive credentials. Wrap password with quotes if necessary. | |
sudo mount -t cifs -o uid=dano,gid=sudo,user=dano,password="my password" \\\\10.0.0.99\\home /mnt |
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
from requests import get # pip install requests | |
""" | |
Examples: | |
Docs: | |
- Create email (add_pop): https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Email%3A%3Aadd_pop | |
- Delete email (delete_pop): https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Email%3A%3Adelete_pop | |
- Change pass (passwd_pop): https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Email%3A%3Apasswd_pop |
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
""" | |
Create a user on the Openfire XMPP server | |
Enable REST API by logging into admin portal (e.g. https://xmpp.devdungeon.com:9090) and go to `Plugins` and then `Available Plugins`. Enable the `REST API`. | |
Then go to `Server | Server Settings | REST API` and change it to `Enabled`. | |
Choose `Secret key auth` option and store that key. | |
(http 9090, https 9091) | |
POST https://example.org:9091/plugins/restapi/v1/users |
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
""" | |
Copy your SSH public key into a remote | |
host's `~/.ssh/authorized_keys` file. | |
pip install paramiko | |
Usage: ssh-copy-id.py <host> <username> | |
""" | |
from paramiko import SSHClient, AutoAddPolicy | |
import sys |
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 | |
# Healthy Reminders | |
# | |
# Setup a cron job to remind you to do healthy things | |
# Install dependency with: `sudo apt install libnotify-bin` | |
# | |
# Usage: remind.sh "Time to hydrate." | |
# | |
# Some cron examples (`crontab -e`): | |
# 0 * * * * /home/dano/Healthy-Reminders/remind.sh "Time to stand up." |
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 python | |
""" | |
Extract images from a PDF | |
Modified from original at https://www.geeksforgeeks.org/how-to-extract-images-from-pdf-in-python/ | |
pip install fitz frontend pymupdf | |
""" | |
import fitz | |
import io | |
from PIL import Image |
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 ruby | |
require 'net/http' | |
BACKUP_DESTINATION_DIR = '/home/nanodano/mc_backup_rotate/backup_test' | |
DISCORD_WEBHOOK_URL = '' | |
DIR_TO_BACKUP = '/home/nanodano' | |
DB_USER = 'username' | |
DB_HOST = '127.0.0.1' | |
DB_NAME = 'dbname' | |
DB_PASS = 'password' |