Skip to content

Instantly share code, notes, and snippets.

@haroldcris
haroldcris / gist:cdee2e44045e52101834f72ee938f9bc
Created March 20, 2018 10:14
Get MS Sql Parameters from Stored Procedure
SELECT SCHEMA_NAME(SCHEMA_ID) AS [Schema],
SO.name AS [ObjectName],
P.parameter_id AS [ParameterID],
P.name AS [ParameterName],
TYPE_NAME(P.user_type_id) AS [ParameterDataType],
P.max_length AS [ParameterMaxBytes],
P.is_output AS [IsOutPutParameter]
FROM sys.objects AS SO
INNER JOIN sys.parameters AS P
ON SO.OBJECT_ID = P.OBJECT_ID
@haroldcris
haroldcris / ConvertWinServer2016ToStandard
Created November 5, 2017 15:49
Convert WIndows Server 2016 Evaluation to Standard
dism /online /set-edition:ServerStandard /productkey:WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY /accepteula
---------------------------------------------------------------------------------------------------
The product key that is used here is the KMS key for Windows Server 2016 Standard Edition.
Reboot the server (it will reboot twice!).
Checking winver.exe:
03-windows-server-2016-eval-to-licensed
//
// Taken from https://cborrow.wordpress.com/2009/11/13/c-remove-flicker-in-mdi-applications/
//
const int WM_NCPAINT = 0x85;
const int WM_SIZE = 0x05;
//Add this to MDI CHILD FORM
public static void InvokeIfRequired(this ISynchronizeInvoke obj, MethodInvoker action)
{
if (obj.InvokeRequired)
{
var args = new object[0];
obj.Invoke(action, args);
}
else
{
action();
-- 1) Create AUDIT Table.
IF NOT EXISTS
(SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[dbo].[Audit]')
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE Audit
(Type CHAR(1),
TableName VARCHAR(128),
PK VARCHAR(1000),
FieldName VARCHAR(128),
OldValue VARCHAR(1000),
/*
MODIFIED CODE FROM
__________________________________________________________________
Name: CS SPROC Builder
Version: 1
Date: 10/09/2004
Author: Paul McKenzie
*/
SET NOCOUNT ON;
@haroldcris
haroldcris / RegisterDLL
Last active March 25, 2017 09:54
Register DLL from C#
public class Registrar : IDisposable
{
private IntPtr hLib;
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
internal static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32.dll", SetLastError = true)]
internal static extern IntPtr LoadLibrary(string lpFileName);
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>CrudSave</Title>
<Shortcut>crudsave</Shortcut>
<Description>Code snippet for Basic Saving</Description>
<Author>AiTech Solutions</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
public string ImageToBase64(Image image,
System.Drawing.Imaging.ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
// Convert byte[] to Base64 String
# Fix the issue of MS-SQL Character Encoding to Laravel
# /etc/freetds.conf
[global]
tds version = 8.0
client charset = UTF-8