Skip to content

Instantly share code, notes, and snippets.

View acaly's full-sized avatar
📚
Learning

Zhenwei Wu acaly

📚
Learning
  • Toronto, Canada
View GitHub Profile
//From:
//https://gitlab.qarea.org/timeguard/tg-url-det/blob/master/addon/windows/url.cc
//https://gitlab.qarea.org/timeguard/tg-url-det/blob/1b63ac16f54ff6cf41fea4217985b19d7b2b29ac/addon/windows/url.cc
VARIANT urlProp;
editBoxElement->GetCurrentPropertyValue(UIA_ValueValuePropertyId, &urlProp); //get the string
BSTR url;
url = urlProp.bstrVal;
wstring urlStr(url, SysStringLen(url));
@acaly
acaly / reciprocal_fib.py
Last active December 9, 2023 18:24
A fast (but hard-to-read) implementation of Reciprocal fibonacci constant calculator in python. This was a UofT CSC373 assignment.
import array
import sys
import cProfile
# input
OutputCount = int(sys.argv[1])
# object init
@acaly
acaly / mem_speed_test.cpp
Last active October 18, 2018 21:18
Test speed of memory access across different pages
#include <cstdio>
#include <vector>
#include <chrono>
#include <thread>
static constexpr int test_size = 100000;
static constexpr int page_size = 4096;
static int data[test_size * page_size];
static int index[test_size];
@acaly
acaly / fastslim.py
Created November 12, 2018 23:55
Modification of UofT CSC369 A3 tracer code.
#!/usr/bin/python
# This program processes an address trace generated by the Valgrind lackey tool
# to create a reduced trace according to the Fastslim-Demand algorithm
# described in "FastSlim: prefetch-safe trace reduction for I/O cache
# simulation" by Wei Jin, Xiaobai Sun, and Jeffrey S. Chase in ACM Transactions
# on Modeling and Computer Simulation, Vol. 11, No. 2 (April 2001),
# pages 125-160. http://doi.acm.org/10.1145/384169.384170
import fileinput
@acaly
acaly / main.c
Created November 3, 2019 09:08
Transparent OpenGL with Gtk+.
/* For details see: https://stackoverflow.com/a/58678719/3622514 */
#include <gtk/gtk.h>
#include <gdk/gdkscreen.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkgl.h>
#include <GL/gl.h>
#include <GL/glu.h>
static gboolean supports_alpha = FALSE;
@acaly
acaly / ReflectionTest.cs
Last active December 2, 2020 23:11
Benchmark property set
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Reflection;
using System.Reflection.Emit;
public class ReflectionTest
{
private delegate void RefAction<T1, T2>(ref T1 p1, T2 p2);
private delegate void RefAction<T1, T2, T3>(ref T1 p1, T2 p2, T3 p3);
@acaly
acaly / RealConditionalWeakTableTests.cs
Last active April 13, 2021 00:36
An experimental implementation of .NET ConditionalWeakTable that allows collection of the table when value back-references the table.
using NUnit.Framework;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Threading;
namespace RealConditionalWeakTableTests
{
public class Tests
@acaly
acaly / coins.cpp
Last active June 14, 2021 10:49
Split a given amount using coins of specified denominations - SIMD optimized version.
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <ctime>
#include <chrono>
#include <memory>
#include <immintrin.h>
@acaly
acaly / StaticReflectionTest.cs
Last active September 14, 2021 07:35
Static reflection benchmark in .NET 6.
using BenchmarkDotNet.Analysers;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Running;
using System.Numerics;
using System.Runtime.CompilerServices;
@acaly
acaly / Program.cs
Last active June 16, 2024 09:24
C# image manipulation using SIMD
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;