Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
| # -*- coding: utf-8 -*- | |
| from django import forms | |
| from crispy_forms.helper import FormHelper | |
| from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field | |
| from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions | |
| class MessageForm(forms.Form): | |
| text_input = forms.CharField() |
| from bisect import bisect_left, bisect_right | |
| class SortedCollection(object): | |
| '''Sequence sorted by a key function. | |
| SortedCollection() is much easier to work with than using bisect() directly. | |
| It supports key functions like those use in sorted(), min(), and max(). | |
| The result of the key function call is saved so that keys can be searched | |
| efficiently. |
| # List databases | |
| sudo su postgres | |
| psql | |
| \list | |
| # Create a compressed backup | |
| sudo su postgres | |
| pg_dump -Fc <database_name> > <file> | |
| # Example |
| from django.db import models | |
| class Person(models.Model): | |
| name = models.CharField(max_length=200) | |
| groups = models.ManyToManyField('Group', through='GroupMember', related_name='people') | |
| class Meta: | |
| ordering = ['name'] | |
| def __unicode__(self): |
| #!flask/bin/python | |
| from flask import Flask, jsonify, abort, request, make_response, url_for | |
| from flask_httpauth import HTTPBasicAuth | |
| app = Flask(__name__, static_url_path = "") | |
| auth = HTTPBasicAuth() | |
| @auth.get_password | |
| def get_password(username): | |
| if username == 'miguel': |
| <script> | |
| // espera hasta que se cargue jquery, no es la forma optima pero es interesante | |
| function docReady(fn) { | |
| if (document.readyState === "complete" || document.readyState === "interactive") { | |
| setTimeout(fn, 105); | |
| } else { | |
| document.addEventListener("DOMContentLoaded", fn); | |
| } | |
| } | |
| docReady(existejquery); |
| from django import forms | |
| from menu.models import Ingredient, Diet, FoodPreference | |
| class IngredientForm (forms.ModelForm): | |
| class Meta: | |
| model = Ingredient | |
| exclude = ["franchise"] | |
| def __init__ (self, *args, **kwargs): | |
| brand = kwargs.pop("brand") |
| #!/bin/bash | |
| echo "This script will: | |
| 1) install all modules need to run web2py on Jessie Minimal and other tools | |
| 2) install web2py in /home/www-data/ | |
| 3) create a self signed ssl certificate | |
| 4) setup web2py with mod_wsgi | |
| 5) overwrite /etc/apache2/sites-available/default | |
| 6) restart apache. | |
| Press a key to continue...[ctrl+C to abort]" |