Skip to content

Instantly share code, notes, and snippets.

View vinyll's full-sized avatar
🗺️
Creating locally

Vincent Agnano vinyll

🗺️
Creating locally
View GitHub Profile
@vinyll
vinyll / django-crossdomainxhr-middleware.py
Created March 15, 2012 09:01 — forked from vicalejuri/django-crossdomainxhr-middleware.py
Middlware to allow's your django server to respond appropriately to cross domain XHR (postMessage html5 API).
import re
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
from django import http
from django.conf import settings
XS_SHARING_ALLOWED_ORIGINS = getattr(settings, 'XS_SHARING_ALLOWED_ORIGINS', '*')
@vinyll
vinyll / wtfjs-parseint.js
Created December 3, 2012 08:08
wtfjs parseint on big numbers
parseInt("10000000000000000", 10) + 1
//10000000000000000
parseInt("10000000000000000", 10) + 2
//10000000000000002
parseInt("10000000000000000", 10) + 3
//10000000000000004
parseInt("10000000000000000", 10) + 4
//10000000000000004
parseInt("10000000000000000", 10) + 5
//10000000000000004
class FizzBuzz
def initialize
@fizz = 3
@buzz = 5
end
def convert(num)
return "FizzBuzz" if isDivisibleBy(@fizz, num) && isDivisibleBy(@buzz, num)
return "Fizz" if isDivisibleBy(@fizz, num)
@vinyll
vinyll / models.py
Last active June 3, 2023 17:00
Advanced user inheritance with Django
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import (AbstractBaseUser,
BaseUserManager as DjBaseUserManager)
from model_utils.managers import InheritanceManager
class BaseUserManager(DjBaseUserManager, InheritanceManager):
"""
@vinyll
vinyll / output
Created December 11, 2013 14:36
AMO test errors
(venv)vinyll@vinyll ~/P/z/src> dj test --logging-clear-handlers --noinput --settings=settings_local
nosetests --with-fixture-bundling --exclude=mkt/* --logging-clear-handlers --verbosity=1
Reusing old database "test_zamboni". Set env var FORCE_DB=1 if you need fresh DBs.
...................Exception pyes.urllib3.connectionpool.MaxRetryError: MaxRetryError('Max retries exceeded for url: /_bulk',) in <bound method ES.__del__ of <pyes.es.ES object at 0x10687d710>> ignored
No handlers could be found for logger "z.task"
Exception pyes.urllib3.connectionpool.MaxRetryError: MaxRetryError('Max retries exceeded for url: /_bulk',) in <bound method ES.__del__ of <pyes.es.ES object at 0x106881790>> ignored
../Volumes/Users/vinyll/Projects/zamboni/src/apps/addons/models.py:360: DeprecationWarning: object.__new__() takes no parameters
return super(Addon, cls).__new__(cls, *args, **kw)
...Exception pyes.urllib3.connectionpool.MaxRetryError: MaxRetryError('Max retries exceeded for url: /_bulk',) in <bound method ES.__d
======================================================================
ERROR: test_search_limits (api.tests.test_views.SearchTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Volumes/Users/vinyll/Projects/zamboni/src/apps/api/tests/test_views.py", line 1017, in test_search_limits
assert False
File "/Volumes/Users/vinyll/Projects/zamboni/src/apps/api/tests/test_views.py", line 1017, in test_search_limits
assert False
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/bdb.py", line 46, in trace_dispatch
return self.dispatch_line(frame)
from django.contrib.auth.models import User
username = "me"
user = User.objects.get_or_create(username=username)[0]
user.email = username+"@mozilla.com"
user.set_password(user.email)
user.is_verified = True
user.is_staff = True
@vinyll
vinyll / python3.4 installer
Created October 19, 2014 09:45
Installing python3.4 at Alwaysdata
BASH_FILE=~/.zshrc
mkdir -p ~/.python/src
cd !$
wget https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tgz --no-check-certificate
tar xfz Python-3.4.2.tgz
cd Python-3.4.2
mkdir $HOME/.python/python3.4
./configure --prefix=!$ && make && make install
cd ~
"Each child in an array should have a unique "key" prop. Check the render method of PanelsManager. See http://fb.me/react-warning-keys for more information." app.js:15174:2
"panels generated: " Array [ Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, 4 more… ] app.js:25120:6
"children" Array [ undefined, undefined, undefined, undefined ] app.js:24737:4
"children" Array [ undefined, undefined, undefined, undefined, undefined, undefined, undefined ] app.js:24737:4
"children" Array [ undefined, undefined, undefined ]
@vinyll
vinyll / designer.html
Last active August 29, 2015 14:19
designer
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<polymer-element name="my-element">