You may need to configure a proxy server if you're having trouble cloning
or fetching from a remote repository or getting an error
like unable to access '...' Couldn't resolve host '...'.
Consider something like:
| from django import forms | |
| from django.contrib.postgres.fields import ArrayField | |
| class ChoiceArrayField(ArrayField): | |
| """ | |
| A field that allows us to store an array of choices. | |
| Uses Django 1.9's postgres ArrayField | |
| and a MultipleChoiceField for its formfield. |
| # -*- coding: utf-8 -*- | |
| from __future__ import unicode_literals | |
| from django.db import migrations | |
| from django.contrib.auth.admin import User | |
| def create_superuser(apps, schema_editor): | |
| superuser = User() | |
| superuser.is_active = True |
Magic words:
psql -U postgresSome interesting flags (to see all, use -h or --help depending on your psql version):
-E: will describe the underlaying queries of the \ commands (cool for learning!)-l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)| # -*- coding: utf-8 -*- | |
| __author__ = 'Arkady.Babaev' | |
| import requests | |
| import xml.etree.ElementTree as ET | |
| class ALMUrl: | |
| def __init__(self, ip, port, domain, project): | |
| self.__base = u'http://' + ip + u':' + port + u'/qcbin' | |
| self.__auth = self.__base + u'/authentication-point/authenticate' |
| class MyAdmin(admin.ModelAdmin): | |
| list_display = (..., 'actions_html') | |
| def actions_html(self, obj): | |
| return format_html('<button class="btn" type="button" onclick="activate_and_send_email({pk})">Activate and send email</button>', pk=obj.pk) | |
| actions_html.allow_tags = True | |
| actions_html.short_description = "Actions" |
| <style> | |
| @font-face { | |
| font-family: "Computer Modern"; | |
| src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf'); | |
| } | |
| div.cell{ | |
| width:800px; | |
| margin-left:16% !important; | |
| margin-right:auto; | |
| } |
| # Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail | |
| # Make sure you have IMAP enabled in your gmail settings. | |
| # Right now it won't download same file name twice even if their contents are different. | |
| import email | |
| import getpass, imaplib | |
| import os | |
| import sys | |
| detach_dir = '.' |
| def dict_format(original, **kwargs): | |
| """Recursively format the values in *original* with *kwargs*. | |
| >>> sample = {"key": "{value}", "sub-dict": {"sub-key": "sub-{value}"}} | |
| >>> dict_format(sample, value="Bob") == \ | |
| {'key': 'Bob', 'sub-dict': {'sub-key': 'sub-Bob'}} | |
| True | |
| """ | |
| new = {} | |
| for key, value in original.items(): | |
| if type(value) == type({}): |
| ;(function($){ | |
| ListFilterCollapsePrototype = { | |
| bindToggle: function(){ | |
| var that = this; | |
| this.$filterEl.click(function(){ | |
| that.$filterList.slideToggle(); | |
| }); | |
| }, | |
| init: function(filterEl) { | |
| this.$filterEl = $(filterEl).css('cursor', 'pointer'); |