This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function disable_a_moment(o) { | |
o.disabled = true; | |
o.value = o.value + "…"; | |
setTimeout(function() { | |
o.disabled = false; | |
o.value = o.value.substr(0, o.value.length - 1); | |
}, 5000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global module */ | |
module.exports = function(grunt) { | |
'use strict'; | |
grunt.loadNpmTasks('grunt-angular-gettext'); | |
grunt.initConfig({ | |
nggettext_extract: { | |
ops: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
makemessagesjs: | |
grunt nggettext_extract; \ | |
export PO_FILE=locale/fr/LC_MESSAGES/angular.po; \ | |
export POT_FILE=$${PO_FILE}t; \ | |
[ ! -f $$PO_FILE ] && msginit -i $$POT_FILE -o $$PO_FILE || msgmerge --update $$PO_FILE $$POT_FILE; \ | |
rm $$POT_FILE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <glib.h> | |
#include <libsoup/soup.h> | |
#include <libsoup/soup-auth.h> | |
static char* django_get_csrftoken_from_body(SoupMessage *msg) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun duplicate-current-line-or-region (arg) | |
"Duplicates the current line or region ARG times. | |
If there's no region, the current line will be duplicated. However, if | |
there's a region, all lines that region covers will be duplicated." | |
(interactive "p") | |
(let (beg end (origin (point))) | |
(if (and mark-active (> (point) (mark))) | |
(exchange-point-and-mark)) | |
(setq beg (line-beginning-position)) | |
(if mark-active |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun rename-this-buffer-and-file () | |
"Renames current buffer and file it is visiting." | |
(interactive) | |
(let ((name (buffer-name)) | |
(filename (buffer-file-name))) | |
(if (not (and filename (file-exists-p filename))) | |
(error "Buffer '%s' is not visiting a file!" name) | |
(let ((new-name (read-file-name "New name: " filename))) | |
(cond ((get-buffer new-name) | |
(error "A buffer named '%s' already exists!" new-name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Issue(models.Model): | |
title = models.CharField(max_length=256) | |
class Label(models.Model): | |
issue = models.ForeignKey(Issue, related_name='labels') | |
NAME_CHOICES = ( | |
('bug', "Bug"), | |
('feature', "Feature"), | |
('blocker', "Release blocker"), | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Issue(models.Model): | |
LABEL_CHOICES = ( | |
('bug', "Bug"), | |
('feature', "Feature"), | |
('blocker', "Release blocker"), | |
) | |
title = models.CharField(max_length=256) | |
labels = ArrayField( | |
models.CharField(max_length=32, choices=LABEL_CHOICES), | |
default=[], blank=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.utils.datastructures import MultiValueDict | |
class ArrayFieldSelectMultiple(forms.SelectMultiple): | |
"""This is a Form Widget for use with a Postgres ArrayField. It implements | |
a multi-select interface that can be given a set of `choices`. | |
You can provide a `delimiter` keyword argument to specify the delimeter used. | |
""" | |
def __init__(self, *args, **kwargs): | |
# Accept a `delimiter` argument, and grab it (defaulting to a comma) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IssueAdminForm(forms.ModelForm): | |
class Meta: | |
model = app_models.Issue | |
fields = ['title', 'labels'] | |
widgets = { | |
'labels': app_forms.ArrayFieldSelectMultiple( | |
choices=app_models.Issue.LABEL_CHOICES), | |
} | |
class IssueAdmin(admin.ModelAdmin): |
OlderNewer