This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:template match="html:li" mode="glossary"> | |
<xsl:param name="footnoteId"/> | |
<xsl:if test="parent::html:ol/parent::html:div/@class = 'footnotes'"> | |
<xsl:if test="concat('#',@id) = $footnoteId"> | |
<xsl:apply-templates select="html:span[@class='glossary sort']" mode="glossary"/> | |
<xsl:apply-templates select="html:span[@class='glossary name']" mode="glossary"/> | |
<xsl:variable name="glsname"> | |
<xsl:apply-templates select="html:span[@class='glossary name']" mode="glossary"/> | |
</xsl:variable> | |
<xsl:text>,</xsl:text> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- anchors --> | |
<xsl:template match="html:a[@href]"> | |
<xsl:param name="footnoteId"/> | |
<xsl:choose> | |
<!-- footnote (my addition)--> | |
<xsl:when test="@class = 'footnote'"> | |
<xsl:text>\footnote{</xsl:text> | |
<xsl:apply-templates select="/html:html/html:body/html:div[@class]/html:ol/html:li[@id]" mode="footnote"> | |
<xsl:with-param name="footnoteId" select="@href"/> | |
</xsl:apply-templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
####################################################################################### | |
## save as "github" in your path, and chmod+x | |
## Takes one optional argument: a directory name (new or existing) | |
## in which to create the repo (script assumes it's the same name as the Github repo) | |
## if called without an argument, assumes you wish to use the current working directory | |
## example: "github foo" creates (if it doesn't exist) dir foo in current working dir | |
## switches to foo initialises git repo, adds files, performs initial commit, | |
## sets remote master to [email protected]:github_user/foo.git and | |
## attempts to push to it. If the push fails, .git dir is removed and the script exits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import itertools | |
things = { | |
'thing_1' : { | |
'country':'France', | |
'people':'authors', | |
'people_names':['Stendhal', 'Flaubert'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
twitrend.py | |
""" | |
import sys | |
import os | |
import tweepy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{'created_at': '2011-02-01T00:36:34Z', 'trends': [{'url': 'http://search.twitter.com/search?q=%23wishuwould', 'query': '%23wishuwould', 'events': None, 'promoted_content': None, 'name': '#wishuwould'}, {'url': 'http://search.twitter.com/search?q=%23questionsidontlike', 'query': '%23questionsidontlike', 'events': None, 'promoted_content': None, 'name': '#questionsidontlike'}, {'url': 'http://search.twitter.com/search?q=%23februarywish', 'query': '%23februarywish', 'events': None, 'promoted_content': None, 'name': '#februarywish'}, {'url': 'http://search.twitter.com/search?q=Purp+%26+Patron', 'query': 'Purp+%26+Patron', 'events': None, 'promoted_content': None, 'name': 'Purp & Patron'}, {'url': 'http://search.twitter.com/search?q=Egyptians', 'query': 'Egyptians', 'events': None, 'promoted_content': None, 'name': 'Egyptians'}, {'url': 'http://search.twitter.com/search?q=Kool+Herc', 'query': 'Kool+Herc', 'events': None, 'promoted_content': None, 'name': 'Kool Herc'}, {'url': 'http://search.twitter.com/search?q=A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import urllib2 | |
from StringIO import StringIO | |
def mock_response(req, resp_obj, resp_code): | |
""" Mock response for MyHTTPSHandler | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
mmd3_proc.py | |
Convert a MultiMarkdown file into a latex file using MMD3, | |
and process it using XeLaTeX, Biber and Makeglossaries | |
Takes a single argument: the input file to process | |
Outputs a PDF with the same basename as as the input file to cwd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# produce the cartesian product of input dicts | |
# cartesian product is non-commutative, so order matters | |
import itertools | |
output = list(itertools.product(dict_one, dict_two, dict_three) | |
# now you have a list containing nested tuples of all the input dict combinations: | |
# [(('text_1', value_1), ('text_2', value_2), ('text_3', value_3)), … ] | |
# output list of concatenated text and summed values for each top-level tuple | |
flattened = [[' '.join(text), sum(numbers)] for text, numbers in [zip(*item) for item in output]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
excel_things.py | |
Created by Stephan Hügel on 2011-05-07 | |
Read XLS or CSV files, and return contents as unicode strings in nested lists | |
One row per list item, one column per nested list item: | |
[[u'foo', u'bar'], [u'baz', u'abc123'], … ] |
OlderNewer