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 admin | |
# Register your models here. | |
from forum.models import Topic | |
admin.site.register(Topic) |
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.auth.models import User | |
from django.db import models | |
class Topic(models.Model): | |
title = models.CharField(max_length=30) | |
created_by = models.ForeignKey(User, on_delete=models.CASCADE) | |
created_at = models.DateTimeField(auto_now_add=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
asgiref==3.5.0 | |
attrs==21.4.0 | |
Django==4.0.3 | |
django-debug-toolbar==3.2.4 | |
django-extensions==3.1.5 | |
factory-boy==3.2.1 | |
Faker==13.3.2 | |
iniconfig==1.1.1 | |
packaging==21.3 | |
pluggy==1.0.0 |
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 datetime | |
import factory.django | |
import pytest | |
from freezegun import freeze_time | |
from django.contrib.auth.models import User | |
from forum.models import Topic | |
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 WordpressRouter(object): | |
""" Database router - for the moment, everything to default except the wordpress app, which has its own setting """ | |
def db_for_read(self, model, **hints): | |
if model._meta.app_label == 'wordpress': | |
return 'wordpress' | |
return None | |
def db_for_write(self, model, **hints): | |
if model._meta.app_label == 'wordpress': |
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 requests | |
import lxml | |
from lxml import etree | |
from decimal import * | |
from jinja2 import Template | |
import codecs | |
r = requests.get('http://www.azsos.gov/ftp/dbelec/detail.xml') | |
xml_source = r.text | |
root = etree.fromstring(xml_source) |
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 requests | |
import csv | |
from pyquery import PyQuery as pq | |
f = open('strike_all_bills.csv', 'w') | |
wr = csv.DictWriter(f, ['billno']) | |
req = requests.get('http://www.azleg.gov/StrikeEverything.asp') | |
html = pq(req.text) | |
rows = html('tr.TableHeaderBackground').siblings() |
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
for file in `ls`:; do rm /Users/mng/Documents/MapBox/export/$file.mbtiles; tilemill export $file /Users/mng/Documents/MapBox/export/$file.mbtiles --format=mbtiles --files=/Users/mng/Documents/MapBox; tilemill export $file /Users/mng/Documents/MapBox/export/$file.mbtiles --format=upload --files=/Users/mng/Documents/MapBox; done |
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 os | |
from django.conf import settings | |
from django.core.management.base import NoArgsCommand | |
from django.template.loader import render_to_string | |
from prey.models import State | |
class Command(NoArgsCommand): | |
"""command for creating templated tilemill projects""" | |
def handle_noargs(self, *args, **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
jQuery(document).ready(function() { | |
var triggers_in_viewport = []; | |
checkTriggers(); | |
$(window).scroll(function(event) { | |
checkTriggers(); | |
}); | |
$('aside h3 a').click(function(event) { | |
showAside($(this).attr('href')); | |
}); |
NewerOlder