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
AMQP_URI: ${AMQP_URI:pyamqp://guest:guest@localhost} | |
SENTRY: | |
DSN: https://your.sentry.dsn |
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
#!/bin/bash | |
set -euox pipefail | |
IFS=$'\n\t' | |
INTERPOLATED_COUNT=25 | |
PHOTOS_DIR=$1 | |
TEMPORARY_FRAMES_DIR=tmp_frames | |
echo "Making timelapse from photos in $PHOTOS_DIR..." |
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
<?php | |
function get_interval($older, $newer) { | |
$invert = $newer < $older; | |
if ($invert) { | |
list($older, $newer) = array($newer, $older); | |
} | |
$Y1 = $older->format('Y'); | |
$Y2 = $newer->format('Y'); | |
$Y = $Y2 - $Y1; |
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
-- without subquery | |
explain analyze | |
select | |
unnest(tags) as tag, | |
count(unnest(tags)) as tag_count | |
from photos_photo | |
group by tag | |
order by tag_count desc; | |
-- with subquery |
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
// build and run with: | |
// g++ -Wall -std=gnu++0x -O0 -fno-elide-constructors main.cpp -o main && ./main | |
// or: | |
// clang++ -Wall -std=gnu++0x -O0 -fno-elide-constructors main.cpp -o main && ./main | |
#include <cstddef> | |
#include <algorithm> | |
#include <iostream> | |
#include <iterator> | |
#include <vector> |
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
// build and run with: | |
// g++ -Wall -std=gnu++0x -O0 -fno-elide-constructors main.cpp -o main && ./main | |
// or: | |
// clang++ -Wall -std=gnu++0x -O0 -fno-elide-constructors main.cpp -o main && ./main | |
#include <iostream> | |
class MoveMe { | |
public: | |
MoveMe(int value = -1): data(new int(value)) { | |
std::cout << "MoveMe(): " << *data << " (" << data << ")\n"; |
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 |
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
.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
# -*- 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): |
NewerOlder