Skip to content

Instantly share code, notes, and snippets.

@GeeLaw
GeeLaw / onedrive-bug-report.md
Created Apr 29, 2021
Bug in Cloud Filer / Placeholder / Reparse Point Disguising / OneDrive sync engine
View onedrive-bug-report.md

Bug in Cloud Filer / Placeholder / Reparse Point Disguising / OneDrive sync engine

Starting from an unknown version of Windows 10, programs can no longer access dehydrated (online-only, placeholder) files with CreateFile(Ex) normally.

Consider the following excerpt:

// By default (if the program does not have a manifest, so it runs in Windows Vista mode),
// RtlQueryProcessPlaceholderCompatibilityMode returns PHCM_DISGUISE_PLACEHOLDER, and
// RtlQueryThreadPlaceholderCompatibilityMode returns PHCM_APPLICATION_DEFAULT.
@GeeLaw
GeeLaw / CreateAppointmentFromMessage.vb
Created Oct 16, 2020
Outlook macro: Create appointment from e-mail.
View CreateAppointmentFromMessage.vb
Option Explicit
Sub CreateAppointmentFromMessage()
Dim activeWin As Object
Dim targetItem As Object
Dim targetMsg As MailItem
Dim targetFolder As Folder
Dim newAppointment As AppointmentItem
Dim msgInspector As Inspector
@GeeLaw
GeeLaw / CrtpBenchmark.cs
Created Oct 4, 2020
CRTP benchmark (C#)
View CrtpBenchmark.cs
/**** Benchmarking CRTP without virtual dispatch in C#.
See https://geelaw.blog/entries/csharp-crtp-static-polymorphism-friendship/
Results on my Surface Book 2:
| milliseconds | struct, non-virtual | struct, virtual | virtual |
| :----------: | :-----------------: | :-------------: | :-----: |
| x86 Core 3.1 | 1065 | 1405 | 1431 |
| x64 Core 3.1 | 1015 | 1371 | 1418 |
| x86 Fx 4.7.2 | 1160 | 1501 | 1490 |
@GeeLaw
GeeLaw / Program.cs
Created Aug 11, 2020
`IEnumerable<T, TEnumerator>` for more precise type propagation in C♯ generics.
View Program.cs
/* See https://geelaw.blog/entries/csharp-generics-duck-typing/ for the context.
Copyright (c) 2020 by Gee Law
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the “Software”),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:
@GeeLaw
GeeLaw / trackfocus.cc
Created Mar 31, 2020
Track the focus of Windows using UI Automation.
View trackfocus.cc
/*
Copyright (c) 2020 by Gee Law
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@GeeLaw
GeeLaw / gnfa2.cpp
Created Aug 22, 2019
Creates a regular expression that accepts strings of length at least 15 that have a digit, a lowercase letter, an uppercase letter and a special character.
View gnfa2.cpp
// gnfa.cpp
// Copyright 2019 by Gee Law.
// Forked from https://gist.github.com/GeeLaw/be3aec94a6ba7c3817ef2e16d261f616
// Licensed under the MIT license.
#include<cstdio>
#include<vector>
#include<map>
template <typename TDerived, typename TBase>
@GeeLaw
GeeLaw / Move-PhotosInteractively.ps1
Created May 21, 2019
Photo organizer (V2EX 566127)
View Move-PhotosInteractively.ps1
& {
$source = '~\Documents\Playground\MovePhotos'
$destinations = @(
'~\Documents\Playground\MovePhotos\Category1',
'~\Documents\Playground\MovePhotos\Category2',
'~\Documents\Playground\MovePhotos\Category3'
)
$destinationNames = @(
'Category1',
@GeeLaw
GeeLaw / gnfa.cpp
Created Dec 29, 2018
Playing with generalized NFA. The program gets a positive number as input, and outputs a regular expression that matches positive decimal integer without leading zeros that is a multiple of the input number.
View gnfa.cpp
// gnfa.cpp
// Copyright 2018 by Gee Law.
// Licensed under the MIT license.
#include<cstdio>
#include<vector>
#include<map>
// #define DEBUG_ONLY(t) do { t; } while (false)
#define DEBUG_ONLY(t) do { } while (false)
@GeeLaw
GeeLaw / OutlookCourseMgmt.vb
Created Sep 21, 2018
Outlook course management macro
View OutlookCourseMgmt.vb
Option Explicit
' See https://geelaw.blog/entries/course-mgmt-outlook/
Dim termStartsOn As Date, curriculumCalendar As Folder
Sub AskForTermStartsOn()
Dim shouldAskNewDate As Boolean
TryAskNewDate:
@GeeLaw
GeeLaw / sfinae.cc
Created Aug 13, 2018
Use SFINAE to detect whether to_string is present.
View sfinae.cc
#include<string>
#include<iostream>
#include<utility>
#include<type_traits>
template <typename T, typename TType, bool value =
std::is_same<std::string, decltype(to_string(std::forward<T>(*(T *)nullptr)))>::value
>
struct has_to_string { };