Skip to content

Instantly share code, notes, and snippets.

View sc0tt's full-sized avatar
🍦
grinding

Scott Adie sc0tt

🍦
grinding
View GitHub Profile
@sc0tt
sc0tt / gpt_sort.py
Last active March 31, 2023 02:54
I needed to sort around 5k files into different directories based on extension. I used this to try out ChatGPT.
import shutil
import json
from pathlib import Path
# Define the source and destination directories
source_dir = Path('root')
destination_dir = Path('root_sorted')
# Define the mappings between file extensions and categories
category_mappings = {
@sc0tt
sc0tt / lounge.service
Created November 13, 2019 14:41
Lounge Service
# Save this file as:
# /etc/systemd/system/lounge.service
#
# Then run:
# systemctl enable lounge.service
#
# Then run:
# systemctl start lounge
#
# If something isn't working or you want to make sure it is working, you can see the output by running:
@sc0tt
sc0tt / formvalidation.py
Last active January 25, 2016 01:10
Converts a WTForms form to JSON which http://formvalidation.io/ accepts. May become a library in the future.
from wtforms.validators import DataRequired, Length, Email, UUID, MacAddress, EqualTo, Regexp
def convert_form_to_json(form):
def convert_field_to_json(field):
validations = {}
for val in field.validators:
validation_type = val.__class__
if validation_type not in validation_types:
raise Exception('Unknown validator')
validations[validation_types[validation_type]['type']] = {}
@sc0tt
sc0tt / webm.md
Last active August 29, 2015 14:24 — forked from ndarville/webm.md

Grab ffmpeg from https://www.ffmpeg.org/download.html

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
### Keybase proof
I hereby claim:
* I am sc0tt on github.
* I am sc0tt (https://keybase.io/sc0tt) on keybase.
* I have a public key whose fingerprint is 4FDE 9BAC 0401 F8D7 4780 85C3 AE61 77CB 40DC 6C46
To claim this, I am signing this object:
@sc0tt
sc0tt / pokeparser.py
Created September 23, 2014 01:55
Parses the pokemon tcg website.
import re
import time
from selenium import webdriver
# You will need to have the phantomjs exe in your path or alongside this script.
driver = webdriver.PhantomJS()
current_page = 0
total_pages = -1
Sentence:
That is a really cool fire truck you got there!
Left side is a key, right is a value
That is a -> really cool fire
is a really -> cool fire truck
a really cool -> fire truck you
really cool fire -> truck you got
cool fire truck -> you got there!
@sc0tt
sc0tt / picker.py
Created July 12, 2014 12:49
Player picker
import random
name_list = None
with open("names.txt") as name_file:
name_list = [n.strip() for n in name_file.readlines()]
if len(name_list) % 2:
exit("Number of Players is not Even")
with open("out_names.txt", "w") as out:
<?php
$this->log($data);
Cakelog::write('error', $data);
// If $data is an array
Cakelog::write('error', print_r($data, true));
?>
@sc0tt
sc0tt / domain.net
Created March 1, 2014 02:11
nginx config for a site under gunicorn
server {
listen 80;
server_name subdomain.domain.net;
access_log /path/to/access.log;
error_log /path/to/error.log;
location / {
proxy_pass http://127.0.0.1:8001/;
proxy_redirect off;