Skip to content

Instantly share code, notes, and snippets.

View lelandbatey's full-sized avatar

Leland Batey lelandbatey

View GitHub Profile
@lelandbatey
lelandbatey / scrap.tf-scraper.py
Last active December 13, 2015 19:58
Short and dirty page scraper to tell you the different hats that are available on http://scrap.tf. Loops on a ten second delay. If this in any way causes problems for the scrap.tf guys, I'll take it down. However, it's a super useful tool for other fellow hat-hounds.
View scrap.tf-scraper.py
#scrap.tf-scraper.py
import urllib2
from bs4 import BeautifulSoup
import time
def getItemDivs(url):
opener = urllib2.build_opener()
# For this to work, you need to paste your scrap.tf cookies into here. I used the following javascript bookmarklet to get the cookies:
# javascript:void(document.cookie=prompt(document.cookie,document.cookie));
@lelandbatey
lelandbatey / pull-all-gits.sh
Last active December 13, 2015 23:19
Recursively "git pull" all git directories
View pull-all-gits.sh
#!/bin/bash
# Finds all directories named "".git"
# Strips the ".git" from the path produced by 'find'
# passes that master-folder to xargs which cd's into that directory and runs "git pull"
find ~/ -name ".git" -type d | sed 's,/*[^/]\+/*$,,' | xargs -L1 bash -c 'cd "\$1" && git pull' _
@lelandbatey
lelandbatey / gifConvert.sh
Last active February 5, 2016 09:29
Convert video to .gif really easily. See this commit to my help files as an example: https://github.com/lelandbatey/configDebDev/blob/master/helpFiles.txt#L113
View gifConvert.sh
#!/bin/bash
#Alright, so this should automatically convert a given video into a gif called optimized_output.gif
# See here for explanation: https://github.com/lelandbatey/configDebDev/blob/master/helpFiles.txt#L113
ffmpeg -i $1 out%04d.gif # Extracts each frame of the video as a single gif
convert -delay 4 out*.gif anim.gif # Combines all the frames into one very nicely animated gif.
convert -layers Optimize anim.gif optimized_output.gif # Optimizes the gif using imagemagick
# vvvvv Cleans up the leftovers
@lelandbatey
lelandbatey / tf2ItemsJsonGenerator.py
Created May 19, 2013 23:14
Generates a json file with the item-ids of all tradable items as the keys, and the corresponding item names as the values. Very "hacky" in it's approach to getting the right data that it needs, but it gets the job done. Might break in the future.
View tf2ItemsJsonGenerator.py
from __future__ import print_function
from pprint import pprint
import json
# What do I need?
# This requires two files: tf2ItemsFile and tf2PricesJson.
# tf2ItemsFile
# A copy of the "current client item schema" for tf2. This can either be found
@lelandbatey
lelandbatey / tf2_Item_names_with_ids.json
Created May 19, 2013 23:21
Json dictionary of all tradable items in tf2, with the ids as the keys, and the names as the values.
View tf2_Item_names_with_ids.json
{
"100": "Glengarry Bonnet",
"1000": "Festive Axtinguisher",
"1001": "Festive Buff Banner",
"1002": "Festive Sandvich",
"1003": "Festive Ubersaw",
"1004": "Festive Frontier Justice",
"1005": "Festive Huntsman",
"1006": "Festive Ambassador",
"1007": "Festive Grenade Launcher",
@lelandbatey
lelandbatey / ytwatch.sh
Last active December 29, 2015 01:38
ytwatch.sh - For when you don't want to deal with the Youtube interface. Script to automatically download a Youtube video then open it in VLC media player.
View ytwatch.sh
#!/bin/bash
#This requires:
# youtube-dl (pip install youtube-dl)
# vlc (sudo apt-get install vlc)
#
# Usage:
#
# ytwatch http://www.youtube.com/watch?v=dMH0bHeiRNg
#
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active February 25, 2024 13:47
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!
View whiteboardCleaner.md

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@lelandbatey
lelandbatey / yt1080.md
Last active October 21, 2023 16:31
YouTube 1080p Download Script
View yt1080.md

YouTube 1080p Downloader

The Problem

It used to be you could directly download any YouTube video in any quality you wanted, as a single .mp4 file. However, around a year ago, YouTube switched from the "single file stream", to "DASH" streaming, which streams the video and the audio to you as two separate streams, which are played in sync with each other in the YouTube player.

It's still possible to download YouTube videos as a single file, but YouTube only offers that for qualities up to 720p. So you can't download "single file stream" videos in 1080p or higher.

@lelandbatey
lelandbatey / ffmpeg-compile.sh
Created June 21, 2014 23:53
Auto-compile ffmpeg
View ffmpeg-compile.sh
#!/bin/bash
# Auto-compiles and installs ffmpeg, as per the official instruction:
# https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
#
# Only up to date as of June 21st, 2014
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev \
@lelandbatey
lelandbatey / recursive_link_grab.py
Last active October 15, 2021 23:59
Recursive link gatherer -- great for `wgetting` an Apache directory
View recursive_link_grab.py