Skip to content

Instantly share code, notes, and snippets.

View HEskandari's full-sized avatar

Hadi Eskandari HEskandari

View GitHub Profile
@HEskandari
HEskandari / macapp.go
Created April 6, 2024 16:15 — forked from mholt/macapp.go
Distribute your Go program (or any single binary) as a native macOS application
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
//
// https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
//
// Bundling the .app is the first thing it does, and creating the DMG is the
// second. Making the DMG is optional, and is only done if you provide
// the template DMG file, which you have to create beforehand.
//
// Example use:
@HEskandari
HEskandari / foo.kt
Created January 14, 2016 09:13
Kotlin Annotations
annotation class foo
foo class bar {
}
@HEskandari
HEskandari / Test Async
Created January 3, 2014 09:46
NSubstitute and Async
using System.Threading.Tasks;
using NSubstitute;
using NUnit.Framework;
namespace ClassLibrary1
{
public interface ICalculationServiceAsync
{
Task Calculate();
}
[TestFixture]
public class MockingAsyncTask
{
[Test]
public async void can_mock_interface_methods_with_task_return()
{
var mock = NSubstitute.Substitute.For<ILongRunningOperation>();
var sut = new SystemUnderTest {Operaiton = mock};
await sut.Execute();
@HEskandari
HEskandari / ExceptionHandler.cs
Created April 20, 2012 06:11
Exception Handler? Or Thrower?
public ActionResult HandleException()
{
return HandleException(new Exception("An Exception Has Occurred"));
}
public ActionResult HandleException(Exception ex)
{
throw ex;
}
@HEskandari
HEskandari / ComponentsWithTypedFactoryTestCase.cs
Created January 11, 2012 07:30
Failing test for Windsor 3.0
// Copyright 2004-2012 Castle Project - http://www.castleproject.org/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@HEskandari
HEskandari / PixleFormat enum
Created October 11, 2011 11:40
PixelFormat enum in GDI+
namespace System.Drawing.Imaging
{
public enum PixelFormat
{
DontCare = 0,
Undefined = 0,
Max = 15,
Indexed = 65536,
Gdi = 131072,
Format16bppRgb555 = 135173,
@HEskandari
HEskandari / API Usage
Created September 29, 2011 19:50
Async Abstraction Usage
public IEnumerable<IResult> LoadReport(int reportId)
{
yield return Display.Busy();
var service = new ReportingServiceClient();
yield return Display.ChangeStatus("Preparing Reports...");
yield return new WebServiceResult().Invoke(service.PrepareReports);
@HEskandari
HEskandari / DefaultDecoderTests.cs
Created July 25, 2011 11:37
Failing test when deserializing xml content
[TestFixture]
public class DefaultDecoderTests
{
[Test]
public void XmlAttributes_Are_Not_Converted_To_Elements()
{
var customerRaw = @"<Customer Mode=""Add"">
<CustomerNo>02121V</CustomerNo>
</Customer>";
@HEskandari
HEskandari / XmlDecoderTests.cs
Created July 6, 2011 18:39
Decoding string to dynamic and static objects (part of EasyHttp project)
[TestFixture]
public class XmlDecoderTests
{
[Test]
public void can_decode_xml_response_as_static_object()
{
IDecoder decoder = new XmlDecoder();
var xml = GetXmlContent();
var customer = decoder.DecodeToStatic<Customer>(xml, HttpContentTypes.ApplicationXml);