Skip to content

Instantly share code, notes, and snippets.

@gregseth
gregseth / Qt4.natvis
Created July 24, 2014 09:27
Visual Studio 2012 debugger info for Qt 4.5+
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="QPoint">
<AlternativeType Name="QPointF"/>
<DisplayString>{{ x = {xp}, y = {yp} }}</DisplayString>
<Expand>
<Item Name="[x]">xp</Item>
<Item Name="[y]">yp</Item>
</Expand>
@gregseth
gregseth / email-regex.md
Last active May 1, 2023 15:31
RegEx for RFC 2822 compliant email address.

Complete version

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\ x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

Simpler version

[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

Sources

@gregseth
gregseth / UnmanagedArrayConverter.cs
Last active May 12, 2021 07:23
Conversion of an unmanaged to a managed array of struct
/// <summary>
/// Méthode générique de conversion d'un pointeur sur une liste de
/// structures non managées, en un tableau managé de structures.
/// </summary>
/// <typeparam name="Struct">Le type de la structure</typeparam>
/// <param name="_P">Le pointeur vers le premier élément du tableau
/// non managé.</param>
/// <param name="_Size">La taille du tableau non managé.</param>
/// <returns>Le tableau managé contenant les structures.</returns>
Struct[] PtrToStructArray<Struct>(IntPtr _P, int _Size)
@gregseth
gregseth / oracle_to_date.sql
Last active August 12, 2019 09:28
Convert a number field standing for an unix timstamp, to a printable date with ORACLE.
SELECT TO_CHAR(TO_DATE('19700101','YYYYMMDD') + date/86400, 'YYYY-MM-DD HH24:MI:SS') FROM a_table_with_a_column_named_date;
@gregseth
gregseth / _readme.md
Last active August 12, 2019 09:24 — forked from gka/_readme.md
PHP Endpoint for Github Webhook URLs

PHP Endpoint for Github Webhook URLs

If you love deploying websites using Github, but for some reason want to use your own server, this script might be exactly what you need.

  1. Put github.php somewhere on your PHP-enabled web server, and make it accessible for the outside world. Let's say for now the script lives on http://example.com/github.php

Keybase proof

I hereby claim:

  • I am gregseth on github.
  • I am gregseth (https://keybase.io/gregseth) on keybase.
  • I have a public key whose fingerprint is 7449 E6EC 895D 0FDB FADB 4017 CB30 8791 3643 20B2

To claim this, I am signing this object:

@gregseth
gregseth / LibUnloader.cs
Last active December 14, 2015 00:59
Allows a managed .NET class to unload an unmanaged DLL.
public class LibUnloader, IDisposable
{
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr _HModule);
[DllImport("kernel32.dll")]
private static extern bool LoadLibraryA(string _HModule);
[DllImport("kernel32.dll")]
private static extern bool GetModuleHandleExA(UInt32 _Flags, string _ModuleName, ref IntPtr _HModule);
@gregseth
gregseth / ArrayStructure.cs
Created February 18, 2013 12:48
Boxing and unboxing of arrays (.NET 4)
class Util
{
public static Array GetArrayAs(Type t_, Array array_)
{
int iDimensions = array_.Rank;
int[] iSizes = new int[iDimensions];
int iCount = array.Length;
for (int i=0; i<iDimensions; ++i)