Skip to content

Instantly share code, notes, and snippets.

View ionelmc's full-sized avatar
🙃
wat

Ionel Cristian Mărieș ionelmc

🙃
wat
View GitHub Profile
anonymous
anonymous / partialable.py
Created September 13, 2014 10:22
import inspect
class n_partialable(object):
@staticmethod
def arity_evaluation_checker(function):
is_class = inspect.isclass(function)
if is_class:
function = function.__init__
import array
import tracemalloc
from contextlib import contextmanager
@contextmanager
def tracemem(msg):
tracemalloc.start()
snapshot1 = tracemalloc.take_snapshot()
yield
snapshot2 = tracemalloc.take_snapshot()
@ionelmc
ionelmc / .travis.tmpl.yml
Last active December 13, 2015 15:46
This might be outdated. Updated samples here: https://github.com/ionelmc/python-nameless/tree/generative
language: python
python: '3.5'
sudo: false
env:
global:
LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
matrix:
- TOXENV=check
{% for env, config in tox_environments|dictsort %}
- TOXENV={{ env }}{% if config.cover %},extension-coveralls,coveralls,codecov{% endif %}
from nonlocal_ import nonlocal_
def foo():
a = 1
def bar():
nonlocal_('a')
a = 2
bar()
return a
"""
This file contains code that, when run on Python 2.7.5 or earlier, creates
a string that should not exist: u'\Udeadbeef'. That's a single "character"
that's illegal in Python because it's outside the valid Unicode range.
It then uses it to crash various things in the Python standard library and
corrupt a database.
On Python 3... well, this file is full of syntax errors on Python 3. But
if you were to change the print statements and byte literals and stuff:
@ionelmc
ionelmc / settings.py
Last active December 27, 2015 12:49
Dead-simple Django SQL logging
import sys
try:
from sqlparse import format as sqlformat
except ImportError:
sqlformat = lambda s, reindent=None: s
from traceback import format_stack
class WithStacktrace(object):
def __init__(self, skip=[], limit=5):
self.skip = [__name__, 'logging']
#!/bin/bash -eEx
if ! which gpg-agent; then
sudo apt-get install gnupg-agent
fi
if ! which pull-lp-source; then
sudo apt-get install ubuntu-dev-tools
fi
gpg-agent || eval `gpg-agent --daemon`
@OddBloke
OddBloke / nose_checker.py
Created September 24, 2013 08:07
A pylint plugin to fix nose.tools import errors
# The MIT License (MIT)
#
# Copyright (c) 2013 Daniel Watkins <daniel@daniel-watkins.co.uk>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the Software), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
@aras-p
aras-p / preprocessor_fun.h
Last active May 8, 2024 06:45
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@vegasje
vegasje / usability.md
Last active March 9, 2020 19:30
PLEASE DO NOT USE THIS. See http://userium.com/ instead.

PLEASE DO NOT USE THIS. See http://userium.com/ instead.

Usability Checklist

User Experience

  • Personalized features. Currency, language, country specific deals, taxes, or delivery options are changed based on user's location.
  • Registering provides value to users. For example a "Free Trial" button communicates a clear benefit, but a "Register" button doesn't. Unnecessary registration is avoided.