Skip to content

Instantly share code, notes, and snippets.

@yarko
yarko / session_staff.py
Last active July 19, 2023 00:19
PyCon Session Staff reporting tool; what started as 6 quick lines of code, has a ways to go to be "portable" year-to-year, but coming along...
#!/usr/bin/env python
'''
usage:
session_staff [<url>]
session_staff --report [<kind>] [<url>]
session_staff --version
session_staff --debug
options:
@yarko
yarko / build-pythonv3.6.0.sh
Last active December 23, 2016 20:24
Build Python v3.6.0 release on os/x from github sources, where brew has installed (co-reside w/ your other pythons)
#!/usr/bin/env sh
# NOTE: keeping this gist for 3.6.0 release, because I want to keep 3.5 around for a bit too;
# Here is how I built Python v3.6.0b1...onward
# on OS/X, where brew is installed
# (and python2.7 and python3.5 installed by brew):
# make sure you have openssl installed (this is for installing pip)
# and a recent tcl-tk, if you're going to use idle
# (see https://www.python.org/download/mac/tcltk/ for more info)
# If you have them installed, you might want to `brew upgrade` them.
@yarko
yarko / batch-delete-gmail-emails.js
Last active December 12, 2020 14:53 — forked from gene1wood/batch-delete-gmail-emails.js
A Google Apps Script script to bulk delete large amounts of email in Gmail while avoiding the error #793 which Gmail encounters normally
# This script, when used with Google Apps Scripts will delete 500 emails - the amount the API will return with one call.
# It can be triggered to run periodically (I set @ 5 minute, since it runs slow) without user interaction
# enabling you to bulk delete email in Gmail without getting the #793 errors, etc., from Gmail.
# Configure the search query in the code below to match the type of emails you want to delete
# See - https://developers.google.com/apps-script/reference/gmail/gmail-app#search(String)
# and https://support.google.com/mail/answer/7190?hl=en
# Browser to https://script.google.com/.
# Start a script and paste in the code below.
@yarko
yarko / json2yaml
Created December 16, 2016 20:29
Simple json / yaml conversions
#!/usr/bin/env python
from os import path
import sys
import json
import yaml
if len(sys.argv) > 1:
print("usage:\n\t{} < your_json_file > your_yaml_file".format(
path.basename(sys.argv[0])))
@yarko
yarko / bug-requests.py
Last active May 31, 2017 01:41
debugging scraping threads from twitter
import requests
# 2017-05-30 17:02:10.049243
url = 'https://twitter.com/MinaMarkham/status/865606994614296576'
r = requests.get(url)
# Save the text, see if response is there or not manually:
# 2017-05-30 17:04:07.293014
with open('bug_reqraw.txt', 'w') as f:
@yarko
yarko / conditional_breakpoint.py
Last active October 6, 2017 18:43
conditional break for ipython terminal (**Use:** `if condition: breakpoint` instead -- **don't** use this.)
# This is for ipython interactive
# - you can, for example, place this in
# ~/.ipython/profile_default/startup
def breakpoint_(condition=True):
'''
in ipython:
- breakpoint_() <= break always
- breakpoint_(False) <= never break
- breakpoint_(condition) <= break if True
@yarko
yarko / _excluded_updates.py
Last active February 7, 2018 17:51
bash multi-python pip update scripts
#!/usr/local/bin/python3
from sys import stdin
from os import path
excl_f = path.expanduser("~/.config/pipupgrade/exclude")
with open(excl_f, "r") as f:
excl = []
for line in f:
excl.append(line[:-1])
#!/bin/env python
# doing little more than applying my suggestions to the
# first-time coding effort of:
# https://www.reddit.com/r/Python/comments/6rvd0v/first_time_properly_getting_into_coding_how_is/
# There is more which can be done / said here (e.g. EOF-quit handling), but this
# shows the suggestions I put forth applied, and the effect of separating getting input
# from forming the calculation.
@yarko
yarko / Building-Vim-with-Lua.md
Last active September 12, 2017 23:13
building Vim w/ Lua support (Linux)

These are my notes on Ubuntu 16.04. It seems generic enough, that I trust it applies to any Linux (perhaps any gcc) build.

I (lazily) had used https://vim.spf13.com vim plugins. The startup error messages were getting annoying, in particular from neocomplete (which needs Lua support). I also had problems from python-mode, but this was unrelated (I ended up removing, then re-installing python-mode, via the :Plugin plugin).

This excursion was triggered by a