Skip to content

Instantly share code, notes, and snippets.

View pmachapman's full-sized avatar

Peter Chapman pmachapman

View GitHub Profile
@pmachapman
pmachapman / LinkifyTextView.cs
Last active June 19, 2019 02:58
A Xamarin Android TextView that supports Linkify and gestures
// -----------------------------------------------------------------------
// <copyright file="LinkifyTextView.cs" company="Conglomo">
// Copyright 2019 Peter Chapman. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
namespace Conglomo.AndroidSupport
{
using Android.Content;
using Android.Runtime;
@pmachapman
pmachapman / EncodeCsvField.cs
Created November 5, 2018 03:58
Encode a field for a CSV file
/// <summary>
/// StringUtilities class
/// </summary>
public static class StringUtilities
{
/// <summary>
/// Encodes a string for a CSV field.
/// </summary>
/// <param name="field">The field to encode.</param>
/// <param name="separator">The separator (defaults to a comma).</param>
@pmachapman
pmachapman / GetForwardedIp.aspx
Created May 4, 2018 03:35
A simple test script to get what the forwarded IP address is
<% @Page Language="C#" %>
<%
Response.Write("'" + System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].Split(',')[0] + "'");
%>
@pmachapman
pmachapman / Spectre Registry Check.bat
Created February 16, 2018 19:46
Spectre/Meltdown Compatibility Registry Check
@echo off
cls
rem Spectre Compatibility Registry Check
rem By Peter Chapman <peter@conglomo.co.nz>
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat /v cadca5fe-87d3-4b96-b7fb-a231484277cc
if %ERRORLEVEL% EQU 0 goto :exists
color 4
echo FAIL: Registry Key Not Present
goto :end
:exists
@pmachapman
pmachapman / reboot.asm
Created April 2, 2017 01:54
Simple "reboot" assembly routine. Compile with: debug < reboot.asm
N REBOOT.COM
A 100
MOV AX, 40
MOV DS, AX
MOV AX, 1234
MOV [72], AX
JMP FFFF:0
R CX
10
// file: play2wav.c
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358
#endif
@pmachapman
pmachapman / messagebox_t.c
Created July 9, 2017 22:26
Another example on how to cast a char array to an LPCWSTR
#include <tchar.h>
#include <windows.h>
int main()
{
MessageBox(NULL, _T("Testing, 123!"), _T("Test"), MB_OK);
}
@pmachapman
pmachapman / messagebox.c
Created July 9, 2017 22:25
An example on how to cast a char array to an LPCWSTR
#include <windows.h>
int main()
{
MessageBox(NULL, (LPCWSTR)L"Testing, 123!", (LPCWSTR)L"Test", MB_OK);
}
@pmachapman
pmachapman / guidgenerator.c
Created July 7, 2017 08:13
Generates a GUID
#include <objbase.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
/* Declare variables */
GUID guid;
HRESULT result;
/* Display a help message */
@pmachapman
pmachapman / uuidgenerator.c
Created July 7, 2017 08:08
Generates a UUID
#include <rpc.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
/* Declare variables */
UUID uuid;
RPC_STATUS result;
/* Display a help message */