Skip to content

Instantly share code, notes, and snippets.

@mh2media
mh2media / mysqlStringWP.sql
Created October 24, 2025 16:57
MySQL - search WP tables for string
SET @search = 'questdev01.wpengine.com';
SELECT CONCAT(
'SELECT ''', TABLE_NAME, ''' AS table_name, ''', COLUMN_NAME, ''' AS column_name, ',
'CAST(', COLUMN_NAME, ' AS CHAR(10000)) AS match_value FROM `', TABLE_NAME,
'` WHERE ', COLUMN_NAME, ' LIKE ''%', @search, '%'';'
) AS runme
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND DATA_TYPE IN ('char','varchar','text','mediumtext','longtext');
@mh2media
mh2media / cSharp.Core.NewConsole.cs
Last active March 29, 2020 22:56
cSharp - Core.Net - New Console App #Core #cSharp
dotnet new console
dotnet restore
dotnet build // gives the "Hello World" example program when empty
dotnet run
@mh2media
mh2media / cSharp.webConfig.Redirect.cs
Last active March 29, 2020 18:00
cSharp - web.config - Http-Https Redirect #webConfig #redirect #webdev
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
@mh2media
mh2media / cSharp.WebConfigRedirect.cs
Last active March 29, 2020 18:00
cSharp - WebConfig Block Login #webConfig #webdev #csharp
<rewrite>
<rules>
<rule name="Block login page" stopProcessing="true">
<match url="^login(\.aspx)?(/\s*\S*)*$" />
<conditions logicalGrouping="MatchAll">
<add input="{REMOTE_ADDR}" pattern="192.168.*.*" negate="true" />
<add input="{REMOTE_ADDR}" pattern="127.0.0.1" negate="true" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}" />
</rule>
@mh2media
mh2media / cSharp.authNetHash.cs
Created March 29, 2020 17:54
cSharp - AuthNet-Generate Hash #cSharp
// How to generate the new HMAC-SHA1 Has for Authorize.net
// !important - use next line to generate actual timestamp
// String timeStamp = GetTimestamp(DateTime.Now);
using System;
using System.Security;
@mh2media
mh2media / cSharp.ConnectionStrings.cs
Created March 29, 2020 17:53
cSharp - ConnectionStrings #cSharp
// Connection String defined in web.config
// need to have Using System.Configuration too!
using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["qConnectionString"].ConnectionString))
@mh2media
mh2media / cSharp.Callbacks.cs
Created March 29, 2020 17:52
cSharp - callbacks #cSharp
// This simple example shows how an interface can be used as a callback mechanism.
public interface ICallbackNotificationTest
{
void OnUpdate(string message);
}
class CallBackTest : ICallbackNotificationTest
{
public void OnUpdate(string message)
@mh2media
mh2media / cSharp.Iclonable.cs
Last active March 29, 2020 22:56
cSharp - Collections - IClonable - how to return a deep copy clone of an object #cSharp
// Shows how to return a deep copy clone of an object.
class CloneTest : ICloneable
{
public int SomeProperty { get; set; }
public object Clone()
{
CloneTest clone = new CloneTest();
clone.SomeProperty = this.SomeProperty;
@mh2media
mh2media / cSharp.IEnumb.cs
Last active March 29, 2020 22:57
cSharp - Collections - how to use IEnumerable and IEnumerator #cSharp #collections
// Example adapted from MSDN showing how to use IEnumerable and IEnumerator
public class CollectionTestItem
{
public CollectionTestItem(string Name, double Value)
{
this.Name = Name;
this.Value = Value;
}
@mh2media
mh2media / cSharp.IComparable.cs
Created March 29, 2020 17:48
cSharp - Collections - IComparable #collections #cSharp
// This is a simple example of IComparable for sorting, using one sort order.
class CompareTest : IComparable
{
public int SomeProperty { get; set; }
public CompareTest() { }
public CompareTest(int Value)
{
SomeProperty = Value;