Skip to content

Instantly share code, notes, and snippets.

View marazmiki's full-sized avatar

Mikhail Porokhovnichenko marazmiki

View GitHub Profile
from django.views.generic.base import View, TemplateResponseMixin
from django.views.generic.edit import FormMixin, ProcessFormView
class MultipleFormsMixin(FormMixin):
"""
A mixin that provides a way to show and handle several forms in a
request.
"""
form_classes = {} # set the form classes as a mapping
function pluralForm(a, one, two, five, substring) {
var form = five,
bits = [];
if (a % 10 == 1 && a % 100 != 11) {
form = one;
} else if (a % 10 >= 2 && a % 10 <= 4 && (a % 100 < 10 || a % 100 >= 20)) {
form = two
};
mkdir -p reports
REPO="http://127.0.0.1:8888"
echo Checking for local repo at ${REPO}
curl -f --head ${REPO} > /dev/null 2>&1 || REPO='http://pypi.python.org/simple'
echo "... will use ${REPO}"
echo 'Creating "venv" environment...'
virtualenv --distribute --no-site-packages venv
class ExampleFormMultipleView(MultipleFormsView):
template_name = 'preferences/change_group_multiple.html'
forms = {
'profile': ProfileForm,
'avatar': AvatarForm,
'contacts': ContactsForm,
}
def forms_valid(self, forms):
for key, form in forms.items():
@marazmiki
marazmiki / waveform.c
Created September 1, 2014 16:29 — forked from dz0ny/waveform.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <groove/groove.h>
#include <limits.h>
//compile with gcc -o waveform main.c -O3 -lgroove -std=c99
// Define a vector type
typedef struct {
@marazmiki
marazmiki / nodes.py
Last active August 29, 2015 14:07
Adjacency tree
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from django.utils.encoding import python_2_unicode_compatible
import json
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto
# dependency - Function.prototype.bind or underscore/lodash
app = angular.module 'someApp'
class @BaseCtrl
@register: (app, name) ->
name ?= @name || @toString().match(/function\s*(.*?)\(/)?[1]
app.controller name, @
@inject: (args...) ->
@marazmiki
marazmiki / gulpfile.js
Last active August 29, 2015 14:18 — forked from ktmud/gulpfile.js
var BatchStream = require('batch-stream2')
var gulp = require('gulp')
var coffee = require('gulp-coffee')
var uglify = require('gulp-uglify')
var cssmin = require('gulp-minify-css')
var bower = require('gulp-bower-files')
var stylus = require('gulp-stylus')
var livereload = require('gulp-livereload')
var include = require('gulp-include')
var concat = require('gulp-concat')

Setting up a SSL Cert from Comodo

Purchasing a Comodo PositiveSSL cert via gogetssl.com and installing it on an Nginx server.

Purchase the cert

Prior to purchasing a cert, you need to generate a private key, and a CSR file