Skip to content

Instantly share code, notes, and snippets.

View margusmartsepp's full-sized avatar
😇
It is that simple

Margus Martsepp margusmartsepp

😇
It is that simple
  • Gunvor SA
  • Tallinn
View GitHub Profile
@margusmartsepp
margusmartsepp / withoutpredicate.cs
Last active April 13, 2016 10:52
C# predicate example
public List<int> GetWeekdaysWithIntervalOverlaps(IEnumerable<int> selectedWeekdays, ChannelPlaylistPlaytimeRuleInterval interval, int channelPlaylistId)
{
var playtimeRules = GetChannelPlaylistPlaytimeRules(channelPlaylistId);
var overlappingDays = selectedWeekdays
.Where(weekdayIndex => IsOverlapped(playtimeRules, interval, weekdayIndex))
.ToList();
return overlappingDays;
}
public bool IsWeekdayWithIntervalOverlaps(int selectedWeekday, ChannelPlaylistPlaytimeRuleInterval interval, int channelPlaylistId, int channelPlaylistItemId)
@margusmartsepp
margusmartsepp / Program.cs
Created April 4, 2016 05:30
A* on IntervalHeap's (eucleidian distance heuristics)
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using C5;
namespace Ai.framework2
{
@margusmartsepp
margusmartsepp / Program.cs
Created April 1, 2016 14:08
ef7 code first + dapper
private static void Main(string[] args)
{
var connection = new SqlConnection(@"Server=(local);Database=EF7.ConsoleTests;Trusted_Connection=True;");
foreach (var result in connection.Query<Result>(@"
SELECT NAME as Name,
Count(NAME) AS Number
FROM [EF7.ConsoleTests].[dbo].[multiple] as k
GROUP BY NAME
ORDER BY Name, Number"))
{
@margusmartsepp
margusmartsepp / Ef7Tests.cs
Created April 1, 2016 11:48
Ef7 query test
using System;
using System.Linq;
using Microsoft.Data.Entity;
namespace Ef7Tests
{
internal class Program
{
/// <summary>
/// <para /> Nuget packages:
@margusmartsepp
margusmartsepp / AssemblyInfo.cs
Created March 19, 2016 10:19
Measure NUnit test times
[assembly: MeasureTimeSpan]
@margusmartsepp
margusmartsepp / RootCertificates.cs
Created March 16, 2016 13:42
install root certificate
public static class RootCertificates
{
public static async void AddEsteidSk()
{
try
{
var certificateFile = new Uri("ms-appx:///Assets/ESTEID-SK_2015.der.crt");
var file = await StorageFile.GetFileFromApplicationUriAsync(certificateFile);
var certBlob = await FileIO.ReadBufferAsync(file);
var trustedStore = CertificateStores.TrustedRootCertificationAuthorities;
@margusmartsepp
margusmartsepp / ExampleMain.cs
Last active March 16, 2016 21:20
Png images to gif
using System;
using System.Drawing;
using Gif.Components;
using System.Collections.Generic;
namespace Example
{
class ExampleMain
{
[STAThread]
@margusmartsepp
margusmartsepp / Program.cs
Created March 4, 2016 11:59
Conway's Game of Life
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;
namespace ConwaysGameOfLife
{
class Program
{
public class GameOfLifeConsoleUi
@margusmartsepp
margusmartsepp / Program.cs
Created February 11, 2016 21:05
SpeechSynthesizer with global hookups
using System;
using System.Speech.Synthesis;
using System.Windows.Forms;
using Gma.System.MouseKeyHook;
namespace SoundSynthesize
{
internal class Program
{
public static SpeechSynthesizer Talk;
@margusmartsepp
margusmartsepp / Program.cs
Last active February 6, 2016 12:33
Record audio output device
using System;
using NAudio.Lame;
using NAudio.Wave;
namespace CaptureAudio
{
class Program
{
static LameMP3FileWriter _writer;