Skip to content

Instantly share code, notes, and snippets.

View haroldcris's full-sized avatar

Harold Cris haroldcris

View GitHub Profile
@haroldcris
haroldcris / laravel-post-wrapper
Created June 17, 2015 17:03
A simple Laravel Blade Post wrapper
<script src='/packages/promise/promise.js'></script>
<script>
function postMyData(formName,dialogRef){
return new RSVP.Promise (function(resolve, reject){
var form = $('#' + formName);
//add token
if($(form).find('input[name="_token"]').length == 0) $(form).append('{{Form::token()}}');
var action = $(form).attr('action');
# Fix the issue of MS-SQL Character Encoding to Laravel
# /etc/freetds.conf
[global]
tds version = 8.0
client charset = UTF-8
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
<?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>
@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);
/*
MODIFIED CODE FROM
__________________________________________________________________
Name: CS SPROC Builder
Version: 1
Date: 10/09/2004
Author: Paul McKenzie
*/
SET NOCOUNT ON;
-- 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),
public static void InvokeIfRequired(this ISynchronizeInvoke obj, MethodInvoker action)
{
if (obj.InvokeRequired)
{
var args = new object[0];
obj.Invoke(action, args);
}
else
{
action();
//
// 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
@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