Skip to content

Instantly share code, notes, and snippets.

View titusz's full-sized avatar

Titusz titusz

View GitHub Profile
@hrldcpr
hrldcpr / tree.md
Last active January 6, 2025 22:43
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@sgmurphy
sgmurphy / podcast-ratings.php
Created February 21, 2012 19:31
Scrape ratings from iTunes store
<?php
/**
* Scrape the number of podcast reviews from iTunes for all country specific storefronts.
*
* @author Sean Murphy <[email protected]>
*/
$podcast_id = '366931951'; // Startups For the Rest of Us
//$podcast_id = '318567721'; // techzing
@jordinl-zz
jordinl-zz / django_field_validation.py
Created September 22, 2011 11:51
Add field validations to the model
from django.db import models
from django.core.exceptions import ValidationError
from django.forms import ModelForm
class CleanModel(models.Model):
""" Abstract class that adds field validations """
def clean_fields(self, exclude):
errors = {}
@joshmarshall
joshmarshall / tornado_temp_file_put.py
Created March 15, 2011 02:35
Temporary File PUT Transfer Handler for Tornado
import tornado.ioloop
import tornado.web
import tornado.httpserver
import tornado.httputil
import tempfile
class MainHandler(tornado.web.RequestHandler):
def put(self):
filename = self.request.body.name
# do stuff with the image