Skip to content

Instantly share code, notes, and snippets.

@kasajian
kasajian / Store.cs
Last active November 17, 2023 13:47
Store C# class for streaming / serializing .NET objecfts to XML
using System.IO;
using System.Xml.Serialization;
//--------------------------------------------------------------------------
// Saves an object to an XML file and Loads an object from an XML file.
//
// Examples -- saves to a file:
// CMyClass myobject;
// myobject = ....
// Store<CMyClass>.Save("myobject.xml", myobject);
@kasajian
kasajian / AIMS.md
Last active August 29, 2015 14:01
A.I.M.S. (Action Item Management System)

A.I.M.S. (Action Item Management System)

Action item is assigned by Assigner to Assignee.

  • All action items must have a next action date. Upon assignment, the Assignee is responsible for providing the Assigner the completion date for the action item or a path to the date by which the completion date is identified.
  • Action items conveyed verbally must be followed by e-mail to insure that there's no miscommunications and that the expected deliverables are clear.
  • An Assignee may reassign the action item to another Assignee. The original Assginee must inform the Assigner of the assignment change. (i.e. there's always an owner for an action item.)
  • As soon as the Assignee is aware that they cannot deliver on a published date, they must inform the Assigner. Thus, it is not acceptable for a date to pass with no feedback from the Assignee.

top

@kasajian
kasajian / brain dead hash
Last active August 29, 2015 14:01
Brain Dead Hash Function
int
HashFunction(char *string, int size)
{
int hashkey = 1;
while (string[0])
{
hashkey = hashkey<<1^string[0];
string++;
}
@kasajian
kasajian / C Sharp Timer code
Created May 20, 2014 02:31
C Sharp Timer code for performance measuriment
// Stopwatch stopWatch = new Stopwatch();
// using ( new Timer( stopWatch ) )
// {
// Thread.Sleep(1000);
// }
// Print Timer.FormatTimeSpan(stopWatch.Elapsed);
//
public class Timer : IDisposable
{
private Stopwatch stopWatch;
@kasajian
kasajian / Clean.bat
Created May 20, 2014 02:34
Clean files
@echo off
rem call c14.bat
rem for /r . %%i in (*.sln) do devenv /clean debug "%%i"
rem for /r . %%i in (*.sln) do devenv /clean release "%%i"
del/f/s/q *.aps 2>nul
del/f/s/q *.bsc 2>nul
del/f/s/q *.exp 2>nul
del/f/s/q *.idb 2>nul
del/f/s/q *.ilk 2>nul
@kasajian
kasajian / locatebrowserpaths.bat
Created May 20, 2014 02:36
Locate Browser Executable Paths
@echo off
setlocal
rem SET PHANTOMJS_BIN=%AppData%\npm\node_modules\phantomjs\lib\phantom\phantomjs.exe
REM SET CHROME_BIN=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
rem SET CHROME_BIN=%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe
REM SET FIREFOX_BIN=C:\Program Files (x86)\Mozilla Firefox\firefox.exe
SET BROWSERPATH=
call :loc Chrome HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command
@kasajian
kasajian / ignore.hpp
Created May 20, 2014 02:43
C++ template to force use of function return value.
// If it is important that a return value not be ignored by the caller of a function,
// the template dont_ignore may be used as follows:
// BEFORE:
// int add( int x, int y )
// {
// return x + y;
// }
// AFTER:
// dont_ignore<int> add( int x, int y )
// {
@kasajian
kasajian / convert.cpp
Created May 20, 2014 02:46
Windows C++ / ATL way to: Convert ASCII to UNICODE
// My favorite way to convert from ASCII to UNICODE:
static_cast<LPCWSTR>(CComBSTR(static_cast<LPCWSTR>(_bstr_t(reinterpret_cast<const char*>( char*ascii_string_goes_here )))))
@kasajian
kasajian / ccom.cpp
Created May 20, 2014 02:48
Creating a COM Object in plain C++
#include <windows.h>
#include "ccom.h"
// In order to use from VBScript, you need to place the progID in the registry so
// that it can be used to obtain the CLSID of this class.
// VB script
/*
DIM X
DIM Y
SET X = CREATEOBJECT( "BrlsMath.Math" )
@kasajian
kasajian / detect.bat
Created May 20, 2014 02:59
Determine if an exe or bat can be invoked
rem To determine if 7za.exe is in the path:
for %%X in (7za.exe) do (set FOUND=%%~$PATH:X)
rem To determine if 7z.exe is at the specified location:
if exist "%programfiles(x86)%\7-zip\7z.exe" set FOUND=1