Skip to content

Instantly share code, notes, and snippets.

@guneysus
guneysus / How-to-Permalink-to-a-Gist's-Raw-File.md
Last active March 15, 2020 17:54 — forked from atenni/README.md
How to permalink to a gist's raw file
@guneysus
guneysus / Makefile
Created March 26, 2020 10:02 — forked from puzrin/Makefile
Makefile example for fontello.com API
# Edit here - set path to you directory with config.json & fonts
FONT_DIR ?= ./assets/vendor/fontello/src
### Don't edit below ###
FONTELLO_HOST ?= http://fontello.com
fontopen:
@if test ! `which curl` ; then \
@guneysus
guneysus / markdown-details-collapsible.md
Created March 27, 2020 11:07 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@guneysus
guneysus / FastMethodInvoker.cs
Last active April 8, 2020 09:44 — forked from CleanCoder/Reflaction
FastMethodInvoker
public static FastInvokeHandler GetMethodInvoker(MethodInfo methodInfo)
{
DynamicMethod dynamicMethod = new DynamicMethod(string.Empty,
typeof(object), new Type[] { typeof(object),
typeof(object[]) },
methodInfo.DeclaringType.Module);
ILGenerator il = dynamicMethod.GetILGenerator();
ParameterInfo[] ps = methodInfo.GetParameters();
Type[] paramTypes = new Type[ps.Length];
for (int i = 0; i < paramTypes.Length; i++)
@guneysus
guneysus / FP.cs
Last active April 8, 2020 09:43 — forked from CleanCoder/FP
Funtional Programming
struct Result<T> {
public T Ok { get; }
public Exception Error { get; }
public bool IsFailed { get => Error != null; }
public bool IsOk => !IsFailed;
public Result (T ok) {
Ok = ok;
Error = default (Exception);
}
@guneysus
guneysus / Task Extension.cs
Last active November 17, 2021 19:58 — forked from CleanCoder/Task Extension
Task Extensions
static async Task<T> Otherwise<T> (this Task<T> task, Func<Task<T>> orTask) {
task.ContinueWith (async innerTask => {
if (innerTask.Status == TaskStatus.Faulted)
return await orTask ();
return await Task.FromResult<T> (innerTask.Result);
}).Unwrap ();
}
static async Task<T> Retry<T> (Func<Task<T>> task, int retries, TimeSpan delay, CancellationToken cts = default (CancellationToken)) {
@guneysus
guneysus / HookFx.cs
Created May 11, 2020 11:34 — forked from NaxAlpha/HookFx.cs
Windows API Hook with C#
using System;
using System.Runtime.InteropServices;
public class FxHook:IDisposable {
const int nBytes = 5;
IntPtr addr;
Protection old;
byte[] src = new byte[5];
@guneysus
guneysus / engineer.md
Created May 15, 2020 10:30 — forked from v0lkan/engineer.md
The Evolution of a Software Engineer

This gist outlines the change in the depth and breadth of the tasks and responsibilities of a software engineer as she continuously improves herself.

I created this to supplement a discussion in an internal slack group; then I though the rest of the world might benefit from this too.

Contributions are always welcome.

Junior Engineer

  • Knowledge
USE master
go
SELECT sdes.database_id
,sdes.[host_name]
,sdes.[program_name]
,sdes.login_name
,sdes.login_time
,sdec.client_net_address
,sdec.local_net_address
,sdest.Query
@guneysus
guneysus / memory_docs_samples.md
Created July 20, 2020 20:15 — forked from GrabYourPitchforks/memory_docs_samples.md
Memory<T> API documentation and samples

Memory<T> API documentation and samples

This document describes the APIs of Memory<T>, IMemoryOwner<T>, and MemoryManager<T> and their relationships to each other.

See also the Memory<T> usage guidelines document for background information.

First, a brief summary of the basic types

  • Memory<T> is the basic type that represents a contiguous buffer. This type is a struct, which means that developers cannot subclass it and override the implementation. The basic implementation of the type is aware of contigious memory buffers backed by T[] and System.String (in the case of ReadOnlyMemory<char>).