Skip to content

Instantly share code, notes, and snippets.

@serge1
serge1 / get_mac_address.cs
Last active December 15, 2015 23:09
Retrieve and output MAC addresses for all network interfaces of local machine in C#
using System;
using System.Net.NetworkInformation;
using System.Linq;
namespace Test {
// Retrieve and output MAC addresses for all network interfaces of local machine
public class Program {
static void Main()
{
@serge1
serge1 / create_zip.bat
Created April 15, 2013 16:45
Create ZIP files without specialized tools/utilities on Windows
cscript zip.vbs zip_file.zip file1.ext file2.ext file3.ext
@serge1
serge1 / test2html.xsl
Created May 5, 2013 16:47
XSLT script for converting BOOST.TEST results to HTML report
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<!--link rel="stylesheet" href="test2html.css" type="text/css" /-->
<html>
<style>
@serge1
serge1 / readme.txt
Last active December 17, 2015 01:09
Invocation of Java Script for XSLT transformation on Windows host
Possible invocation methods:
- Command line console output:
cscript test.js
- Output in message box:
wscript test.js
- or, just double click
@serge1
serge1 / xml_struct.cs
Last active December 17, 2015 01:09
Print XML file structure for all XML files in given directory
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Xml.Linq;
namespace xml_struct
{
//-----------------------------------------------------------------------
class Program
@serge1
serge1 / search_and_replace.cpp
Created May 7, 2013 10:08
C++ STL implementation of string search and replace
void
search_and_replace( std::string& value, std::string const& search,
std::string const& replace )
{
std::string::size_type next;
for ( next = value.find( search ); // Try and find the first match
next != std::string::npos; // next is npos if nothing was found
next = value.find( search, next ) // search for the next match starting after
// the last match that was found.
@serge1
serge1 / gist:5705452
Created June 4, 2013 12:09
Example usage of MS build utility 'msbuild'
The whole solution compilation:
msbuild _project_.sln /t:Rebuild /p:configuration="Release"
Particular project compilation:
msbuild _project_.vcxproj /t:Rebuild /p:project="_project_" /p:platform="Win32" /p:configuration="Release"
@serge1
serge1 / input.xml
Last active August 30, 2022 19:24
XSLT Transform by simple Java code
import javax.xml.transform.*;
import javax.xml.XMLConstants;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.File;
public class XsltTransform {
public static void main(String[] args) throws TransformerException {
Source xslt = new StreamSource(new File(args[0]));
Source xml = new StreamSource(new File(args[1]));
@serge1
serge1 / DllTest.cpp
Created May 6, 2014 21:53
Using a C++ DLL from Python by involving ctypes package
#ifdef _MSC_VER
#define _SCL_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <string>
#include <sstream>
#include <string.h>
#include "DllTest.h"
@serge1
serge1 / HPTimer.hpp
Created May 11, 2014 12:00
High Precision Timer for Windows
#include <windows.h>
class HPTimer
{
public:
HPTimer( std::string name ) : total(0.0), name_(name)
{
}
void reset()