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 "aquila/tools/TextPlot.h" | |
#include <cstddef> | |
int main(int argc, char *argv[]) | |
{ | |
const std::size_t SIZE = 64; | |
int arr[SIZE]; | |
for (std::size_t i = 0; i < SIZE; ++i) | |
{ | |
arr[i] = i % 10; |
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
--- D:/Python26/Lib/site-packages/django_notification-0.1.4-py2.6.egg/notification/views.py Tue Jun 08 14:21:04 2010 | |
+++ D:/Python26/Lib/site-packages/django_notification-0.1.4-py2.6.egg/notification/views2.py Tue Jun 08 14:21:12 2010 | |
@@ -19,7 +19,7 @@ | |
@login_required | |
def notices(request): | |
notice_types = NoticeType.objects.all() | |
- notices = Notice.objects.notices_for(request.user, on_site=True) | |
+ notices = Notice.objects.notices_for(request.user, on_site=True).select_related(depth=1) | |
settings_table = [] | |
for notice_type in NoticeType.objects.all(): |
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.contrib import comments | |
from django.contrib.contenttypes.models import ContentType | |
from django.db import connection | |
from django.db import models | |
from django.utils.datastructures import SortedDict | |
class RecentManagerMixin(object): | |
pub_date_field_name = 'pub_date' |
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
Aquila::SineGenerator generator(44100); | |
generator.setAmplitude(2000).setFrequency(500).generate(10 * 44100); | |
Aquila::WaveFile::save(generator, "L:\\sin.wav"); |
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
/** | |
* Playing the Imperial March from Star Wars. | |
* | |
* Notes and timings found at: | |
* http://processors.wiki.ti.com/index.php/Playing_The_Imperial_March | |
*/ | |
#include "aquila/source/generator/SineGenerator.h" | |
#include "aquila/wrappers/SoundBufferAdapter.h" | |
#include <SFML/Audio.hpp> |
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
# -*- coding: utf-8 -*- | |
import string | |
vowels, consonants = 'aąeęioóuy', 'bcćdfghjklłmnńpqrsśtvwxzźż' | |
trans = string.maketrans(vowels + consonants, 'V' * len(vowels) + 'C' * len(consonants)) | |
patterns = [w.lower().translate(trans, string.punctuation + string.digits) for w in open('in.txt', 'r').read().split()] | |
for p, count in sorted(dict((p, patterns.count(p)) for p in set(patterns)).iteritems(), key=lambda (k,v): (v,k), reverse=True): | |
print '%24s: %d' % (p, count) |
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
# -*- coding: utf-8 -*- | |
from django.test import TestCase | |
class _ObjectContext(object): | |
u""" | |
Context manager returned by assertObjectCreated/assertObjectDeleted. | |
""" | |
def __init__(self, enter_assertion, exit_assertion, model_class, **kwargs): |
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
.UFIComment .emote_text { | |
display: inline !important; | |
} | |
.UFIComment .emote_img { | |
display: none !important; | |
} |
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
import reversion | |
from reversion.helpers import generate_patch_html | |
def get_html_diff(instance): | |
versions = reversion.get_for_object(instance) | |
if len(versions) < 2: | |
return "New object, no diff" | |
else: | |
diffs = [] |
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.template.defaultfilters import slugify | |
def get_unique_slug(model_class, value): | |
slug = base_slug = slugify(value) | |
i = 1 | |
while model_class.objects.filter(slug=slug).exists(): | |
slug = '%s%d' % (base_slug, i) | |
i += 1 | |
return slug |
OlderNewer