Skip to content

Instantly share code, notes, and snippets.

@yarko
yarko / separate_mbox.py
Created August 7, 2020 04:30
Start looking at large mbox / gmail file
#!/usr/bin/env python
'''
separate_mbox [input_mbox] [filter_label]
'''
from collections import Counter
from pprint import pprint
from sys import argv, stdin, stdout, stderr
# write based on first label
@yarko
yarko / config.sh
Last active December 8, 2021 18:14 — forked from leolord/vim.sh
Compiling vim on Ubuntu 18 with LUA-support
# my build: (Ubuntu 20.04)
# see notes (2/12/2020):
# https://github.com/ycm-core/YouCompleteMe/wiki/Building-Vim-from-source
# be sure we have libgtk-3-dev installed
# sudo apt install libgtk-3-dev
./configure \
--with-features=huge \
--enable-multibyte \
--enable-luainterp=yes \
--enable-python3interp=yes \
@yarko
yarko / bitops.py
Last active January 28, 2018 01:23
correct bit complement operation in python (it doesn't seem to work as expected - i.e. on unsigned value - or byte value)
# coding: utf-8
'''
Tried to bit-invert a CSS hex-encoded color using python, but
couldn't get expected output with bit-invert operator.
I.e. this didn't do what I expected:
print(f'#{old_color:x} => #{~old_color:x}')
Besides acting on an apparently arbitrary length integer (rather
than an unsigned (i.e. sign-not-interpreted) bit pattern, the operator
@yarko
yarko / check_links.py
Last active December 30, 2017 21:40
quick check for valid links on a webpage
@yarko
yarko / index.html
Created September 16, 2017 18:47
JPNG.svg (Transparent PNG with JPEG Compression)
<header class="container">
<div class="logo">
<h1 class="logo__heading">
<img class="logo__image" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/39255/jpng-logo.png" alt="JPNG.svg" />
</h1>
<small class="logo__subtitle"><em>This logo was originally 300kb, but compressed down to 69kb using the tool below.</em></small>
</div>
@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

#!/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 / _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])
@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 / 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: