Skip to content

Instantly share code, notes, and snippets.

View marazmiki's full-sized avatar

Mikhail Porokhovnichenko marazmiki

View GitHub Profile
@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 {
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():
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
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
};
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
@marazmiki
marazmiki / gist:4214368
Created December 5, 2012 09:50 — forked from michelts/gist:1029336
FormsView
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
@marazmiki
marazmiki / sticky.css
Created November 14, 2012 08:53 — forked from mokagio/sticky.css
Twitter Bootstrap + Sticky Footer + Fixed Nav Bar
html, body, .container, .content {
height: 100%;
}
.container, .content {
position: relative;
}
.proper-content {
padding-top: 40px; /* >= navbar height */
@marazmiki
marazmiki / daemon.py
Created September 4, 2012 07:53
Python daemon example
#!/usr/bin/env python
# coding: utf-8
import argparse
import os
import sys
import time
import atexit
import logging
import signal
@marazmiki
marazmiki / authuser.md
Created June 30, 2012 19:33 — forked from jacobian/authuser.md
Upgrading auth.User - the profile approach

Upgrading auth.User - the profile approach

This proposal presents a "middle ground" approach to improving and refactoring auth.User, based around a new concept of "profiles". These profiles provide the main customization hook for the user model, but the user model itself stays concrete and cannot be replaced.

I call it a middle ground because it doesn't go as far as refactoring the whole auth app -- a laudable goal, but one that I believe will ultimately take far too long -- but goes a bit further than just fixing the most egregious errors (username length, for example).

This proposal includes a fair number of design decisions -- you're reading the fifth or sixth draft. To keep things clear, the options have been pruned out and on the one I think is the "winner" is still there. But see the FAQ at the end for some discussion and justification of various choices.

The User model

@marazmiki
marazmiki / ffmpeg_runner.py
Created June 29, 2012 03:57
Runs the ffmpeg process and calculates convertation progress in real time
class FFMPegRunner(object):
"""
Usage:
runner = FFMpegRunner()
def status_handler(old, new):
print "From {0} to {1}".format(old, new)
runner.run('ffmpeg -i ...', status_handler=status_handler)