Skip to content

Instantly share code, notes, and snippets.

View kosmakoff's full-sized avatar

Oleg Kosmakov kosmakoff

  • DataArt
  • Wrocław, Poland
View GitHub Profile
@kosmakoff
kosmakoff / Program.cs
Created January 13, 2020 17:46
Sanitizing sensitive data with serilog
using System;
using System.Collections.Generic;
using System.Reflection;
using Serilog;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting.Json;
namespace SerilogSanitizer
{
openapi: 3.0.0
info:
title: Holdings API
version: 1.0.0
description: Holdings API
contact:
name: Oleg Kosmakov
email: oleg.kosmakov@dataart.com
paths:
"/v1/holdings/{id}":
@kosmakoff
kosmakoff / CodeGenerator.cs
Created November 30, 2016 20:18
Simple class that builds the type implementing arbitrary interface in-memory, and then constructs it and returns
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace CodeGenDemo
{
static class CodeGenerator
{
public static T GenerateStub<T>()
{
@kosmakoff
kosmakoff / OAuthFlowsCheatSheet.md
Created October 18, 2016 12:22
OAuth flows cheat-sheet
  • User interaction involved
    1. Authorization code
      This grant type is most appropriate for server-side web applications. After the resource owner has authorized access to their data, they are redirected back to the web application with an authorization code as a query parameter in the URL. This code must be exchanged for an access token by the client application. This exchange is done server-to-server and requires both the client_id and cli ent_secret, preventing even the resource owner from obtaining the access token. This grant type also allows for long-lived access to an API by using refresh tokens.
    2. Implicit grant for browser-based client-side applications
      The implicit grant is the most simplistic of all flows, and is optimized for clientside web applications running in a browser. The resource owner grants access to the application, and a new access token is immediately minted and passed back to the application using a #hash fragment in the URL. The application can immediately e
@kosmakoff
kosmakoff / PlistIssueDemo.c
Created May 11, 2016 16:58
Showing plist time issue, C version
#include <plist/plist.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define MAC_EPOCH 978307200
using System;
using System.Runtime.InteropServices;
namespace PlistDemo
{
class Program
{
static void Main(string[] args)
{
const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
@kosmakoff
kosmakoff / TextBlockExt.cs
Last active August 29, 2015 14:08
Custom TextBlock for WPF with specific measuring tweaks
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Media;
namespace TextBlockEx
{
[ContentProperty("Text")]
public class TextBlockExt : FrameworkElement
@kosmakoff
kosmakoff / enumsqlservers.cs
Last active October 18, 2016 12:23
Enumerating MS SQL Server instances in different ways
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.SqlServer.Management.Smo;