Skip to content

Instantly share code, notes, and snippets.

http://www.python.org/dev/peps/pep-0350/
import smtpd
import asyncore
server = smtpd.DebuggingServer(('127.0.0.1', 1025), None)
asyncore.loop()
@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
@miratcan
miratcan / pivotal2github.py
Created June 29, 2011 16:47
Simple script for migrating from pivotaltracker to github
from github2.client import Github
from csv import reader as CsvReader
# FILL INFORMATION BELOW
# your username at github
GITHUB_USERNAME = ""
# your api token, you can find it at https://github.com/account/admin
GITHUB_API_TOKEN = ""
@miratcan
miratcan / komikaze.py
Created June 30, 2011 18:34
a Crawler for komikaze.net
"""
Mirat Can Bayrak / 2009
"""
from urllib import urlopen, urlretrieve
from datetime import date as Date
from datetime import timedelta
from xml.dom import minidom
from os.path import basename
import re
@miratcan
miratcan / settings.py
Created July 14, 2011 13:36
settings.py that running on both remote and local server.
from os import uname, getcwd
from os.path import join
MACHINE_NAME = uname()[1]
if MACHINE_NAME == "XXX.webfaction.com":
DOCUMENT_ROOT = "/path/to/document/"
DATABASE_ENGINE = ...
DATABASE_NAME = ...
DATABASE_USER = ...
DATABASE_PASSWORD = ...
@miratcan
miratcan / wtf.log
Created July 18, 2011 14:11
That long sql log is for showing 10 thumbnails...
[sql] SELECT ...
FROM "looks_look"
[sql] SELECT ...
FROM "thumbnail_kvstore"
WHERE "thumbnail_kvstore"."key" = sorl-thumbnail||image||da518127fcee31e22ccffa7532bd4008
[sql] SELECT ...
FROM "thumbnail_kvstore"
WHERE "thumbnail_kvstore"."key" = sorl-thumbnail||image||da518127fcee31e22ccffa7532bd4008
[sql] INSERT INTO "thumbnail_kvstore" ("key",
"value")
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
# Override flatpage admin
class FlatPageAdmin(admin.ModelAdmin):
class Media:
js = ('/media/j/jquery.js',
'/media/j/admin_enhancements.js')
css = {'screen': ('/media/c/admin.css',)}
@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 / gist:2025029
Created March 12, 2012 22:12
downloads coursera videos.
import urllib2
from BeautifulSoup import BeautifulSoup
from subprocess import call
for id in range(19, 54):
page = urllib2.urlopen("https://www.coursera.org/modelthinking/lecture/preview_view?lecture_id=%s" % id)
soup = BeautifulSoup(page)
video_tag = soup.find("source", attrs={'type': "video/ogg"})
call(["wget", "%s" % video_tag['src']])