Skip to content

Instantly share code, notes, and snippets.

Avatar

Pybites pybites

View GitHub Profile
@pybites
pybites / emailer.py
Created March 23, 2017 10:31 — forked from sarahholderness/emailer.py
Python scripts to read a list of customer emails and send an email with the daily weather forecast
View emailer.py
import weather
import smtp
'''
Send a greeting email to our customer email list
with the daily weather forecast and schedule
'''
def get_emails():
# Reading emails from a file
@pybites
pybites / PyBites.py
Last active June 4, 2017 18:19 — forked from clamytoe/PyBites.py
PyBites.py
View PyBites.py
"""Written on iPhone with the Pythonista 3 app
As a joke for the PyBites guys, I don't see why it wouldn't work anywhere else though. They always
start off their newsletter annoucements with:
from @PyBites import newsletter
So I turned it into actual code that pulls their feed and opens their latest newsletter in a browser :)
"""
import webbrowser
@pybites
pybites / followers_wc.ipynb
Created August 20, 2017 22:41 — forked from simecek/followers_wc.ipynb
Generate wordcloud of followers' descriptions
View followers_wc.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View ciudades.py
#!python3
# my first VBA macro redone in Python
# related article: How I got fired up about programming
# https://bobbelderbos.com/2016/02/fired-up-about-programming/
# 1. download game here: http://juegosexcel.com/foro/viewtopic.php?t=6396
# 2. (to avoid loosing a lot of time using older excel libs) save file to xlsx
#
from collections import namedtuple
import re
View mount-data.txt
{"achievementPoints": 14565,
"battlegroup": "Cyclone",
"calcClass": "V",
"class": 9,
"faction": 0,
"gender": 0,
"lastModified": 1519011260000,
"level": 110,
"mounts": {"collected": [{"creatureId": 32158,
"icon": "ability_mount_drake_blue",
@pybites
pybites / slack-community.py
Created April 22, 2018 04:53
script to get timezone distribution of our slack community
View slack-community.py
from collections import Counter
import os
import sys
from slackclient import SlackClient
token = os.environ.get('SLACK_TOKEN') or sys.exit('need slack api token')
client = SlackClient(token)
users = client.api_call("users.list")
timezones = Counter()
View platform_login_selenium.py
import os
# make venv and pip install selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# set your codechalleng.es username and password in venv/bin/activate, then source it
user = os.getenv('PB_USER')
password = os.getenv('PB_PW')
@pybites
pybites / tictactoe.py
Last active August 19, 2020 09:59
A simple tictactoe game including AI
View tictactoe.py
'''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
View simple-class-pytest.py
# cars.py
from datetime import date
class Car:
def __init__(self, model, year):
self.model = model
self.year = year
self._mileage = []
View gist:1ae8b5f60bad232d2621673ad666d745
# from Fluent Python 2nd ed
class Averager():
def __init__(self):
self.series = []
def __call__(self, new_value):
self.series.append(new_value)
total = sum(self.series)