Skip to content

Instantly share code, notes, and snippets.

View KyleJamesWalker's full-sized avatar
😃
Hello!

Kyle James Walker (he/him) KyleJamesWalker

😃
Hello!
View GitHub Profile
@KyleJamesWalker
KyleJamesWalker / quick_rename.py
Last active August 29, 2015 14:15
Batch Rename as Parent Directory
import os
def main():
'''Stupidly simple script to rename all files to the name of their
parent_dir directory.
Warning: Be careful when running, this could be bad... Also
make sure your current directory doesn't have anything in
it but folders. Otherwise they'll get renamed to ..extention
@KyleJamesWalker
KyleJamesWalker / rangecounter.py
Created February 7, 2015 01:07
rangecounter.py
'''
Simple class for counting number of occurances in each of the given ranges.
'''
class RangeCounter(object):
def __init__(self, range_list):
# Verify range is sorted
self.range_list = sorted(range_list)
self.counter = [0] * (len(range_list) + 1)
def add(self, view_count):
# -*- coding: utf-8 -*-
import argparse
import gzip
import logging
import logging.config
import os
import sys
import zipfile
logger = logging.getLogger(__name__)
@KyleJamesWalker
KyleJamesWalker / dir_to_srt.py
Last active December 15, 2018 01:51
Converts a folder of srt files into a single srt
# -*- coding: utf-8 -*-
'''
Quick script to embed into Automator to concat a folder of srt files into
a single srt.
Note: This also removes extra blanks lines, to allow pycaption to process
the files. This won't be needed if https://github.com/pbs/pycaption/pull/39
is merged.
'''
@KyleJamesWalker
KyleJamesWalker / googleLogin.py
Last active June 7, 2017 13:49
Login to Google (browser style)
# encoding: utf-8
from __future__ import unicode_literals
import os
import requests
import sys
def get_google_auth_session(username, password):
session = requests.Session()
@KyleJamesWalker
KyleJamesWalker / Ranger.md
Last active February 4, 2020 16:03
Ranger Setup

Ranger mac setup:

  • brew install ranger
  • ranger --copy-config=all
  • vim ~/.config/ranger/rc.conf
    • preview_image false --> true

Other Tools:

  • brew install w3m
  • brew install lynx
description "Hubot Slack bot"
# Slack-specific environment variables. Change these:
env HUBOT_SLACK_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaa
env HUBOT_SLACK_TEAM=example
env HUBOT_SLACK_BOTNAME=flash_gordan
env HUBOT_AUTH_ADMIN=admin
# Subscribe to these upstart events
# This will make Hubot start on system boot
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import logging
import logging.handlers
import requests
class BufferingSlackWebHookHandler(logging.handlers.BufferingHandler):
'''
Quick and dirty code to see if I could figure out the next
larger number with all the same digits of the number passed.
Note: After coming up with the solution I found the following
http://stackoverflow.com/questions/9368205/given-a-number-find-the-next-higher-number-which-has-the-exact-same-set-of-digi
'''
def get_next(the_num):
the_num = str(the_num)
from flask import Blueprint
shared_value = None
class RegisteringExampleBlueprint(Blueprint):
'''
Example showing how to access a value for routes
saved in flask's configuration section for all routes in
blueprint.