Skip to content

Instantly share code, notes, and snippets.

View yuyoyuppe's full-sized avatar

Andrey Nekrasov yuyoyuppe

View GitHub Profile
@yuyoyuppe
yuyoyuppe / HandleTransferChannel.hxx
Last active July 12, 2020 10:35
A simple wrapper class for working with a spin-lock protected shared memory on Windows.
#include "SerializedSharedMemory.h"
class HandleTransferChannel
{
std::optional<HANDLE> _handle;
const DWORD _destination_pid;
public:
HandleTransferChannel(const DWORD destination_pid) noexcept
:_destination_pid{destination_pid}
{
#include <Windows.h>
#include <optional>
#include <Shlwapi.h>
#include <string_view>
#include <functional>
#include <atomic>
namespace timeutil
{
inline time_t from_filetime(const FILETIME& ft)
{
#pragma once
#include <mutex>
struct polymorphic_mutex
{
virtual void lock() = 0;
virtual void unlock() = 0;
virtual bool try_lock() = 0;
};
@yuyoyuppe
yuyoyuppe / reload_project.cs
Created December 10, 2019 12:06
Visual Studio Extension to enable binding reload project action to a hotkey
//------------------------------------------------------------------------------
// <copyright file="ReloadProject.cs" company="Company">
// Copyright (c) Company. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.ComponentModel.Design;
using System.Globalization;
using Microsoft.VisualStudio.Shell;
async function sleep_sort(a)
{
let sorted = [];
await Promise.all(a.map(async e => {
await new Promise(resolve => setTimeout(resolve, e));
sorted.push(e);
}));
return sorted;
}
var BookHTML = "";
var ImageCounter = 0;
const SleepAmount = 50;
function downloadUrlToFile(url, filename)
{
return fetch(url).then((t) =>
{
return t.blob().then((b) =>
{
@yuyoyuppe
yuyoyuppe / transparent_imgui.cxx
Created March 22, 2019 15:35
Proof of concept that ... DXGI_ALPHA_MODE_PREMULTIPLIED doesn't work. Just use small borderless window and set bg_color to rgba(x,x,x,1)
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#pragma comment(lib, "user32.lib")
#include <wrl.h>
#include <dxgi1_3.h>
#include <d3d11_2.h>
#include <d2d1_2.h>
#include <d2d1_2helper.h>
@yuyoyuppe
yuyoyuppe / TEDTOP10.js
Created January 16, 2016 14:23
TED talks TOP10 most popular themes
console.log("TED talks TOP10");
$(".h9").filter(function(i){
return $(this).parent().hasClass("topics__list__topic")
&& $(this).parent().text().indexOf("TED") < 0;
}).map(function() {
var match = /(.*)\n(\d+)/gm.exec($(this).parent().text());
var res = {};
res.name = match[1];
res.c = parseInt(match[2]);
return res;
#include <SFML/Graphics.hpp>
#include <chrono>
#include <iostream>
#include <vector>
///////////////////////////////////////////////////////////////////////////////////////////
// КОНСТАНТЫ, СТРУКТУРЫ И ПРОЧИЕ НЯШНОСТИ
float screen_width = 500;
float screen_height = 500;