Skip to content

Instantly share code, notes, and snippets.

@maplpro
maplpro / gist:594055
Created September 23, 2010 18:01
goog.ui.TabBar
goog.require( 'goog.ui.TabBar' );
goog.provide( 'infoportal.ui' );
infoportal.ui.init = function () {
tb = new goog.ui.TabBar();
goog.array.forEach(
['Enterprise', 'Farms', 'Web Application', 'Site Collections', 'Sites'],
@maplpro
maplpro / gist:593725
Created September 23, 2010 14:47
jQuery sample
<html>
<head>
<script src="static/scripts/jquery/jquery-1.4.2.js" type="text/javascript" charset="utf-8"></script>
<script src="static/scripts/jquery/json2.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
@maplpro
maplpro / gist:591574
Created September 22, 2010 12:24
google closure gears on IE just returns
function testCreateTable() {
if (!database) {
return;
}
var created = database.queryValue('SELECT 1 FROM SQLITE_MASTER ' +
'WHERE TYPE=? AND NAME=?',
'table',
'Test') != null;
assertTrue('Test table could not be created', created);
@maplpro
maplpro / gist:590139
Created September 21, 2010 18:00
goog.net.BulkLoader
var bulkLoader = new goog.net.BulkLoader(urls);
goog.events.listen(bulkLoader,
[goog.net.EventType.SUCCESS, goog.net.EventType.ERROR],
function(e) {
if (e.type == goog.net.EventType.SUCCESS) {
// We use unsafeParse here because we trust the source of the data.
var loader = /** @type {goog.net.BulkLoader} */ (e.target);
var json = goog.array.map(loader.getResponseTexts(),
goog.json.unsafeParse),
showEventsOnCalendar(json);
@maplpro
maplpro / gist:590138
Created September 21, 2010 17:59
goog.net.XhrIo
goog.net.XhrIo.send('http://www.example.com/testdata.txt', function(e) {
// e.type will be goog.net.EventType.COMPLETE
var xhr = /** @type {goog.net.XhrIo} */ (e.target);
alert(xhr.getResponseText());
});
@maplpro
maplpro / gist:589555
Created September 21, 2010 11:42
python stack trace
import logging
logging.basicConfig( filename = r"C:\Program Files\Quest Software\Site Administrator for SharePoint\SharePoint Information Portal\iis\test.log", level = logging.INFO )
log = logging.info
import isapi_wsgi
try:
import django.core.handlers.wsgi
@maplpro
maplpro / gist:589552
Created September 21, 2010 11:40
python virtual environment
import sys
sys.path.append('C:\\Program Files\\Quest Software\\Site Administrator for SharePoint\\SharePoint Information Portal\\Python25\\Lib')
sys.path.append( 'C:\\Program Files\\Quest Software\\Site Administrator for SharePoint\\SharePoint Information Portal\\Python25\\DLLs' )
sys.path.append('C:\\Program Files\\Quest Software\\Site Administrator for SharePoint\\SharePoint Information Portal')
sys.path.append('C:\\Program Files\\Quest Software\\Site Administrator for SharePoint\\SharePoint Information Portal\\Application')
sys.path.append( r'C:\Program Files\Quest Software\Site Administrator for SharePoint\SharePoint Information Portal\Python25\Lib\site-packages' )
@maplpro
maplpro / cherrypy_srv.py
Created September 20, 2010 10:39
cherrypy simple example and config file
import cherrypy
from jinja2 import Environment, Template, FileSystemLoader
env = Environment( loader = FileSystemLoader('./templates') )
class Root:
@cherrypy.expose
def index(self):
return env.get_template( "index.html" ).render( months = [ '2010-01', '2010-02', '2010-03', '2010-04', '2010-05', '2010-06' ] )
@maplpro
maplpro / index.py
Created September 20, 2010 10:36
indexing with .Net Lucene
import clr
clr.AddReference( "Lucene.Net.dll" )
from System.IO import FileInfo
idx_dir = FileInfo( "index" )
from Lucene.Net.Index import IndexWriter, IndexReader
from Lucene.Net.Analysis.Standard import StandardAnalyzer
from Lucene.Net.Analysis import StopFilter
@maplpro
maplpro / ping.py
Created September 20, 2010 10:16
ping site by URL from IronPython
#pinger
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-u", "--url", dest="url", help="url to ping" )
parser.add_option("-l", "--log", dest="log", help="log file for pinging this URL" )
options, args = parser.parse_args()