Skip to content

Instantly share code, notes, and snippets.

View chand1012's full-sized avatar

Chandler chand1012

View GitHub Profile
@chand1012
chand1012 / requirements.txt
Created February 8, 2021 17:51
Gistbin requirements
certifi==2020.12.5
chardet==4.0.0
idna==2.10
RandomWords==0.3.0
requests==2.25.1
urllib3==1.26.3
@chand1012
chand1012 / test.py
Created February 8, 2021 17:46
this is a test
# name: test.py
# desc: this is a test
# public: true
print("Hello world!")
@chand1012
chand1012 / npr_char.py
Created February 3, 2021 15:13
Gets the number of permutations for alphanumeric ASCII characters in the range of 5 thought 12, totalled.
import string
# this part is from here: https://www.geeksforgeeks.org/program-to-calculate-the-value-of-npr/
# START Geeksforgeeks snippet
import math
def fact(n):
if (n <= 1):
return 1
return n * fact(n - 1)
@chand1012
chand1012 / buffersize.py
Last active September 6, 2021 04:37
File to test the buffer size for os.read. Requires humanize to be installed. See here for license: https://chand1012.mit-license.org/
import os
import sys
import humanize
file_path = sys.argv[1]
size = os.path.getsize(file_path)
print(f'Size in bytes: {humanize.naturalsize(size, binary=True)}')
video = os.open(file_path, os.O_RDONLY)
@chand1012
chand1012 / twitch_streamer_videos_json.py
Last active September 6, 2021 04:39
Requires Twitch-Python. Gets all of the top streamer's videos as JSON and outputs a JSON file with the information. See the license here: https://chand1012.mit-license.org/
import os
import json
from twitch import Helix
from twitch.helix.models.video import Video
def video_to_dict(video: Video):
return {
'id': video.id,
'user_id': video.user_id,
@chand1012
chand1012 / rand_err.py
Created January 13, 2021 15:43
Random error generator designed to make really confusing random errors.
# From my friend Alex
import math, random
Errors = [
"Error",
"Log",
"File",
"Creation",
"Pressure",
@chand1012
chand1012 / twitch_chat_json.py
Last active September 6, 2021 04:38
Get all of the twitch chat from a twitch VOD. See license here: https://chand1012.mit-license.org/
import os
import json
from twitch import Helix
from twitch.v5.models.comment import Comment
def comment_to_dict(comment: Comment):
return {
'id': comment.id,
'created_at': comment.created_at,
import os
from tqdm import tqdm
import requests
from bs4 import BeautifulSoup
base_url = "http://www.textfiles.com/etext/"
endings = ['MODERN', 'FICTION', 'NON-FICTION', 'REFERENCE']
if not os.path.exists('files'):
@chand1012
chand1012 / linting.yml
Created December 4, 2020 06:21
GitHub Actions Linting Script. Could also be configured to create a PR if needed.
name: Python Linting
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
@chand1012
chand1012 / home_dir_example
Created August 10, 2020 19:52
Example of listing your home directory
Desktop
Documents
Downloads
Music
Pictures
Public
Templates
Videos