Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
DinisCruz / 1s example
Created July 27, 2012 11:02
o2 Script: Simple examples of .script_Me() functionality
//var topPanel = "{name}".popupWindow(700,400);
var topPanel = panel.clear().add_Panel();
var textBox = topPanel.add_TextBox(true);
textBox.set_Text("hello world");
textBox.script_Me();
@DinisCruz
DinisCruz / O2 Script.cs
Created September 29, 2012 02:51
TM - Script to do batch save via web Browser
var browser = "browser".o2Cache(()=>open.browser());
browser.parentForm().alwaysOnTop();
var articles = teamMentor.articles();
var count = 1;
foreach(var article in articles)
{
"[{0}/{1}] saving: [{2}] {3}".info(count++ ,articles.size(), article.Library, article.Title);
var url = "http://localhost:3187/editor/{0}".format(article.Id);
browser .open(url)
@DinisCruz
DinisCruz / gist:3809710
Created October 1, 2012 05:57
O2Script - VisualStudio API - Example of GUI Scripting
//get a reference to the VisualStudio API
var visualStudio = new VisualStudio_2010();
//write an Error and Warning messages to the 'Error List' VisualStudio Window
visualStudio.errorList().add_Error("I'm an Error");
visualStudio.errorList().add_Warning("I'm an Warning");
//open a text file
visualStudio.open_Document("a text file".saveWithExtension(".exe"));
@DinisCruz
DinisCruz / 1st example with TextArea.cs
Created October 2, 2012 08:54
O2 Script - Simple File Viewer
var treeView = "C# files in a a path".popupWindow()
.add_TreeView();
var codeViewer = treeView.insert_Right("Source Code")
.add_TextArea();
treeView.afterSelect<string>((file) => codeViewer.set_Text(file))
.onDrop((path)=>{
treeView.clear();
foreach(var file in path.files("*.cs",true))
treeView.add_Node(file.fileName(),file);
@DinisCruz
DinisCruz / gist:3826642
Created October 3, 2012 12:19
O2 Script - VisualStudio API - create top menu and hook build events
var visualStudio = new VisualStudio_2010();
//add a button called "My Custom Code" to the "Tools" Menu (at bottom), which when clicked will
//invoke the myCustomCode function which will show a WinForms MessageBox
Action myCustomCode = ()=>{
"This is custom code executing".messageBox();
};
var toolsMenu = visualStudio.dte().get_Menu("Tools");
@DinisCruz
DinisCruz / cmd.bat
Created October 5, 2012 10:53
Git commands to upgrade the TM OWASP repository to the 3.2 version
git init
git remote add tm_master https://github.com/TeamMentor/Master
git remote add tm_library https://github.com/TeamMentor-OWASP/Library_OWASP
git remote add origin [email protected]:TeamMentor-OWASP/Master.git
git pull origin master
git branch -m master TeamMentor_3_1
git checkout --orphan master
git rm -rf .
git pull tm_master master:master
git fetch tm_library
@DinisCruz
DinisCruz / gist:3843849
Created October 6, 2012 04:27
O2 Script - that created the "Util - view and extract MSI files (using LessMSI) v1.0.exe"
//**************** StandAlone exe package and setup ****************
//O2Embed:LessMsi\lessmsi.exe
//O2Package:E:\O2_V4\_TempDir_v4.3.2.0\_ToolsOrApis\LessMsi\wix.dll
//O2Package:E:\O2_V4\_TempDir_v4.3.2.0\_ToolsOrApis\LessMsi\wixcab.dll
//O2Package:MSI_Icon.ico
O2ConfigSettings.O2Version = "LessMSI";
O2Setup.extractEmbededConfigZips();
if ("wixcab.dll".local().fileExists())
{
"wixcab.dll".local().file_Copy(PublicDI.config.EmbeddedAssemblies.createDir());
@DinisCruz
DinisCruz / gist:3869882
Created October 11, 2012 02:50
O2 Script - Create TM Library from CheckMarx CWE data
var tmSite = "http://localhost.:3187/";
var adminPwd = "{admin_pwd}";
var checkMark_XmlDumps = @"{path_to_folder_with}\_CheckMark_XmlDumps";
var teamMentor = "__teammentor".o2Cache<API_TeamMentor_WebServices>(
()=>{
var tm = new API_TeamMentor_WebServices(tmSite);
tm.login("admin", adminPwd);
return tm;
@DinisCruz
DinisCruz / gist:3880284
Created October 12, 2012 17:07
C# Sample to try saving a file with a 0 char in the filename
var tempDir = "".tempDir();
var fileName = "__" + '\x43' + "__.txt"; // this will work
//var fileName = "__" + '\x43' + '\x00' + "__.txt"; // this will NOT work
var filePath = tempDir.pathCombine(fileName);
return "some text".saveAs(filePath);
@DinisCruz
DinisCruz / gist:3887854
Created October 14, 2012 08:05
O2 Script: PoC - View FluentSharp_BCL Embeded Icons.h2
//var topPanel = panel.add_Panel(true);
var topPanel = "PoC - View FluentSharp_BCL Embeded Icons".popupWindow(1000,700).add_Panel(true);
var toolStrip = topPanel.add_ToolStrip().layout_Flow();
var iconsMappings = typeof(FormImages).ctor().propertyValues_MappedBy_Name<Bitmap>();
foreach(var iconMapping in iconsMappings)
{
var name = iconMapping.Key;
var image= iconMapping.Value;