Skip to content

Instantly share code, notes, and snippets.

@pabloko
pabloko / Edge WebView2 on D3D11.md
Last active December 2, 2024 12:37
Rendering offscreen Edge (WebView2) to D3D11 texture for overlays (C++/win32)

Using Edge WebView2 is really straightforward, but using the Composition controller is poorly documented and only discussed on few issues in the WebView2 repo.

The browser itself is rendered on a separate process using DirectComposition API wich does not directly interoperate with DirectX, but can be readed using GraphicsCaptureItem WinRT apis. This means that a capture session must be setup into the host visual root, and it will provide accelerated GPU texture capture of the browser (with transparency)

There are few extra steps to setup this pipeline under win32 apps, apart of usual WebView2 setup:

  1. A DispatcherQueueController need to be created in the hosting thread in order to be able to use the Visual interfaces
  2. Use CreateCoreWebView2CompositionController instead CreateCoreWebView2Controller or its WithConfig equivalent.
  3. Create a WinRT DirectComposition IContainerVisual and IVisual as in the example
  4. Create a WinRT Direct3D11CaptureFramePool and start the session using `GraphicsC
@joe-niland
joe-niland / sqlite-to-mysql.py
Last active May 31, 2021 08:45 — forked from rednebmas/convert.py
Convert sqlite3 dump to mysql importable statements
#!/usr/bin/env python3
import re
import fileinput
print("SET FOREIGN_KEY_CHECKS=0;")
def main():
for line in fileinput.input():
@uid0
uid0 / onstart.hook
Created August 6, 2020 05:51
Taskwarrior On-Modify Hook for 'stup' integration
import sys
import json
import os
# Hook should extract all of the following for use as Timewarrior tags:
# UUID
# Project
# Tags
# Description
# UDAs
@AoJ
AoJ / HAclustering.md
Created June 17, 2020 09:30
High Availability (HA) and Clustering: 2-Node (Master / Slave) PostgreSQL Cluster
@wipash
wipash / Create-VM-cloud-init.ps1
Last active July 11, 2024 12:21
Create Linux VM on Hyper-V with cloud-init
<#
Create Unix VM's.
PREREQUISITES:
- A VM that has been installed with an OS that supports cloud-init
- cloud-init is installed on the vm
How it works:
- Asks for a bunch of parameters
- Creates a disk from parent vhdx for speed
<#
Create Unix VM's.
PREREQUISITES:
- A VM that has been installed with an OS that supports cloud-init
- cloud-init is installed on the vm
How it works:
- Asks for a bunch of parameters
- Creates a disk from parent vhdx for speed
@secretrob
secretrob / gitlab_to_jira.py
Last active March 28, 2024 10:33 — forked from mvisonneau/gitlab_to_jira.py
GitLab to Jira issue sync
#!/usr/bin/env python
import requests
import gitlab
from jira import JIRA
import urllib3
import json
## Disable urllib3 ssl checks warnings
urllib3.disable_warnings( urllib3.exceptions.InsecureRequestWarning )
@mdiener21
mdiener21 / round_minutes_to_quarter_hour.py
Last active April 4, 2024 09:05
Python round minutes to the nearest quarter hour
def round_to_nearest_quarter_hour(minutes, base=15):
"""
Input: A value in minutes.
Return: An integer rounded to the nearest quarter-hour (0, 15, 30, 45) based on the base interval,
with special handling to ensure rounding from 0 up to 7 goes to 0 and 8 to 15 round to 15
Example round_to_nearest_quarter_hour(0) rounds to 0
round_to_nearest_quarter_hour(7) rounds to 0
round_to_nearest_quarter_hour(8) rounds to 15
round_to_nearest_quarter_hour(22) rounds to 15
@mcastelino
mcastelino / qemu_netdev_socket_vlan.md
Last active December 16, 2024 19:18
QEMU usermode virtual vlan using -netdev socket

Goal

How to launch multiple QEMU based VM's that can communicate with the outside world and between each other other without any setup on the host.

This uses two features available in qemu

  • User Mode Networking stack - SLIRP
  • Socket networking backend allows you to create a network of guests that can see each other

This allows us to have

@romainl
romainl / vanilla-linter.md
Last active December 13, 2024 09:48
Linting your code, the vanilla way

Linting your code, the vanilla way

You may want a linter plugin to lint your code in Vim but you probably don't need it. At least try the built-in way before jumping on the plugin bandwagon.

Defining makeprg

autocmd FileType <filetype> setlocal makeprg=<external command>

This autocommand tells Vim to use <external command> when invoking :make % in a <filetype> buffer. You can add as many similar lines as needed for other languages.