Skip to content

Instantly share code, notes, and snippets.

Szymon Kulec Scooletz

Block or report user

Report or block Scooletz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Scooletz
Scooletz / sas.cs
Created Mar 17, 2018
Blob SAS Token
View sas.cs
public static string GetBlobReadonlySasToken(CloudStorageAccount account)
{
var now = DateTimeOffset.Now;
// to address emulator running on http
var nonHttps = account.BlobEndpoint.ToString().StartsWith("http:");
var sas = account.GetSharedAccessSignature(new SharedAccessAccountPolicy
{
Services = SharedAccessAccountServices.Blob,
@Scooletz
Scooletz / TFChunk.cs
Last active Feb 15, 2018
EventStore's TFChunk writing a reversable entry
View TFChunk.cs
var workItem = _writerWorkItem;
var buffer = workItem.Buffer;
var bufferWriter = workItem.BufferWriter;
buffer.SetLength(4);
buffer.Position = 4;
record.WriteTo(bufferWriter);
var length = (int) buffer.Length - 4;
bufferWriter.Write(length); // length suffix
buffer.Position = 0;
@Scooletz
Scooletz / json.net.cs
Created Feb 2, 2018
JSON.NET serializers Guid
View json.net.cs
public override void WriteValue(Guid value)
{
InternalWriteValue(JsonToken.String);
string text = null;
#if HAVE_CHAR_TO_STRING_WITH_CULTURE
text = value.ToString("D", CultureInfo.InvariantCulture);
#else
text = value.ToString("D");
@Scooletz
Scooletz / perf-counter-timer-1h.cs
Created Aug 17, 2017
This gist provides a test showing that AverageTimer32 handles ticks greater than int.MaxValue
View perf-counter-timer-1h.cs
namespace Tests
{
using System;
using System.Diagnostics;
using System.Security;
using System.Threading;
using NUnit.Framework;
public class PerformanceCounterCategoryTest
{
@Scooletz
Scooletz / Program.cs
Last active Apr 25, 2017
ProtofbufRaw vs regular protobuf-net
View Program.cs
using System;
using System.IO;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using ProtoBuf;
namespace Locals
{
class Program
@Scooletz
Scooletz / Program.cs
Last active Apr 21, 2017
ThreadStatic vs stackalloc
View Program.cs
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace Locals
{
class Program
{
@Scooletz
Scooletz / CodeCopPossibleBug.cs
Last active Mar 2, 2016
Both tests don't work. When a struct is turned into a class, they start to work
View CodeCopPossibleBug.cs
using System;
using CodeCop.Core;
using CodeCop.Core.Fluent;
using NUnit.Framework;
namespace CodeCop.Tests
{
public class CodeCopStructBugTests
{
public unsafe struct WithPtr
View PowerShell pre-push.sh
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
@Scooletz
Scooletz / SqlClientSqlCommandSet.cs
Created Sep 11, 2015
System.Data.SqlClient.SqlCommandSet extracted from Data internals, better than NHibernate, as no delegates creation is required beside the first static ctor
View SqlClientSqlCommandSet.cs
public class SqlClientSqlCommandSet : IDisposable
{
private static readonly Type SqlCmdSetType;
private readonly object _instance;
private int _countOfCommands;
private readonly static Action<object, SqlConnection> SetConnection;
private readonly static Func<object, SqlConnection> GetConnection;
private readonly static Action<object, SqlTransaction> SetTransaction;
private readonly static Func<object, SqlCommand> GetCommand;
View gist:9b78bd52451f76ba0eea
public class TestX
{
[Test]
public void T()
{
Inspect(typeof(int));
Inspect(typeof(long));
Inspect(typeof(bool));
Inspect(typeof(Guid));
}
You can’t perform that action at this time.