Skip to content

Instantly share code, notes, and snippets.

View palevell's full-sized avatar

Patrick Allan palevell

View GitHub Profile
@palevell
palevell / Howto.md
Created May 13, 2023 19:07 — forked from brentjanderson/Howto.md
SSH Tunneling with Firefox

Sometimes it is useful to route traffic through a different machine for testing or development. At work, we have a VPN to a remote facility that we haven't bothered to fix for routing, so the only way to access a certain machine over that VPN is via an SSH tunnel to a machine that is reachable over the VPN. Other times, I have used this technique to test internet-facing requests against sites I am developing. It is pretty easy, and if you don't use firefox regularly, you can treat Firefox as your "Proxy" browser and other browsers can use a normal configuration (Although you can also configure an entire system to use the proxy, other articles exists that discuss this potential).

  1. Open a terminal
@palevell
palevell / markdown_parser.py
Last active May 7, 2023 18:07
Parses message.content of OpenAI chat responses
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# markdown_parser.py - Sunday, May 7, 2023
# Via ChatGPT
import os
import re
import sys
import argparse
import subprocess
@palevell
palevell / index.html
Last active April 26, 2023 00:48
ChatGPT Responsive Home Page #1
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<title>My Blog Homepage</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
@palevell
palevell / idle_accts_cshell_eh.md
Last active June 13, 2020 01:19
Idle Accounts Followed by @cshell_eh
@palevell
palevell / tpoff.sh
Last active February 9, 2020 15:45
Creates BASH aliases for toggling laptop touch devices ON/OFF
#!/usr/bin/env bash
# tpoff.sh v1.0.9 - Sunday, February 9, 2020
# Create commands (aliases) to toggle touch devices ON/OFF
XINPUT=/usr/bin/xinput
if [ -x $XINPUT ]; then
DEVNAMES=()
DEVNAMES+=("Synaptics TouchPad")
DEVNAMES+=("AlpsPS/2 ALPS DualPoint TouchPad")
DEVNAMES+=("AlpsPS/2 ALPS DualPoint Stick")
@palevell
palevell / filename2long.patch
Created January 14, 2020 15:33
This patch fixes 'Filename too long' errors when video titles are too long for the filesystem.
*** /usr/local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py 2020-01-14 08:51:17.908524990 -0500
--- youtube_dl/YoutubeDL.py 2020-01-14 09:06:18.785934554 -0500
***************
*** 635,640 ****
--- 635,646 ----
try:
template_dict = dict(info_dict)
+ ##### 2020-Jan-13 PAL - Fix 'Filename too long errors' - BEGIN
+ if 'title' in template_dict.keys():
@palevell
palevell / update_settings
Created December 28, 2019 21:31
This is a utily script to update the settings.py file in Django projects, based on the contents of the .env file. It also adds code for dotenv support.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# update_settings - Monday, December 23, 2019
__version__ = '1.1.10'
import os, re
from glob import glob
from os.path import basename, dirname, exists, getmtime, join
@palevell
palevell / utils.py
Created December 28, 2019 21:06
Plugging Tweepy into the Django-Allauth package was easier than I thought.
# utils.py - Saturday, December 28, 2019
# -*- coding: utf-8 -*-
""" I have been experimenting to see which web framework would make the better
wrapper for Tweepy. I decided on Django, with the Allauth package.
Afer going through the Django-Allauth Tutorial at
https://wsvincent.com/django-allauth-tutorial/ and playing with the DjangoTweepy repository at
https://github.com/martinjc/DjangoTweepy/blob/master/src/twitter_auth/utils.py,
this is what I contrived.
@palevell
palevell / crypto03.py
Created December 17, 2019 11:00
This is the best example of Fernet encryption that I have found.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# crypto03.py - Monday, December 16, 2019
# Ref: https://www.thepythoncode.com/article/encrypt-decrypt-files-symmetric-python
""" This is the best example of Fernet encryption that I have found """
__version__ = '1.0.0'
from datetime import datetime
from shutil import copy2
@palevell
palevell / patch.diff
Created November 18, 2019 14:12
this is a patch to fix 'Cannot write' errors related to long tweets
diff --git a/youtube_dl/extractor/twitter.py b/youtube_dl/extractor/twitter.py
index 5f8d90fb4..3cf8e408b 100644
--- a/youtube_dl/extractor/twitter.py
+++ b/youtube_dl/extractor/twitter.py
@@ -392,6 +392,10 @@ class TwitterIE(TwitterBaseIE):
title = description = status['full_text'].replace('\n', ' ')
# strip 'https -_t.co_BJYgOjSeGA' junk from filenames
title = re.sub(r'\s+(https?://[^ ]+)', '', title)
+ # 2019-Nov-18 PAL - BEGIN Truncate long tweets to prevent 'Cannot write' errors
+ if len(title) > 200: