Skip to content

Instantly share code, notes, and snippets.

@gregseth
gregseth / _readme.md
Last active Aug 12, 2019 — forked from gka/_readme.md
PHP Endpoint for Github Webhook URLs
View _readme.md

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
View keybase.md

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 / Qt4.natvis
Created Jul 24, 2014
Visual Studio 2012 debugger info for Qt 4.5+
View Qt4.natvis
<?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 / oracle_to_date.sql
Last active Aug 12, 2019
Convert a number field standing for an unix timstamp, to a printable date with ORACLE.
View oracle_to_date.sql
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 / email-regex.md
Last active Nov 8, 2021
RegEx for RFC 2822 compliant email address.
View email-regex.md

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 / LibUnloader.cs
Last active Dec 14, 2015
Allows a managed .NET class to unload an unmanaged DLL.
View LibUnloader.cs
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 Feb 18, 2013
Boxing and unboxing of arrays (.NET 4)
View ArrayStructure.cs
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)
@gregseth
gregseth / UnmanagedArrayConverter.cs
Last active May 12, 2021
Conversion of an unmanaged to a managed array of struct
View UnmanagedArrayConverter.cs
/// <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)