Skip to content

Instantly share code, notes, and snippets.

@joar
joar / gotcha.rst
Created April 5, 2013 21:42
Python pytest virtualenv gotcha

I encountered this issue:

(mediagoblin)➜  ~VIRTUAL_ENV git:(master) ✗ ./runtests.sh                                                                         belz
Using ./bin/py.test
+ CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_tests
+ exec ./bin/py.test ./mediagoblin/tests --boxed
/home/joar/git/mediagoblin/local/lib/python2.7/site-packages/pytest-2.3.4-py2.7.egg/_pytest/assertion/oldinterpret.py:3: DeprecationWarning: The compiler package is deprecated and removed in Python 3.x.
  from compiler import parse, ast, pycodegen
@magnetikonline
magnetikonline / README.md
Last active April 24, 2025 14:47
Bash string manipulation cheatsheet.

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set, value is returned.

Combine with a : no-op to discard/ignore return value.
${variable="value"}
: ${variable="value"}
@perrygeo
perrygeo / base64_padding.md
Last active January 21, 2025 15:04
Avoiding TypeError: Incorrect padding with Python's base64 encoding

Avoiding padding errors with Python's base64 encoding

>>> import base64
>>> data = '{"u": "test"}'
>>> code = base64.b64encode(data)
>>> code
'eyJ1IjogInRlc3QifQ=='
@sindresorhus
sindresorhus / esm-package.md
Last active April 29, 2025 15:28
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.