Skip to content

Instantly share code, notes, and snippets.

View amenayach's full-sized avatar

Amen Ayach amenayach

View GitHub Profile
function http(url, method, payload, callback) {
const options = {
method: method ? method : 'GET',
headers: {
"Content-Type": "application/json"
}
};
if(payload) {
options.body = JSON.stringify(payload);
@amenayach
amenayach / SqlService.cs
Created August 20, 2019 08:31
Execute non-query MS SQL script using C#
namespace SqlSample
{
using System;
using System.Data;
using System.Data.SqlClient;
public class SqlService
{
private readonly string connectionString;
@amenayach
amenayach / Base64FileConverter.cs
Last active April 25, 2018 13:16
A C# base64 file converter.
using System;
using System.IO;
using System.Linq;
public static class Base64FileConverter
{
public static string ToBase64(byte[] bytes)
{
if (bytes == null || bytes.Length == 0)
@amenayach
amenayach / StickyInput.cs
Last active April 12, 2018 23:27
This helps to maintain last used inputs in a winform, let's say you have a Title and Description text boxes in a form F, this class will ensure when the form F is loaded that last entered input in these text boxes will be present at load event
namespace System.Windows.Forms
{
//This class requires JSON.net package, to install from the nuget console use:
//Install-Package Newtonsoft.Json
using Newtonsoft.Json.Linq;
using System.IO;
using System.Linq;
public static class StickyInput
{
@amenayach
amenayach / Mac.cs
Created August 11, 2016 07:34
Mac.cs is winforms class that makes a Form opens with sliding motion from one of four directions selected by the user. Usage: Mac.Slide(form);
//By Amen Ayach
using System;
using System.Windows.Forms;
using System.Drawing;
public class Mac
{
public enum eDirection
{
Up,