Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
struct test {
int a;
int a_square();
};
int test::a_square()
{
def word_search(request):
match = request.GET.get('q')
result = []
if match is not None and len(match) >= 2:
# We search different variants of spelling
variants = Variant.objects.filter(
Q(name__istartswith=match) | Q(downcoded__istartswith=match)
).values_list("entry__pk").order_by("name")
// Search
$("#searchButton").click(function() {
var id = $("#id_word_1").val();
if (id) {
location.replace("/dictionary/redirect/" + id + "/");
return;
}
});
$("#searchTop").submit(function() {
var id = $("#id_word_1").val();
def save(self, *args, **kwargs):
if not self.slug:
self.slug = slugify(self.name)
if not self.slug_unique:
self.slug_unique = unique_slug(self.slug)
try:
if not self.added_by:
self.added_by_id = 9
except Member.DoesNotExist:
pass
class TestSlugs(TestCase):
# This slug must be unique
b = BookPublisher(slug=self.slug)
self.assertRaises(IntegrityError, b.save)
#check if there's only one BookPublisher
self.assertEquals(BookPublisher.objects.count(), 1)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.apple.locate</string>
<key>Disabled</key>
<true/>
<key>ProgramArguments</key>
<array>
@dmishe
dmishe / jsonp.js
Created October 22, 2010 13:57
Pure JS JSONP call
function jsonp(url, callback, name, query)
{
if (url.indexOf("?") > -1)
url += "&" + callback + "="
else
url += "?"+ callback +"="
url += name + "&";
if (query)
url += encodeURIComponent(query) + "&";
url += new Date().getTime().toString(); // prevent caching
AssertionError: Tuples differ: (datetime.date(2011, 9, 19), N... != (datetime.datetime(2011, 9, 19...
First differing element 0:
2011-09-19
2011-09-19 08:17:24
- (datetime.date(2011, 9, 19), None)
+ (datetime.datetime(2011, 9, 19, 8, 17, 24), None)
? ++++ +++++++++++
[statusMapping mapKeyPath:@"item" toRelationship:@"item" withMapping:itemMapping];
[statusMapping mapKeyPath:@"item" toRelationship:@"item" withMapping:serializationItemMapping serialize:YES];
static NSDateFormatter *monthYearFormatter;
#import "NSDate+DateUtils.h"
@implementation NSDate (DateUtils)
- (NSString *)stringMonthYear
{
if (!monthYearFormatter)
{
monthYearFormatter = [[NSDateFormatter alloc] init];