Skip to content

Instantly share code, notes, and snippets.

@LegoStormtroopr
LegoStormtroopr / input.xml
Created Aug 19, 2012
Using XPath1.0 to resolve the correct implied value of an XML elements xml:lang attribute
View input.xml
<?xml version="1.0" encoding="utf-8"?>
<data>
<foo xml:lang="en">
<bar>
<tog xml:lang="fr">
<wel>
<vay xml:lang="sv"/>
</wel>
</tog>
<tog>
View dogsurvey.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="././xsltforms-beta2/xsltforms/xsltforms.xsl" type="text/xsl"?><?xsltforms-options debug="no"?><html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:rml="http://legostormtoopr/response">
<head>
@LegoStormtroopr
LegoStormtroopr / Identifiables
Created Oct 14, 2012
List of objects in DDI 3.1 by their most complex class
View Identifiables
Abstract
Abstract
Access
ActionToMinimizeLosses
Attribute
Coding
CollectionEvent
CollectionSituation
CoordinateGroup
CreationSoftware
@LegoStormtroopr
LegoStormtroopr / Example_use.txt
Created Feb 20, 2013
A demonstration of how to read Excel files using xlrd - http://www.lexicon.net/sjmachin/xlrd.htm
View Example_use.txt
Using: http://www.abs.gov.au/ausstats/meisubs.NSF/log?openagent&634501.xls&6345.0&Time%20Series%20Spreadsheet&D22A58332C098EE7CA257B17000D3976&0&Dec%202012&20.02.2013&Latest
>>> data = abs.xlrdDemo('634501 (1).xls')
>>> print data.keys()
[u'Index', u'Data1', u'Inquiries']
>>> print data['Data1'][10,5]
64.7
>>> print data['Inquiries']
{(9, 1): u'I N Q U I R I E S', (3, 0): '', (8, 0): '', (2, 1): '', (5, 1): u'Table 1. Total Hourly Rates of Pay Excluding Bonuses: Sector, Original, Seasonally Adjusted and Trend', (4, 0): '', (9, 0): '', (8, 1): '', (11, 1): u'Referral Service on 1300 135 070 or Luci Burrage on Perth (08) 9360 5151.', (5, 0): '', (10, 0): '', (4, 1): u'6345.0 Wage Price Index, Australia', (1, 1): u'Time Series Workbook', (0, 0): '', (7, 1): '', (6, 0): '', (11, 0): '', (10, 1): u'For further information about these and related statistics, contact the National Information and', (1, 0): '', (0, 1): '', (7, 0): '', (6, 1): '', (3, 1): '', (2, 0): ''}
@LegoStormtroopr
LegoStormtroopr / Example.py
Last active Jan 23, 2020
'FingerTabs' - Horizontal Text, Horizontal Tabs in PyQt This [trivial fingertab gist](https://gist.github.com/LegoStormtroopr/5075267) is released as Public Domain, but boy would it beswell if you could credit me, or tweet me [@LegoStormtoopr](http://www.twitter.com/legostormtroopr) to say thanks!
View Example.py
from PyQt4 import QtGui, QtCore
from FingerTabs import FingerTabWidget
import sys
app = QtGui.QApplication(sys.argv)
tabs = QtGui.QTabWidget()
tabs.setTabBar(FingerTabBarWidget(width=100,height=25))
digits = ['Thumb','Pointer','Rude','Ring','Pinky']
for i,d in enumerate(digits):
@LegoStormtroopr
LegoStormtroopr / Shift-Tab_friendly_QTextEdit.py
Last active Jun 13, 2019
A BackTab Friendly QTextEdit for PyQt. Allows a user to use Tab/Shift-Tab to indent and un-indent text in a QTextEdit - it also works in QPlaintextEdit A workable solution to this StackOverflow question: http://stackoverflow.com/questions/13579116/qtextedit-shift-tab-wrong-behaviour/18032320#18032320
View Shift-Tab_friendly_QTextEdit.py
import sys
from PyQt4 import QtCore, QtGui
class TabPlainTextEdit(QtGui.QTextEdit):
def __init__(self,parent):
QtGui.QTextEdit.__init__(self, parent)
def keyPressEvent(self, event):
# Shift + Tab is not the same as trying to catch a Shift modifier and a tab Key.
# Shift + Tab is a Backtab!!
@LegoStormtroopr
LegoStormtroopr / pyqt_xml_editor.py
Created Sep 1, 2013
This is a basic XML editor that shows of how to do very simple XML validation inside of a PyQT QTextEdit field. All this does is check for document well-formed-ness, but using the LXML library it shouldn't be difficult to extend this to perform Schema or DOCTYPE based validation.
View pyqt_xml_editor.py
import sys
from lxml import etree
from PyQt4 import QtCore, QtGui
class editor(QtGui.QMainWindow):
def __init__(self):
super(editor, self).__init__()
self.text = QtGui.QTextEdit()
self.setCentralWidget(self.text)
self.text.textChanged.connect(self.validate)
@LegoStormtroopr
LegoStormtroopr / iassist2014.ddi31.xml
Last active Aug 29, 2015
IASSIST 2014 Conference evaluation questionnaire metadata
View iassist2014.ddi31.xml
<?xml version="1.0"?>
<ddi:DDIInstance xmlns:ddi="ddi:instance:3_1" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sqbl="sqbl:1"
xmlns:a="ddi:archive:3_1" xmlns:r="ddi:reusable:3_1" xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:d="ddi:datacollection:3_1" xmlns:l="ddi:logicalproduct:3_1" xmlns:c="ddi:conceptualcomponent:3_1"
xmlns:ds="ddi:dataset:3_1" xmlns:s="ddi:studyunit:3_1" xmlns:g="ddi:group:3_1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="x0" version="0.0.1"
agency="com.kidstrythisathome.ddirepo.legostormtroopr">
<g:ResourcePackage id="x1">
<g:Purpose id="x2">
<r:Content />
@LegoStormtroopr
LegoStormtroopr / badge.html
Created Aug 16, 2014
Font-awesome login badge
View badge.html
<span class="face">
<i class="fg fa fa-user"></i>
</span>
@LegoStormtroopr
LegoStormtroopr / token_search_form.py
Created Oct 9, 2014
Haystack google-like colon searching
View token_search_form.py
# Released as GPL.
# Attribute where possible :)
from haystack.constants import DEFAULT_ALIAS
from haystack import connections
class TokenSearchForm(SearchForm):
def prepare_tokens(self):
try:
query = self.cleaned_data.get('q')
except: