Skip to content

Instantly share code, notes, and snippets.

View bbelderbos's full-sized avatar

Bob Belderbos bbelderbos

View GitHub Profile
@relsqui
relsqui / buses.py
Last active October 11, 2015 04:28
Morning readiness script.
#!/usr/bin/python
from urllib2 import urlopen
from json import loads
from xml.dom.minidom import parseString
from datetime import datetime, timedelta
from math import floor
TRIMET_API_KEY = "" # redacted for privacy
@clamytoe
clamytoe / get_pid.sh
Created December 2, 2017 17:03
Scripts that I use to keep my Slack bot running if it gets disconnected.
#!/bin/bash
ps awxx | grep $1 | grep -v get_pid | grep -v grep | awk '{print $1}'
@NekoTashi
NekoTashi / leap_year.py
Created January 3, 2018 15:10
365 does not include leap year.
from datetime import datetime, timedelta
PYBITES_BORN = datetime(year=2016, month=12, day=19)
def my_gen_special_pybites_dates():
days = 1
while True:
dt = PYBITES_BORN + timedelta(days=days)
# if days % 100 == 0: # commented to print only 'every year'
PYBITES_IMG = """
;;;;;;;;,,.`
:;;;;;;;;;;::,,,,,
`.............`.`....````.``........`..`..``````````````````````````````````````````````````````````````````````````````````````;, ,;;;;;;;;:,,,,,,,,``````````````````
`.....................``..................```````````````````````````````````````````` ``,,``````````````````````````````````:;. .;;;;;;;;::,,,,,:::,````````````````
`.....................`.`.............` `,`````````````````````````````. +`,`````````` `,.`````````````````````````````````:,;;;;;;;;;;;;::::::::::::```````````````
`...............................``.,,.``.`````````````````````````````####+'.````````` `..```````````````````````````````,,,:;;;;;;;;;;;;:,:::::::::::`````````````
@kyokley
kyokley / py23_check.md
Last active July 7, 2018 13:29
Dynamically set Python2/3 version in Syntastic

Determining Python 2/3 Version in VIM

Introduction

I am a big fan of the syntastic package. In python, it is useful for viewing both Pyflakes and Bandit errors. However, this only works if syntastic knows what python interpreter to use. Not everyone is fortunate enough to have upgraded all of their software to python3. For reasons out of my control, I end up spending most of my time writing python2 code. This means that the times when I finally get to write python3, all of my syntax checking is broken. How cool would it be to have VIM determine what version of python to use automatically? So, begins my grand experiment...

Prerequisites

For this to work, I will be using a virtualenv for python2 and one for python3. It's not absolutely necessary to use virtualenvs but I definitely recommend it. Setting up virtualenvs is out of the scope of this gist but make sure that each virtualenv

@pybites
pybites / tictactoe.py
Last active August 19, 2020 09:59
A simple tictactoe game including AI
'''Simple tictactoe game, board positions are like keyboard
7 8 9
4 5 6
1 2 3
'''
from builtins import input
from collections import Counter
from functools import wraps
import itertools
@kyokley
kyokley / syntax.md
Last active September 2, 2021 12:47
Preventing saving for various errors in VIM

Preventing saving for various errors in VIM (Buffer Pre-write Hook Part 2)

Introduction

This is a continuation of my buffer pre-write hook series. Check out the previous gist to follow the progression.

Have you ever tried running a file only to be stopped by "<<<<<<<"?

Wouldn't it be nice to be able to automatically run your code through pyflakes before actually saving it? Maybe even raise an error for showstopping bugs in your code?

@yaythomas
yaythomas / README.md
Last active November 28, 2021 16:12
pypyr video processing (untested) rough structural example

automating your video processing

[preamble]

what we want to achieve

TODO:

  1. download the video
  2. convert to different formats via ffmpeg
  3. create thumbnails
  4. use a trained ML model for scene classification
  5. make sub clips based on classification
@ryan-blunden
ryan-blunden / pybites-intro.py
Created November 30, 2021 11:58
Pybites commuity intro message fun
from dataclasses import dataclass
import random
pybites_init_questions = [
'If you were to build a chatbot what would it do'
]
@dataclass
class PybitesIntro:
@nnja
nnja / .pdbrc
Created August 2, 2019 12:55
My .pdbrc file with an interacti alias
# Install IPython: python3 -m pip install ipython
import IPython
from traitlets.config import get_config
cfg = get_config()
cfg.InteractiveShellEmbed.colors = "Linux" # syntax highlighting
cfg.InteractiveShellEmbed.confirm_exit = False
alias interacti IPython.embed(config=cfg)