Skip to content

Instantly share code, notes, and snippets.

Avatar

Pybites pybites

View GitHub Profile
@treyhunner
treyhunner / reversible_flags.py
Created Jan 21, 2022
Python script to identify all Unicode flags that represent a different flag when reversed
View reversible_flags.py
"""
Script to print all Unicode flag emoji are also a valid flag when reversed.
Output of this script:
🇦🇬 (Antigua and Barbuda) reverses to 🇬🇦 (Gabon)
🇦🇱 (Albania) reverses to 🇱🇦 (Lao People's Democratic Republic)
🇦🇲 (Armenia) reverses to 🇲🇦 (Morocco)
🇦🇶 (Antarctica) reverses to 🇶🇦 (Qatar)
🇦🇸 (American Samoa) reverses to 🇸🇦 (Saudi Arabia)
View wins.py
"""
The wins file generator script we use at PyBites
Because it matters!
https://pybit.es/articles/boost-your-motivation-with-brag-doc/
"""
from datetime import date, datetime
import sys
LAST_WEEK_NUMBER = 52
View post_snippet.py
"""
Script to post a code snippet to PyBites CodeImag.es
If you see other use cases (e.g. process a csv file with snippets),
contact @bbelderbos on Twitter, thanks.
"""
from pprint import pprint as pp
# pip install requests python-decouple
import requests
from decouple import config
@kyokley
kyokley / py23_check.md
Last active Jul 7, 2018
Dynamically set Python2/3 version in Syntastic
View py23_check.md

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

View pybites.py
PYBITES_IMG = """
;;;;;;;;,,.`
:;;;;;;;;;;::,,,,,
`.............`.`....````.``........`..`..``````````````````````````````````````````````````````````````````````````````````````;, ,;;;;;;;;:,,,,,,,,``````````````````
`.....................``..................```````````````````````````````````````````` ``,,``````````````````````````````````:;. .;;;;;;;;::,,,,,:::,````````````````
`.....................`.`.............` `,`````````````````````````````. +`,`````````` `,.`````````````````````````````````:,;;;;;;;;;;;;::::::::::::```````````````
`...............................``.,,.``.`````````````````````````````####+'.````````` `..```````````````````````````````,,,:;;;;;;;;;;;;:,:::::::::::`````````````
@simecek
simecek / followers_wc.ipynb
Created Aug 18, 2017
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.
@clamytoe
clamytoe / PyBites.py
Last active Jun 4, 2017
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 os
@zulhfreelancer
zulhfreelancer / upgrade.md
Last active Dec 15, 2022
How to upgrade Heroku Postgres database plan?
View upgrade.md
  1. Assuming you have multiple Heroku apps and Git remote like so:
development https://git.heroku.com/xxx.git (fetch)
development https://git.heroku.com/xxx.git (push)
origin      git@bitbucket.org:xxx/xxx.git  (fetch)
origin      git@bitbucket.org:xxx/xxx.git  (push)
production  https://git.heroku.com/xxx.git (fetch)
production  https://git.heroku.com/xxx.git (push)
staging https://git.heroku.com/xxx.git (fetch)
@kyokley
kyokley / syntax.md
Last active Sep 2, 2021
Preventing saving for various errors in VIM
View syntax.md

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?

@claymcleod
claymcleod / pycurses.py
Last active Jan 28, 2023
Python curses example
View pycurses.py
import sys,os
import curses
def draw_menu(stdscr):
k = 0
cursor_x = 0
cursor_y = 0
# Clear and refresh the screen for a blank canvas
stdscr.clear()