Skip to content

Instantly share code, notes, and snippets.

function friendly(arr) {
var now = new Date();
var fromDate = new Date(Date.parse(arr[0]));
var toDate = new Date(Date.parse(arr[1]));
var ord = [];
if (sameYear(fromDate, now) && withinOneYear(fromDate, toDate)) {
// Year should not be displayed at first date
ord[0] = monthName(fromDate) + " " + nth(fromDate);
} else {
// All should be displayed at first date
var Recipe = function (title, servings, ingredients) {
this.title = title;
this.servings = servings;
this.ingredients = ingredients;
};
Recipe.prototype.print = function() {
console.log(this.title);
console.log("Serves: " + this.servings);
console.log("Ingredients:")
(function ($, undefined) {
if ($.forms !== undefined) {
$.error("forms.js has already been loaded.");
}
var forms;
$.forms = forms = {
href: function (element) {
return element.attr('href');
# MongoEngine's useful tool called query_counter
from mongoengine.context_managers import query_counter
# Initialize counter
c = query_counter()
with c:
# make MongoDB calls via MongoEngine API
# e.g. User.objects.all()
{% macro render(form) -%}
<fieldset>
{% for field in form %}
{% if field.type in ['CSRFTokenField', 'HiddenField'] %}
{{ field() }}
{% else %}
<div class="clearfix {% if field.errors %}error{% endif %}">
{{ field.label }}
<div class="input">
@teisman
teisman / bash.md
Last active December 16, 2015 15:59

##bashrc | bash_profile

Configuring your bash shell, you often want to specify environment variables, set the search path, and do other configurations. The question arises which files need to be configured in order to do so. A unix shell can run in two modes; as a login shell or as a non-login shell. In case of bash - a Bourne type shell - the login and the non-login variants call their own configuration files, which can be found in ~/.bash_profile and ~/.bashrc respectively. The seperation between login and non-login shells makes sense. When a user first logs in to a system (for example via ssh), the user may want to set specific parameters such as which type of terminal is running, or may want to display specific login messages. To avoid doing the same (potentially relatively expensive) initialization, later invocations of the shell will normally open the non-login shell, which can be configured to run with a light initialization.

###Solution When you want to load a PATH variables under all circumstan

To install your personal python package, first create a source distribution by entering python setup.py sdist. On UNIX systems, default output format is a gzipped tar .tar.gz.

When the source distribution has been created, use pip install -e /path/to/setup/file/ to install the distribution in editable mode. What this does is it created a symbolic link, adding the location of the source distribution to the python path sys.path.

When this is set up, new versions of your package can be rolled simply by replacing the source distribution.

{
"message": "Validation failed",
"errors": [
{
"type": "<The type of error returned>",
"code": "<A developer-facing message describing the error.>",
"message": "<User friendly message to display on site>",
"param": "<Name of parameter for in-form display>"
},{
"type": "<The type of error returned>",

Settings by Maxime

##Installation

$ sudo apt-get install nginx supervisor
$ pip install uwsgi

##uWSGI Configure an uWSGI app in /etc/uwsgi.ini:

servers = (
  {
    address = "irc.freenode.net";
    chatnet = "Freenode";
    port = "6667";
    use_ssl = "no";
    ssl_verify = "no";
    autoconnect = "yes";
    password = "<password>";

}