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 random | |
import copy | |
ALPHABET = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", " "] | |
class Scrambler: | |
"""A single scrambler unit""" | |
def __init__(self, seed): | |
self.routes = range(len(ALPHABET)) | |
random.seed(seed) | |
random.shuffle(self.routes) |
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 random | |
import copy | |
ALPHABET = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", " "] | |
class Scrambler: | |
"""A single scrambler unit""" | |
def __init__(self, seed): | |
self.routes = range(len(ALPHABET)) | |
random.seed(seed) | |
random.shuffle(self.routes) |
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
# -*- coding: utf-8 -*- | |
"horfunk.radiopirate models and events handlers" | |
import datetime | |
import os | |
import logging | |
from django.db import models | |
from django.contrib.auth.models import User |
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
String template = Exercise 1: Negate a tree (5%%)\n\n" //usually /n's are at the end of the line | |
+"original tree: \n%s\n" | |
+"original tree negated: \n%s\n" | |
+"original tree negated twice (same as original): \n%s\n" | |
+"empty tree: \n%s\n"; | |
System.out.println(); | |
System.out.printf(template, TreeOps.toString(x), Ex2.negateAll(x), Ex2.negateAll(Ex2.negateAll(x)), Ex2.negateAll(new Tree())); |
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
/** | |
* @param word String to be turned into T9 code | |
* @return the T9 code of the input string | |
* | |
* Method returns the order of buttons of digipad buttons to be pressed to | |
* get the input String from a T9 predictive text dictionary. | |
* | |
* This method assumes the order of the buttons is as follows and ignores case: | |
* | |
* 2= a,b,c |
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
public Set<String> signatureToWords(String signature){ | |
Set<String> words = new HashSet<String>(); | |
int index = (Collections.binarySearch(dictionary, new WordSig("", signature))*-1-2); | |
//System.out.println("Index: "+index); | |
int x = index; | |
String currentSig = dictionary.get(x).getSig(); | |
String currentWord = dictionary.get(x).getWords(); | |
/** | |
if(PredictivePrototype.isValidWord(currentWord)){ | |
words.add(currentWord.toLowerCase()); |
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 ReviewForm(f.ModelForm): | |
class Meta: | |
model = Review | |
class CommentCreateView(CreateView): | |
model = Comment | |
form_class = CommentForm | |
@method_decorator(login_required) | |
def dispatch(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
class CommentForm(f.ModelForm): | |
class Meta: | |
model = Review | |
class CommentCreateView(CreateView): | |
model = Comment | |
form_class = CommentForm | |
@method_decorator(login_required) | |
def dispatch(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
#encoding: UTF-8 | |
from django.conf import settings | |
from django.core.exceptions import ViewDoesNotExist | |
from django.http import HttpResponse | |
from django.template import RequestContext,Template,loader,TemplateDoesNotExist | |
from django.utils.importlib import import_module | |
import httplib | |
class HttpException(Exception): |
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.forms import ModelForm, HiddenInput, MultipleHiddenInput, Textarea | |
from models import Thing, Review, UserProfile | |
from rays.widgets import RangeInput | |
class ReviewForm(ModelForm): | |
mentioned = Textarea() | |
class Meta: | |
model = Review | |
exclude = ("author",) |
OlderNewer