Skip to content

Instantly share code, notes, and snippets.

View georgimanov's full-sized avatar
😀

Georgi Manov georgimanov

😀
View GitHub Profile
@georgimanov
georgimanov / AnyVsCount.cs
Created December 27, 2017 21:37
Any vs Count - check if list is empty optimization
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace PerformanceKata
{
internal class Program
{
private static void Main()
@georgimanov
georgimanov / Program.cs
Last active July 15, 2017 05:52
C-Sharp Loop
using System;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
var myNubers = new byte[] { 72, 97, 112, 112, 121, 32, 66, 105, 114, 116, 104, 100, 97, 121, 33 };
for (int i = 0; i < myNubers.Length; i++)
@georgimanov
georgimanov / StartUp.cs
Created April 21, 2017 10:48
Swap Too Numbers
using System;
namespace SwapTooNumbers
{
public class StartUp
{
// How to swap to numeric values
public static void Main(string[] args)
{
int first = 1;
@georgimanov
georgimanov / canvas-square.html
Created November 17, 2016 16:50
q styled square
// html
<canvas width="300" height="300" id="ccc"> </canvas>
// css
#ccc {border:1px solid #000;}
// js
var canvas = document.getElementById("ccc");
var context = canvas.getContext('2d');
with(context){
@georgimanov
georgimanov / NextBoolTests.cs
Created October 23, 2016 16:49
Testing Next Bool
namespace MoreDotNet.Tests.Extensions.Common.RandomExtensions
{
using System;
using MoreDotNet.Extensions.Common;
using Xunit;
public class NextBoolTests
{
@georgimanov
georgimanov / IEnumerableExtensions.cs
Created February 23, 2016 11:07
IEnumerableExtensions
public static class IEnumerableExtensions
{
public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action)
{
foreach (var item in collection)
{
action(item);
}
}
}
@georgimanov
georgimanov / gist:fc90c5f0f25e645f0313
Created February 23, 2016 11:07
ObjectExtensions
using System;
public static class ObjectExtensions
{
public static T CastTo<T>(this object obj)
{
var result = Activator.CreateInstance(typeof(T));
foreach (var property in obj.GetType().GetProperties())
{
@georgimanov
georgimanov / BinarySearch.cs
Created August 14, 2015 14:17
BinarySearch
using System;
class BinarySearch
{
static void Main(string[] args)
{
Console.WriteLine("Enter string [example: 2, 3, -6, -1, 6, 4, -8, 8]");
string input = Console.ReadLine();
// Comment left for testing purposes only
// string input = "2, 3, -6, -1, 6, 4, -8, 8";