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);

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 / ide_requirements.md
Last active October 27, 2022 19:05
What I look for in an IDE

What I look for in an IDE

As someone who experiments with different programming languages and environments, the following are the requirements I look for in IDE integration, whether for Visual Studio Code, or another IDE.

Minimum

  1. "Run" command that runs a sample piece of code, given an entry point, and exits when it's done. Be able to do this multiple times, after making changes to the source in the editor.
  2. Run under a debugger. Place a break-point somewhere in the executation path, hit F5, and make sure it breaks there. Continuing after that, should go to the end and exit (not remain in the debugger)
  3. Run a set of tests.
  4. Place a breakpoint in any test or production code that's in the execution path of a test, run a set of tests (all tests), and hit the breakpoint on the first test that hits it.
@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 / Positions.md
Last active October 7, 2021 01:11
Job posting
@kasajian
kasajian / Search my gists.md
Created July 19, 2021 06:31
How to search gists

Enter this in the search box along with your search terms:

Get all gists from the user kasajian.
user:kasajian

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@kasajian
kasajian / C Promises.md
Last active October 23, 2020 09:38
promises

Promises

4557 We always imagine that a variable has a value. That is, as soon as a variable is created, it has some value, even if it's a default value. So if you have two variables, x and y, and you want to print the sum, you might code it this way:

WriteLine( x + y );

Now what if a variable's value doesn't exist right away, but will become available at some time in the future. The time in the future can be a long time, a short time or no time, but you don't know. The variable has a .Result property which will return the value, but blocking until the value is actually available. Let's say variable x is that type of a variable, so your code would now look like this:

WriteLine( x.Result + y );

@kasajian
kasajian / install rdp on ubuntu.txt
Last active October 23, 2020 08:55
install rdp on ubuntu.txt
$ sudo apt-get install ubuntu-desktop
$ sudo apt-get install xrdp
Then expose port 3389
sudo apt-get install xfce4
then modified the .xsession file in your home directory (if you dont have one, create it) and put the following line:
xfce-session
@kasajian
kasajian / recursive factorial through y-combinator.js
Last active October 23, 2020 08:55
recursive fatorial using y-combinator
var factorial = (f => {
return y => {
return f(y, f);
};
})((num, f) => {
return (num => {
if (num < 0) {
return -1;
} else if (num === 0) {
@kasajian
kasajian / powershell webserver.ps1
Last active October 23, 2020 08:51
powershell webserver
$Hso = New-Object Net.HttpListener
$Hso.Prefixes.Add("http://+:8000/")
$Hso.Start()
While ($Hso.IsListening) {
$HC = $Hso.GetContext()
$HRes = $HC.Response
$HRes.Headers.Add("Content-Type","text/plain")
$Buf = [Text.Encoding]::UTF8.GetBytes((GC (Join-Path $Pwd ($HC.Request).RawUrl)))
$HRes.ContentLength64 = $Buf.Length
$HRes.OutputStream.Write($Buf,0,$Buf.Length)