Skip to content

Instantly share code, notes, and snippets.

View stnbu's full-sized avatar
💫
detecting the ether

Mike Burr stnbu

💫
detecting the ether
View GitHub Profile
@stnbu
stnbu / submit_to_pypi.sh
Last active August 29, 2015 14:10
*roughly* the steps needed to submit a package to python's pypi repository
# my highly abridged recipe for pushing to pypi:
python setup.py clean -a ; rm -rf *.egg-info/ dist/ */direg.egg-info/ README.rst ; find . -name "*.pyc" -exec rm "{}" \;
python setup.py check --restructuredtext --metadata
python setup.py test
python setup.py register -r https://pypi.python.org/pypi
python setup.py sdist upload -r https://pypi.python.org/pypi --sign --identity=someguy@example.com
@stnbu
stnbu / is_valid_identifier.py
Last active August 29, 2015 14:11
Test to see if "name" is a 'valid' python identifier: does it have spaces? begin with a numeral, etc, etc. Pretty crude.
def is_valid_identifier(name):
"""Pedantic yet imperfect. Test to see if "name" is a valid python identifier
"""
if not isinstance(name, basestring):
return False
if set('\n\t\r') & set(name):
return False
if name.strip() != name:
return False
try:
@stnbu
stnbu / python_decorator_example.py
Created December 15, 2014 20:24
Trivial python decorator examples. Because I always forget.
def decorator(orig_func):
"""Trivial python decorator
"""
def wrapper_func(*a, **k):
return orig_func(*a, **k)
return wrapper_func
def decorator_wrapper(arg):
"""Decorator with arg(s). Do something conditional/interesting with "arg"
"""
@stnbu
stnbu / project_ideas.txt
Last active August 29, 2015 14:11
Ideas for projects that would most likely be new GitHub repositories.
* pip plugin for “singletons”
* setup.py wrapper/generator for me
* github <-> local dir manager, synchronizer thing.
* config system (like qali’s)
* web browser furigana plugin
* a %pip magic command for ipython
* python OO interface to text file "modelines" (emacs, vim, etc.)
* python library for *sh command line completion
@stnbu
stnbu / productivity_bugs.rst
Last active August 29, 2015 14:11
List of things that get in the way of or inhibit my productivity

Editor (vim) configuration issues:

  • I want paste mode turned off after I paste
  • ycm does not work in past mode (entirely.)
  • If I run the python module I’m working on in vim and there’s a syntax error, it currently just says “shell returned 1”. Suspect: usercustomize
  • The “gq” (format) command seems pretty dumb. Doesn’t know how to maintain comment leaders, etc, etc. There’s probably a python-specific replacement. Look into it. (interesting: if I paste text, the comment leader is preserved.)
  • Misspelled words in my color scheme are currently hard to see due to the back/foreground combination.
  • Is there some way of automatically toggling vim's paste mode?
  • How do I move the cursor to some regex without having to "search".
  • how do I clear the current highlighted search with practically no effort at all.
@stnbu
stnbu / test_hello.py
Created December 19, 2014 08:47
A tester tester. A python module that looks like a test to the more popular python testing tools (pytest, nose, unittest, maybe more.) which contains one test (that passes.)
# -*- coding: utf-8 -*-
"""
A test module that looks like a test to the more popular python testing tools (pytest, nose, unittest, maybe more.) which
contains one test (that passes.)
"""
import unittest
class TestAnything(unittest.TestCase):
@stnbu
stnbu / from-source_python-vim.txt
Last active August 29, 2015 14:12
How to uninstall all bundled, brewed, pythons and install python, and vim from source
### WARNING: this is only for the incredibly reckless
brew uninstall --force $(brew list | grep python)
chmod a-x /usr/bin/pydoc /usr/bin/python /usr/bin/python-config /usr/bin/pythonw
rm -rf /System/Library/Frameworks/Python.framework /Applications/Python\ 2.7 /Library/Frameworks/Python.framework
deactivate
cd ~/source/cpython
export CPPFLAGS=-I/usr/local/opt/readline/include
@stnbu
stnbu / custom_iphone_ringtone.txt
Created February 20, 2015 14:33
Create a Custom iPhone Ringtone (at least as of OSX8)
This was slow and painful, but relative to the "iTunes" way of doing it, it's downright elegant.
This:
http://everydaylht.com/howtos/desktop/create-ringtones-for-your-iphone-using-linux/
Is basically spot-on, even for OSX8. I had some bumps and took some notes.
I used Audacity to create a wav file. Then:
@stnbu
stnbu / wxpy_virtualenv_notes
Created February 21, 2015 11:03
Using your brew-installed wxpython with a virtualenv
### rename orig python binary
# cd ~/virtualenv/bin
# mv python2.7 python2.7.orig
### create ./python2.7
#!/bin/sh
PYVER=2.7
PYTHON=/Library/Frameworks/Python.framework/Versions/$PYVER/bin/python$PYVER
@stnbu
stnbu / get_firefox_bookmark_tags
Last active August 29, 2015 14:17
Recover Tag Information From Firefox Bookmarks
-- recover firefox bookmark tags
-- --------------------------------------
-- List known tabs
SELECT id, title FROM moz_bookmarks WHERE fk IS NULL AND title IS NOT NULL;
-- List bookmarks tagged with id=1300
SELECT moz_places.id, moz_places.url, moz_places.title, moz_bookmarks.parent