Skip to content

Instantly share code, notes, and snippets.

@Aaron1011
Aaron1011 / views.py
Created October 8, 2012 18:31
Texting wall views
# Create your views here.
from django.shortcuts import render_to_response
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django import forms
from django.contrib.auth import forms
from django.core.context_processors import csrf
from django.contrib.auth.models import User
from django.template import RequestContext
from django.contrib.auth import authenticate
@Aaron1011
Aaron1011 / views.py
Created October 20, 2012 16:01
Django texting_wall
# Create your views here.
from django.shortcuts import render_to_response
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import forms as auth_forms
from django.core.context_processors import csrf
from django.contrib.auth.models import User
from django.template import RequestContext
from django.contrib.auth import authenticate
from django.contrib.auth import login as auth_login
from django.http import HttpResponse, HttpResponseRedirect
@Aaron1011
Aaron1011 / vies.py
Created November 6, 2012 17:29
Django sms keyword
def _split_message(message):
wall = models.Wall.objects.all()
if len(wall) == 1:
keyword = str(wall[0].sms_keyword)
message = message.replace(keyword, '').replace(' ', ' ')
return keyword, message
codes = re.search("(^|\s)(\w{3})(\s|$)", message)
if codes == None:
return None, None
keyword = _get_keyword(codes)
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<!DOCTYPE html >
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<meta charset="utf-8">
<meta name="google-site-verification"
int reverse(char s[])
{
int len, i;
char copied[MAXLINE];
copy(copied, s);
for (len = 0; ; ++len)
if (s[len] == '\n')
break;
#include <stdio.h>
#define LINECOL 20 /* "fold" after this column */
int main()
{
int c, i, j, lastchar;
int str[LINECOL];
for (i = 0; i <= LINECOL; i++)
str[i] = 0;
{% extends "base.html" %}
{% block title %}Messages{% endblock %}
{% block css %}
.lead {
text-align:center;
}
{% endblock %}
{% block content %}
@Aaron1011
Aaron1011 / passgen.py
Created December 29, 2012 15:27
Password generator
import itertools
import copy
def powerset(iterable):
s = list(iterable)
return itertools.chain.from_iterable(itertools.combinations(s, r) for r in range(len(s) + 1))
def passgen(password, CHOICES = {'a': ['@', '4'], 's': ['$', '&']} ):
@Aaron1011
Aaron1011 / intersect.py
Last active December 10, 2015 10:49
Find intersection
def intersection(sets):
counts = {}
for s in sets:
print "Starting set"
if not counts:
for item in s:
counts[item] = 1
continue
changed = False
for item in s: