Skip to content

Instantly share code, notes, and snippets.

@kasajian
kasajian / Duffs_device.c
Created May 20, 2014 03:00
Duff's device - Fast way to copy in chunks in C
register n = (count + 7) / 8; /* count > 0 assumed */
switch (count % 8)
{
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;
case 4: *to = *from++;
case 3: *to = *from++;
case 2: *to = *from++;
@kasajian
kasajian / misquotes.md
Last active August 29, 2015 14:01
Irritating misquotes and mispronunciations
Mismatch in usage and meaning
its vs. it's
your vs. you're
then vs. than
"as far as xxx goes" vs. "as for, xxx"
except vs. accept
effect vs. affect
libel vs. liable
@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 / Idtypes.idl
Created May 20, 2014 03:19
Prefer Strong Type-checking of C++ Integral Types
#pragma once
//------------------------------------------------------------------------------
// Used for providing static type checking for all types, including intrinsics
//------------------------------------------------------------------------------
// Used for providing static type checking for all types, including intrinsics
// Summary
// Say you're using a LONG to represent a user ID. Ordinarly, you'd just use
// LONG data type in all your APIs. This isn't type safe because someone
// can pass in *any* LONG value -- and not necessary a user ID.
@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";
     }
}

To Disable UAC

Using a Batch file:

REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t "REG_DWORD" /d "0" /f

Using Powershell:

 @powershell Set-ItemProperty -Path registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -Value 0
@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 );