Skip to content

Instantly share code, notes, and snippets.

from django.conf import settings
from django.http.request import validate_host
from django.middleware.csrf import _sanitize_token, constant_time_compare
from tastypie.authorization import ReadOnlyAuthorization
from tastypie.authentication import Authentication
from urlparse import urlparse
class InternalResourceAuthentication(Authentication):
def is_authenticated(self, request, **kwargs):
@miratcan
miratcan / ubuntu.py
Created October 27, 2011 09:21 — forked from uugr/ubuntu.py
Ubuntu System Information Script. Prints sysinfo on terminal
#!/usr/bin/env python
#
# archey [version 0.1-11]
#
# Maintained by Melik Manukyan <melik@archlinux.us>
# Distributed under the terms of the GNU General Public License v3.
# See http://www.gnu.org/licenses/gpl.txt for the full license text.
#
# System information tool for Archlinux written in python.
#-----------------Customized For Ubuntu----------------------------
@miratcan
miratcan / cups.py
Created June 8, 2011 21:53 — forked from huseyinyilmaz/cups.py
my solution for 40 cups and 9 oranges problem.
#!/usr/bin/python3.2
from itertools import combinations
"""
You have 40 bowls, all placed in a line at exact intervals of 1 meter. You also have 9 oranges. You wish to place all the oranges in the bowls, no more than one orange in each bowl, so that there are no three oranges A, B, and C such that the distance between A and B is equal to the distance between B and C. How many ways can you arrange the oranges in the bowls?.
(http://www.bittorrent.com/company/about/developer_challenge)
"""
def find_count(orange_count=9,cup_count=40,start_point=0,l=[]):
"""
orange_count: how many oranges should be placed in cups. for our question it is 9.
cup_count: how many cups should be used