Skip to content

Instantly share code, notes, and snippets.

@kasajian
kasajian / Leap year logic
Created May 20, 2014 03:11
Leap year logic
year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
@kasajian
kasajian / LockWorkstation.bat
Created May 20, 2014 03:13
LockWorkstation
C:\Windows\System32\rundll32.exe user32.dll, LockWorkStation
@kasajian
kasajian / Synonyms.md
Last active August 29, 2015 14:01
Meaining of Synonyms and stuff
Meaning Spelling Pronunciation Example
Synonym Same Different Different
Homonym Different Same Same stalk, spring
Heteronym Different Same Different wind
Homograph Different Same Don’t care stalk or wind
Homophone Different Don’t care Same rose or carrot/caret sea/see
Heterograph Different to / too / two
@kasajian
kasajian / c_sharp_component_creation.md
Created May 20, 2014 03:23
Command-line component creation with C Sharp

Create clock.cs:

public class Clock
{
     public System.String Now()
     {
	return "Don't know the time";
     }
}
@kasajian
kasajian / perf.cpp
Created May 20, 2014 03:38
C++ Timer for measuring performance
#if _DEBUG
file://=====================================================================
=========
// WinQueryPerformance
// Outputs and resets the performance counter.
// (For multiple timers, see CPerformanceTimer)
//
// Use it like so:
//
// WinQueryPerformance( 0 );
@kasajian
kasajian / fib.cpp.md
Created May 20, 2014 03:39
Calculate Fibonacci at compile time in C++
#include <stdio.h>

// The following code prints out the first five elements of the
// fibonacci series without calculating the values at runtime.

template <int param>
struct CFibonacci
{
 static const value;
@kasajian
kasajian / COMsHWND.md
Created May 20, 2014 03:41
How to get COM's HWND
        HWND prevWindow = NULL;
        HWND hwnd;
        for ( ;; )
        {
            hwnd = FindWindowEx( HWND_MESSAGE, prevWindow, L"OleMainThreadWndClass", NULL );
            if ( !hwnd )
                break;

 if ( GetWindowThreadProcessId( hwnd, NULL ) == GetCurrentThreadId() )

Bed Sheets

  • After drying my sheets, put both sheets and one pillowcase in the other pillow case. Fold neatly in a square. Next time you change sheets, you just take the one pillow case and all the sheets and pillow case are inside. No need to look for matches.

Clean your glass shower

  • To clean the glass in your shower easily, apply lemon juice to the glass with a sponge. Then, take newspaper and wipe the lemon juice off the glass. It will be clean and sparkle with no scrubbing!

Reheat Pizza

Can also be used as a way to hash a string.

/*    crc16 - crc16 routine
 *
 *    R.K. Irvine
 *
 *    This routine returns the crc16 for the string pointed
 * to by "in".
@kasajian
kasajian / EHaSwitch.cpp.md
Created May 20, 2014 03:50
Determine from code if compiled with /EHa switch
inline bool CodeHasEHaSwitch()
{
    bool dtorCalled = false;

    struct CCheckEHaSwitch
    {
        CCheckEHaSwitch( bool& dtorCalled) : dtorCalled( dtorCalled ) {}
        ~CCheckEHaSwitch() {  dtorCalled = true; }
 bool&amp; dtorCalled;