Skip to content

Instantly share code, notes, and snippets.

View readevalprint's full-sized avatar
🤠
code is life

Tim readevalprint

🤠
code is life
View GitHub Profile
// test
@readevalprint
readevalprint / smart-smart-contracts-outline.md
Created July 29, 2015 23:28
Outline of my talk "Smart Smart Contracts: AI on the blockchain"
<html>
<title>Hi</title>
<body>
he he he
</body>
</html>
@readevalprint
readevalprint / index.html
Created May 5, 2011 04:29
The minimalist versions of django. One file. Read more at readevalprint.com/mini-django
<html>
<head>
<title>Hey {{name|default:"there"}}!</title>
</head>
<body>
It's a lovely day, eh {{name|default:"chap"}}?
</body>
</html>
@readevalprint
readevalprint / index.html
Created September 6, 2011 01:37
anya's page
<!DOCTYPE html>
<html>
<head>
<title> anyas page </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(function(){
$("a").click(function(){
alert("clicked");
return false;
@readevalprint
readevalprint / test_templates.py
Created September 8, 2011 17:16
html comments to stop links
class ArticlePreviewTests(TestCaseBase):
#.....
def test_comments_no_linkify(self):
d = _create_document(title='Template:Foo')
revision(document=d,
is_approved=True,
is_ready_for_localization=True,
save=True,
@readevalprint
readevalprint / diff.py
Created September 23, 2011 04:48
Django instance Diff - Now it's the bestestest.
#!/usr/bin/env python
# By Tim Watts
# From http://readevalprint.com/blog/more-better-django-changed-instance-diff.html
# Updated on 9/22/2011 - Added Many2Many to supported fields
# Updated on 9/23/2011 - Fixed Many2Many fields
class Missing:
pass
import hashlib
import datetime
import urllib
# TODO: Create a thin wrapper to use settings.SECRET_KEY
def create(secret, **kwargs):
"""Create a signed, timestamped single use nonce from the given kwargs"""
m = hashlib.md5()
@readevalprint
readevalprint / django-sudo.py
Created December 14, 2011 19:49
Log in as a user in Django
from django.shortcuts import get_object_or_404
from django.contrib.auth import SESSION_KEY
from django import http
from django.contrib.auth.models import User
from django.contrib.auth.decorators import user_passes_test
@user_passes_test(lambda u: u.is_staff)
def su(request, username, redirect_url='/'):
su_user = get_object_or_404(User, username=username)
if su_user.is_active: