Skip to content

Instantly share code, notes, and snippets.

require 'cgi'
source = ARGV.shift
exit if ! source
def header(name)
h = '<pre class="code"><code>' + "(#{File.basename(name)})"
puts h
end
application: stylerepo
version: 1
runtime: python
api_version: 1
handlers:
- url: /stylesheets
static_dir: stylesheets
- url: .*
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html dir='ltr' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<title>Check style priorities with CSS Contextual Selectors</title>
<link type='text/css' rel='stylesheet' href='priority.css' />
<style type="text/css">
h1#header1 { color: orange; }
h1 { color: red; }
</style>
application: stylerepo
version: 1
runtime: python
api_version: 1
handlers:
- url: /stylesheets
static_dir: stylesheets
- url: /logrepo/
#!/opt/local/bin/ruby1.9 -w
# -*- coding: utf-8 -*-
# get_titles.rb: get post tiltes from Blogger RSS feed.
require 'net/http'
require 'uri'
require 'rss'
BLOGID = "put your blog ID here"
#! /opt/local/bin/ruby1.9 -w
# -*- coding: utf-8 -*-
# get_tag_and_class.rb: extract tag and class names from a HTML document.
regex = Regexp.compile('<(\w+)[^<>]*class=[\'\"]([^\'\"]+)[\'\"][^<>]*>')
result = Array.new
Tuple = Struct.new(:line_number, :tag, :class)
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# get_tag_and_class.rb: extract tag and class names from a HTML document.
import sys
import re
regex = re.compile('<(\w+)[^<>]*class=[\'\"]([^\'\"]+)[\'\"][^<>]*>')
#!/opt/local/bin/gosh
;; -*- coding: utf-8 -*-
;; get_tag_and_class.scm: extract tag and class names from a HTML document.
(define (match-tag-and-class line)
(rxmatch-case line
[#/<(\w+)[^<>]*class=[\'\"]([^\'\"]+)[\'\"][^<>]*>(.*)/
(all tag class rest)
(if (> (string-length rest) 0)
#!/opt/local/bin/gosh
;; -*- coding: utf-8 -*-
;; wordcount.scm: a simple filter to count lines/words/characters.
(define (apply-filter proc port)
(let ((line (read-line port)))
(if (not (eof-object? line))
[begin
(proc line)
#!/usr/bin/env python
#
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext import db
import datetime
import logging