-
Install redis on OSX (10.7) Lion I used:
$ brew install redis
-
In the project and virtualenv I wanted to use django-celery in I installed the following.
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Testing Pie Chart</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.1.3"></script> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.1.3"></script> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.1.3"></script> | |
<style type="text/css"> |
def not_in_student_group(user): | |
"""Use with a ``user_passes_test`` decorator to restrict access to | |
authenticated users who are not in the "Student" group.""" | |
return user.is_authenticated() and not user.groups.filter(name='Student').exists() | |
# Use the above with: | |
@user_passes_test(not_in_student_group, login_url='/elsewhere/') | |
def some_view(request): | |
# ... |
\documentclass[10pt]{article} | |
\usepackage[T1]{fontenc} | |
\usepackage[scaled]{beramono} | |
\renewcommand*\familydefault{\ttdefault} | |
\usepackage{listings} | |
\lstset{ | |
language=Python, | |
showstringspaces=false, | |
formfeed=\newpage, |
pi@rpi0 ~ $ sudo apt-get purge wolfram-engine | |
Reading package lists... Done | |
Building dependency tree | |
Reading state information... Done | |
The following packages will be REMOVED: | |
wolfram-engine* | |
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. | |
After this operation, 454 MB disk space will be freed. | |
Do you want to continue [Y/n]? y | |
(Reading database ... 77272 files and directories currently installed.) |
In this tutorial we are going to build a Twitter clone using Django and GetStream.io, a hosted API for newsfeed development.
We will show you how easy is to power your newsfeeds with GetStream.io. For brevity we leave out some basic Django-specific code and recommend you refer you to the Github project for the complete runnable source code. At the end of this tutorial we will have a Django app with a profile feed, a timeline feed, support for following users, hashtags and mentions.
I assume that you are familiar with Django. If you're new to Django the [official tutorial] (https://docs.djangoproject.com/en/2.0/intro/) explains it very well.
See comments section for more up-to-date versions of the script. The original script is from 2014 and will not work as is.
- Open news feed preferences on your Facebook menu (browser)
- Click people or pages
- Scroll down (or click see more) until your full list is loaded
- Run the script in your browser console
Facebook will block this feature for you while you use it, depending on how much entities you try to unfollow. It automatically unblocks in a couple of hours and you will be able to continue.
# This is just a cheat sheet: | |
# On production | |
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz | |
# On local | |
scp -C production:~/database.sql.gz | |
dropdb database && createdb database | |
gunzip < database.sql.gz | psql database |
from __future__ import unicode_literals | |
from django.db import models | |
from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor # noqa | |
class RelationNotLoaded(Exception): | |
pass | |
from django.db.models import Count, Max | |
unique_fields = ['field_1', 'field_2'] | |
duplicates = ( | |
MyModel.objects.values(*unique_fields) | |
.order_by() | |
.annotate(max_id=Max('id'), count_id=Count('id')) | |
.filter(count_id__gt=1) | |
) |