Skip to content

Instantly share code, notes, and snippets.

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
class PDFHandler(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'application/pdf'
self.response.headers['Content-Disposition'] = 'attachment; filename=my.pdf'
c = canvas.Canvas(self.response.out, pagesize=A4)
c.drawString(100, 100, "Hello world")
@saga
saga / gist:5786340
Created June 15, 2013 01:12
oo-uu.rhcloud.com
#!/usr/bin/env python
#*_* coding=utf8 *_*
from flask import Flask
#app = Flask(__name__)
import simplejson
import logging
import random
import re
import datetime
#!/usr/bin/env python
from __future__ import unicode_literals
from __future__ import print_function
from argparse import ArgumentParser
import json
import re
import sys
try:
#Py3
@saga
saga / gist:5346957
Created April 9, 2013 16:01
Getting subject nodes
Public Sub SubjectList()
Dim TreeMgr As TreeManager
Dim SubjRoot As SubjectNode
Dim ChildNode As SubjectNode
Dim GrandChildNode As SubjectNode
Dim LeafNode As SubjectNode
Dim RootName As String
Dim Trees As List
Dim i%
'-----------------------------------------------------
@saga
saga / gist:5346941
Created April 9, 2013 15:59
Copy test
Private Sub CopyPasteTest(sourceFolderPath, destFolderPath, TestName)
'Copy a test, including design steps and parameters.
' For example:
' CopyPasteTest "Subject\TestFolder1", "Subject\TestFolder2", "Test1"
' Copies Test1 to TestFolder2
Dim sourceFolder As SubjectNode
Dim destFolder As SubjectNode
Dim treeMng As TreeManager
@saga
saga / gist:5346913
Created April 9, 2013 15:56
Downloading test files and attachments
Public Sub TestFilesAndAttachments(theTest As TDAPIOLELib.Test)
' This routine gets a test object and
' first downloads the script files and then the attachments.
' The debug outputs are based on test:
' "OTA_DEMO_SUBJECT\OTA_SUBJECT_level1\OTA_SUB_1.2\SimpleVAPI-XP"
Dim TestAttachFact As AttachmentFactory
Dim attachList As List, TAttach As Attachment
Dim TestAttachStorage As IExtendedStorage
@saga
saga / gist:5346904
Created April 9, 2013 15:56
Get a test object with name and path
Public Function GetTest(ByVal TestName As String, _
ByVal SubjectPath As String, _
Optional delimChar As String = "\") _
As TDAPIOLELib.Test
'This function gets a test name and path and
'returns a test object.
Dim TestFact As TestFactory, testList As List
Dim TestFilter As TDFilter
On Error GoTo GetTestErr
Public Function CheckForAnyMatch(reqID As Long) As HierarchySupportList
'###############################################################
' This example shows the use of the IHierarchyFilter to check
' whether there are any requirements in the project that match
' a filter, by not specifying an ID for the root of the search.
' Case A: There is at least one requirement that matches the filter
' Case B: There is no requirement in the project that matches the filter
' 2) Finding which sub-trees under a specific requirement contain at least
' one requirement that matches the filter.
Public Function GetSubjectNodeByPath(ByVal fullPath As String, _
Optional delimChar As String = "\") _
As SubjectNode
' This function returns the Test SubjectNode object
' corresponding to the lowest level of a path.
' The path format is:
' "OTA_DEMO_SUBJECT\OTA_SUBJECT_level1\OTA_SUB_1.1\OTA_SUB_1.1.1\OTA_SUB_1.1.1.1"
' If a backslash is not used as the folder delimiter, any other
' character can be passed in the delimChar arguement.
@saga
saga / gist:5095841
Created March 6, 2013 00:56
log with C++
//inline void _cdecl WriteLog(LPCTSTR lpszFormat, ...)
void WriteLog(LPCTSTR lpszFormat, ...) {
va_list args; va_start(args, lpszFormat);
int nBuf; TCHAR szBuffer[512];
nBuf = _vstprintf(szBuffer, lpszFormat, args); _ASSERTE(nBuf < sizeof(szBuffer));
OutputDebugString(szBuffer);
va_end(args);
}